This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
from scipy import ndimage | |
import numpy as np | |
def getVar(im, sigma = 4.0): | |
'''Identifies & highlights areas of image fname with high pixel intensity variance (focus)''' | |
imbw = im.convert("F") # Convert im to greyscale array | |
arrbw = np.array(imbw) | |
sub_mean = ndimage.gaussian_filter(arrbw, sigma) # Calculate variance in area around each pixel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fdefpairs=t(combn(fdefs,2)) | |
npairs=dim(fdefpairs)[1] | |
a=round(sqrt(npairs)) | |
if((a+1)*(a+1)>=npairs) mfrow=c(a+1,a+1) | |
if((a+1)*a>=npairs) mfrow=c(a,a+1) | |
if(a*a>=npairs) mfrow=c(a,a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import seaborn as sns | |
tips = sns.load_dataset("tips") | |
print(sns.__version__) | |
print(tips.head()) | |
ax=sns.swarmplot(x="day", y="total_bill", hue="sex", data=tips,split=True) | |
sns.barplot(x="day", y="total_bill", hue="sex", data=tips,capsize=0.1,errwidth=1.25,alpha=0.25,ci=None) | |
xcentres=[0,1,2,3] | |
delt=0.2 | |
xneg=[x-delt for x in xcentres] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install and load ODE solver package | |
#install.packages("deSolve") | |
library(deSolve) | |
# Named vector of parameter values | |
parameters=c(r_1=1.0,r_2=1.1,K=1) | |
# Named vector of initial conditions | |
state=c(x_1=0.01,x_2=0.01) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model { | |
tau_min <- 10000 | |
tau_max <- 1000000 | |
x0_min <- 0.0 | |
x0_max <- 0.05 | |
r_min <- 0.0 | |
r_max <- 10.0 | |
K_min <- 0.0 | |
K_max <- 0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Visual comparison of the contrast between colours and different solid backgrounds | |
colourGrid=function(dimval=20,background="gray",colourfun=rainbow,ptsize=1){ | |
cols=colourfun(dimval^2) | |
yvals=rep(seq(0,1,length.out=dimval),each=dimval) | |
xvals=rep(seq(0,1,length.out=dimval),dimval) | |
plot(xvals,yvals,type="n",xaxt="n",yaxt="n",ann=FALSE, bty="n") | |
rect(par("usr")[1],par("usr")[3],par("usr")[2],par("usr")[4],col = background,border=NA) | |
points(xvals,yvals,col=cols,pch=16,cex=ptsize) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Plot comparing ranks | |
import string | |
import random | |
import matplotlib.pyplot as plt | |
from matplotlib import cm | |
import numpy as np | |
def experiment(genes,vmin=0.0,vmax=1.0): | |
'''Simulate an experiment with (average) measurement for a set of genotypes''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib as mp | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import string | |
# Set font for figure according to journal specs | |
mp.rcParams['font.family'] = "Arial" | |
# Gene deletion names read from file might not necessarily be in lower case | |
gnames=["EXO1","RAD9","TMA20"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://matplotlib.org/examples/color/colormaps_reference.html | |
#http://matplotlib.org/users/colormaps.html | |
import matplotlib.pyplot as plt | |
from matplotlib import cm | |
import numpy as np | |
N = 200 | |
x = np.random.randn(N) | |
y = np.random.randn(N) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hierarchical uniform distributions | |
Nsamps=500000 | |
r_min=1 | |
r_max=10 | |
trunc=FALSE | |
makePlot=function(){ | |
xlim=c(-5,15) | |
op=par(mfrow=c(1,3)) | |
hist(r,breaks=100,freq=FALSE,xlim=xlim) |