Skip to content

Instantly share code, notes, and snippets.

Conor Lawless CnrLwlss

View GitHub Profile
@CnrLwlss
CnrLwlss / CompareCompanies.R
Last active Jan 31, 2018
siRNA screen scatterplots
View CompareCompanies.R
getReps = function(df,avedef){
dfA = df[df$RepeatNumber%in%c(1,3,5),]
dfB = df[df$RepeatNumber%in%c(2,4,6),]
dfaveA = aggregate(dfA,by=list(dfA$Gene),FUN=avedef)
dfaveA$Gene = dfaveA$Group.1
dfaveB = aggregate(dfB,by=list(dfB$Gene),FUN=avedef)
dfaveB$Gene = dfaveB$Group.1
dfreps = merge(dfaveA,dfaveB,by="Gene")
return(dfreps)
}
View SguaisUibhist_BBC.md

Sguais Uibhist - East Camp, Balivanich

A community run squash club

We have renovated the old RAF squash facilities at East Camp. We now have a nice, bright, warm court with changing rooms and great shower facilities available for the community. For the past 12 years, the nearest publicly available squash facilities have been in Portree and Stornoway.

An Caladh (charitable organisation supporting people struggling with addiction) kindly gave us permission to renovate the building and to use it for our club. Without their support, the project would never have gotten off the ground.

After a round of fundraising, we were awarded a large Scottish Landfill Community Fund grant from An Treas Roinn Innse Gall as well as grants from our local councillors, Sealladh na Beinne Mòire and Benbecula Community Council. We have also secured sponsorship from

@CnrLwlss
CnrLwlss / testlock.py
Last active Sep 18, 2017
Attempt to consume ResortLock webservices
View testlock.py
import requests
import json
authDict = {'client_id':'#####',
'client_secret':'#####',
'grant_type':'client_credentials'}
authRes = requests.post('https://connect.devicewebmanager.com/oauth/token',json=authDict)
print 'Authorisation response from server: ' + authRes.text
authFromServer = authRes.json()
@CnrLwlss
CnrLwlss / SteveRuns.R
Created Jul 11, 2017
Adventures in plotting running data with R.
View SteveRuns.R
distance=seq(0.2,4,0.2)
pace=rep(9,length(distance))
op=par(mfrow=c(2,2))
plot(distance,pace,type="b",main="Sensible")
plot(distance,pace/distance,type="b",main="A bit odd")
plot(distance,pace/(distance^2),type="b",main="WTF?!")
par(op)
@CnrLwlss
CnrLwlss / Focus.py
Created Apr 14, 2017
Image analysis script for finding and visualising the areas of an image that are in focus.
View Focus.py
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
@CnrLwlss
CnrLwlss / RectangularArray.R
Created Nov 30, 2016
Get best size for graphics array (array dimension that is most perfectly filled by correlation plots) when plotting possible pairwise combinations of variables against each other.
View RectangularArray.R
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)
@CnrLwlss
CnrLwlss / CustomErrorBars.py
Last active Nov 12, 2018
Script for plotting stripplot or swarmplot with barplot overlay, including custom error bars, with matplotlib/Seaborn.
View CustomErrorBars.py
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]
@CnrLwlss
CnrLwlss / Limited_logistic_mixture.R
Created Oct 22, 2016
Simulating growth of a nutrient-limited population consisting of a mixture of two lineages with different growth rates (but sharing resources, i.e. co-localised).
View Limited_logistic_mixture.R
# 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)
@CnrLwlss
CnrLwlss / miniQFA.JAGS
Created Oct 13, 2016
Bayesian hierarchical model, written in JAGS, representing relationship between spots on a QFA plate. Constrained, uniform priors all the way through hierarchy.
View miniQFA.JAGS
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
@CnrLwlss
CnrLwlss / ColourContrast.R
Last active Nov 12, 2019
Checking colour contrasts
View ColourContrast.R
# 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)
}
You can’t perform that action at this time.