Skip to content

Instantly share code, notes, and snippets.

View CnrLwlss's full-sized avatar

Conor Lawless CnrLwlss

View GitHub Profile
@CnrLwlss
CnrLwlss / mtDNASpecies.R
Created March 14, 2019 13:38
Testing whether small deletions are under-represented within fibres containing multiple deletion species
# Testing whether small deletions are under-represented within fibres containing multiple deletion species
# Assume 200 mtDNA molecules per fibre section
Nassume = 200
# P7, P15 and P16 are the proportions of smaller mtDNA species in fibres with two or more mtDNA species
P7 = c(0.6,0.2,0.49,0.33,0.57,0.75,0.47,0.29,0.27,0.23,0.51,0.54)
N7 = rep(Nassume,length(P7))
Ndel7 = c(2,2,3,2,2,2,2,3,2,2,2,2)
P15 = c(0.39,0.73,0.37,0.17,0.43,0.53,0.54,0.57)
@CnrLwlss
CnrLwlss / mutationLoadMeasures.R
Last active September 19, 2018 09:35
Comparing measures of mtDNA mutation load in single cells.
library(grDevices)
library(gtools)
dat = read.delim("data/RTdata.txt",sep="\t",stringsAsFactors=FALSE)
dat$PNUM = as.numeric(gsub("P","",dat$Patient))
dat$ID = sprintf("P%02d_%04d",dat$PNUM,dat$Cell.number)
dat$PAT = sprintf("P%02d",dat$PNUM)
colfunc = colorRamp(c("blue","yellow","red"),space="Lab")
colfun = function(x, alpha=1.0) {
@CnrLwlss
CnrLwlss / explore_mitocyto.R
Created May 25, 2018 09:59
Generating some exploratory plots of mitocyto data.
# Read data and rename columns
dat = read.delim("mitocyto_merged_results.csv",sep=",",stringsAsFactors=FALSE)
colnames(dat) = c("value","id","channel","patient_id","patient_type")
# Specify which ids correspond to patients, and which to control
dat$patient_type = ifelse(dat$patient_id=="M1105","patient","control")
dat$patient_id = paste(toupper(substr(dat$patient_type,1,1)),dat$patient_id,sep="_")
# Specify some colours for plotting
dat$colour = "black"
@CnrLwlss
CnrLwlss / estimate_mu.R
Last active November 13, 2019 09:46
How many replicate samples do we need to estimate the mean of a distribution? 2-panel plot, random output.
mu = 5
stdev = 2
N = 10000
data = rnorm(N,mu,stdev)
pdf = function(x) dnorm(x,mu,stdev)
bestmu = function(N,x) sum(x[1:N])/N
op=par(mfrow=c(1,2))
#install.packages(c("mixOmics","RVAideMemoire"))
library(mixOmics)
library(RVAideMemoire)
# Calculate whether measure is greater in control group after scaling
# Used to colour points in VIP plots
direction=function(dt,measure){
dts = as.data.frame(scale(dt[,-1]))
dts$Group = dt$Group
res = median(dts[[measure]][dts$Group=="Control"],na.rm=TRUE) > median(dts[[measure]][dts$Group!="Control"],na.rm=TRUE)
@CnrLwlss
CnrLwlss / checktiff.py
Created February 9, 2018 12:01
Converting non-image .tiff data to pseudo-images (8-bit greyscale, high contrast).
from PIL import Image
import numpy as np
import os
for fname in os.listdir("."):
if fname.endswith(".tiff"):
im=Image.open(fname)
arr=np.array(im,dtype=np.uint16)
maxval = np.max(arr[arr>0])
minval = np.min(arr[arr>0])
@CnrLwlss
CnrLwlss / CompareCompanies.R
Last active January 31, 2018 16:22
siRNA screen scatterplots
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)
}

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 September 18, 2017 09:04
Attempt to consume ResortLock webservices
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 July 11, 2017 10:19
Adventures in plotting running data with 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)