Skip to content

Instantly share code, notes, and snippets.

Conor Lawless CnrLwlss

Block or report user

Report or block CnrLwlss

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ParallelWindows.R
library(parallel)
cores = 5
bigN = 50000000
# Function which can take a noticeable time to run for large N
sumnorm = function(N) sum(rnorm(N))
cl = makeCluster(cores)
@CnrLwlss
CnrLwlss / makeBounds.R
Created May 31, 2014
QFA logistic parameter bounds.
View makeBounds.R
makeBoundsQFA<-function(inocguess,d,minK=0,fixG=FALSE,globalOpt=FALSE){
if(is.null(inocguess)){
# Without a sensible independent estimate for inoculum density, the best we can do is to estimate it based on observed data.
# This strategy will only work well if the inoculum density is high enough to be measurable (e.g. pinned cultures or
# conc. spotted) and is clearly observed. Clearly observed means: no condensation on plates immediately after they are
# placed in incubator for example.
if(length(d$Growth)>0) {candidate=min(d$Growth)}else{candidate=0}
inocguess=max(0.001,candidate)
}
@CnrLwlss
CnrLwlss / PlotGrowthCurves.R
Created Sep 16, 2014
This is a short script to read in Colonyzer2 output after analysis of timecourse images of arrayed microbial cultures growing on solid agar surface. In this case it is assumed that the "time from inoculation" data are stored in the 4th element of an underscore delimited list embedded in the image filenames.
View PlotGrowthCurves.R
fnames = list.files(pattern="*.out")
datlist = lapply(fnames, read.delim,sep="\t",header=TRUE,stringsAsFactors=FALSE)
dat = do.call("rbind", datlist)
dat$ID=paste(dat$Barcode,dat$Row,dat$Column,sep="_")
dat$time=as.numeric(sapply(strsplit(dat$Filename,'_'), "[", 4))
dat=dat[order(dat$time),]
pdf("GrowthCurves.pdf")
by(dat,dat$ID,function(x) plot(x$time,x$Intensity,type="b",xlab="Time",ylab="Intensity",ylim=c(0,0.1),main=unique(x$ID)))
dev.off()
View QFA_ANALYSIS_LIST.R
# To execute this script manually, in parallel on multiple CPUs:
# Rscript Scripts/QFA_ANALYSIS_INDIVIDUAL.R QFA0028 QFA0029 &
# Rscript Scripts/QFA_ANALYSIS_INDIVIDUAL.R QFA0030 QFA0031 &
library(parallel)
source("Scripts/QFA_ANALYSIS.R")
PLOSGenetics=sprintf("QFA%04d",c(28,29,30,31,35,36))
# NCPUs is the maximum number of CPUs the script can use on this node (should be less than 48 on cisban cluster)
NCPUs=47
cisbanNodes=TRUE
@CnrLwlss
CnrLwlss / Search.py
Created Oct 22, 2014
A demo Colonyzer script: looking for cultures in a wider search space
View Search.py
from colonyzer2.functions import *
import time, sys, os, numpy, PIL
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("Note that this script requires a Colonyzer.txt file (as generated by ColonyzerParametryzer) describing initial guess for culture array")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
# Lydall lab file naming convention
# First 15 characters in filename identify unique plates
# Remaining charaters can be used to store date, time etc.
View numerical_r.R
library(qfa)
numerical_r=function(obsdat,mkPlots=FALSE,span=0.5,nBrute=1000,cDiffDelta=0.0001){
# Generate numerical (model-free) estimate for maximum intrinsic growth rate
tims=obsdat$Expt.Time
gdat=obsdat$Growth
tmax=max(tims)
# Smooth data, find slope as function of time and maximum slope
gdat=log(gdat)
@CnrLwlss
CnrLwlss / ParallelHaskellSO.hs
Last active Aug 29, 2015
Demo Haskell code for a SO question.
View ParallelHaskellSO.hs
import Control.Parallel (par, pseq)
import Control.DeepSeq
import System.Environment (getArgs)
import Data.Time.Clock (diffUTCTime, getCurrentTime)
data Tree x = Empty | Node x (Tree x) (Tree x) deriving (Show, Read, Eq)
-- Create instance of NFData for Tree data type (defining "normal form")
instance NFData a => NFData (Tree a) where
rnf Empty = ()
View ParallelSerialHaskell.hs
import Control.Parallel (par, pseq)
import Control.DeepSeq
import System.Environment (getArgs)
import Data.Time.Clock (diffUTCTime, getCurrentTime)
data Tree x = Empty | Node x (Tree x) (Tree x) deriving (Show, Read, Eq)
-- Create instance of NFData for Tree data type (defining "normal form")
instance NFData a => NFData (Tree a) where
rnf Empty = ()
@CnrLwlss
CnrLwlss / telo.hs
Created Dec 2, 2014
Simulating cell population dynamics with Haskell
View telo.hs
data Cell = Cell {teloLength :: Double, birthDate :: Double, lifeSpan :: Double, seedCell :: Integer}
instance Eq Cell where (Cell t1 _ _ _) == (Cell t2 _ _ _) = t1 == t2
instance Ord Cell where (Cell t1 _ _ _) `compare` (Cell t2 _ _ _) = t1 `compare` t2
instance Show Cell where show (Cell t b _ _) = show t ++ " " ++ show b
data CellLine x = Senescent | Mother x (CellLine x) (CellLine x) deriving (Show, Read, Eq)
-- Functions modelling cell biology
shortenTelo :: Cell -> Cell
shortenTelo (Cell telo x y oldseed) = Cell (telo - delta) x y newseed
@CnrLwlss
CnrLwlss / Vicky_Ztest.py
Created Mar 13, 2015
Z-test in python and alternative...
View Vicky_Ztest.py
# Demonstrating significant differences between a
# vector of measurements and a single value
# Using the statsmodels package for doing test
# Using numpy to generate some fake data
from statsmodels.stats import weightstats as stests
import numpy as np
data=np.random.normal(loc=3.4,scale=0.1,size=100)
singleValue=3.3
You can’t perform that action at this time.