Skip to content

Instantly share code, notes, and snippets.

@yk-tanigawa
Last active June 21, 2017 18:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yk-tanigawa/810f17a7eee5a99b476ce25807ee9a4d to your computer and use it in GitHub Desktop.
Save yk-tanigawa/810f17a7eee5a99b476ce25807ee9a4d to your computer and use it in GitHub Desktop.
Templates
Host github.com
User somebody@somewhere.com
Port 22
Hostname github.com
IdentityFile ~/.ssh/github
IdentitiesOnly yes
Host *
ControlMaster auto
ControlPath ~/.ssh/mux-%r@%h:%p
GSSAPIAuthentication no
Compression yes
CompressionLevel 9
Cipher arcfour256
ForwardAgent yes
TCPKeepAlive yes
ServerAliveInterval 15
ServerAliveCountMax 3
PasswordAuthentication no
def make_hist(x, title = None, xlabel = None, ylabel = None, filename = None):
'''
This function generates histogram of a vector x and save to file
Inputs:
x: data vector
title: title of the plot
xlabel: label on x-axis
ylabel: label on y-axis
filename: name of the image file (if given, save to file)
Returns:
matlab plot object
Side effect:
save an image file if filename is given
'''
import matplotlib
matplotlib.use('agg')
from matplotlib import pyplot as plt
fig = plt.figure(figsize=(8,6))
ax = fig.add_subplot(1, 1, 1)
ax.hist(x, 20)
if(xlabel != None):
ax.set_xlabel(xlabel)
if(ylabel != None):
ax.set_ylabel(ylabel)
if(title != None):
ax.set_title(title)
if(filename != None):
fig.savefig(filename)
return(fig)
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import itertools as it
font = {#'family' : 'normal',
#'weight' : 'bold',
'size' : 20}
matplotlib.rc('font', **font)
fig_conf_curves = plt.figure(figsize=(12, 7))
gs_conf_curves = gridspec.GridSpec(1, 2)
axs = [fig_conf_curves.add_subplot(ss) for ss in gs_conf_curves]
for i in range(10):
axs[0].plot(conf_curves[i, :, 0], conf_curves[i, :, 1])
axs[1].plot(conf_curves[i, :26, 0], conf_curves[i, :26, 1])
for ax in axs:
ax.set_xlabel('conservation bin')
axs[0].set_ylabel('BBL')
axs[0].set_title('conservation bin [0, 100]')
axs[1].set_title('conservation bin [0, 25]')
fig_conf_curves.suptitle(#
"""Confidence curves in 10 different sets of shuffle motifs
B_Atf1_primary, 10 * 10 shuffles, p_value_cutoff=1.3
"""
)
gs_conf_curves.tight_layout(fig_conf_curves, rect=[0, 0, 1, 0.88])
fig_conf_curves.savefig('./compareConfidenceCurves_B_Atf1_primary_curve.png')
def set_plt_style(n):
colors = sns.husl_palette(n)
markers = ['o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd'] * (int(n / 13) + 1)
linestyles = ['-', ':', '-.', '--', ':', '-.', '--'] * (int(n / 7) + 1)
return({'color': colors,
'marker': markers,
'linestyle': linestyles})
%matplotlib inline
import numpy as np
import scipy as sc
import pandas as pd
import itertools as it
import subprocess as sp
import colorlog
import sys
import re
import collections
import json
import enum
import bisect
import matplotlib
matplotlib.use('agg')
from matplotlib import pyplot as plt
logger = colorlog.getLogger()
logger.setLevel(colorlog.colorlog.logging.DEBUG)
handler = colorlog.StreamHandler()
handler.setFormatter(colorlog.ColoredFormatter())
logger.addHandler(handler)
logger.debug("Debug message")
logger.info("Information message")
logger.warning("Warning message")
logger.error("Error message")
logger.critical("Critical message")
#!/bin/bash
set -beEu -o pipefail
# (@) some comments
tmpRoot=/dev/shm
# Create a temp working dir. This dir will be automatically deleted.
tmpDir=$(mktemp -d -p $tmpRoot)
echo "tmpDir is $tmpDir"
handler_exit () { rm -rf $tmpDir ; }
trap handler_exit EXIT
import matplotlib.pyplot as plt
color = ['red', 'green', 'blue']
legend_loc = 'lower right'
label = ['red', 'green', 'blue']
# prepare matlabplt object
fig = plt.figure(figsize=(16,12))
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
# define plot region
ax.set_xlim(XMIN, XMAX)
ax.set_ylim(YMIN, YMAX)
# make a scatter plot
for j in xrange(CATEG_NUM):
ax.scatter(X_j,
Y_j,
c = color[j],
label = label(j))
# show legend
ax.legend(loc=legend_loc)
# return the object
return(plt)
#!/usr/bin/env perl
use 5.014;
use utf8;
use warnings;
use diagnostics;
use strict;
use Getopt::Long qw(:config posix_default no_ignore_case gnu_compat);
my ($in_file, $out_file, $param);
GetOptions(
"input|i=s" => \$in_file,
"output|o=s" => \$out_file,
"param|p=i" => \$param
);
%matplotlib inline
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd
from scipy import io
import math
sns.set_style("ticks")
sns.set_context("paper", font_scale=2.0)
import argparse
def main():
parser = argparse.ArgumentParser(description='test program')
parser.add_argument('--version', action='version', version='%(prog)s 20XX-XX-XX')
parser.add_argument('-o', metavar = 'o', default = None,
help = 'output file')
parser.add_argument('-p', metavar = 'p', type=float,default = 0.001,
help = 'param (default: 0.001)')
args = parser.parse_args()
print(args.O)
if __name__ == '__main__':
main()
#!/bin/sh
# Mail at end/on suspension
#$ -m es
#$ -S /bin/sh
#$ -cwd
#$ -V
#$ -q all.q
##################################################
# make a copy of this script
##################################################
cat $0 > "${SGE_O_WORKDIR}/${JOB_NAME}.s${JOB_ID}"
echo hello
#################################
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{bm}
\usepackage[dvips]{graphicx}
\usepackage[top=30truemm,bottom=30truemm,left=30truemm,right=30truemm]{geometry}
\begin{document}
\includegraphics[width = \linewidth, bb=0 0 10 10]{hoge.jpg}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment