Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View CnrLwlss's full-sized avatar

Conor Lawless CnrLwlss

View GitHub Profile
@CnrLwlss
CnrLwlss / Table S2_List of genetic interactions.csv
Last active May 16, 2021 09:19
Data for interactive SGA plot on Observable
R package version: 0.0-39
Summary type: median
Test type: wilcoxon
x-axis treatment: 20
x-axis medium: SDM_rhlk_TGNH
x-axis screen ID: SGA0188
x-axis screen name: CONTROL
x-axis libraries: SDLV4_1536
x-axis client: MMA
x-axis user: AAB
@CnrLwlss
CnrLwlss / ArrayImage.py
Created April 1, 2021 14:02
Converting arrays to images using Python
from PIL import Image
import numpy as np
# Generate a 100x100 array of random floats between 0.0 and 1.0
random_floats = np.random.rand(100,100)
# Scale these up to lie in the range of 8-bit integers (between 0.0 and 255.0)
random_floats_8bit = random_floats * 255.0
# Round these float values to the nearest integer
@CnrLwlss
CnrLwlss / simSamp.R
Last active February 26, 2021 11:10
Simulating uncertainty about randomly sampling a fraction of a small number of mtDNA molecules.
# Sampling noise
simulateSample = function(mtDNAPerWell=1000, mutantFraction=0.95, fracVolumeSampled=1.0/3.0){
# Create a synthetic population of mtDNA molecules
moleculeMutant = rbinom(n = round(mtDNAPerWell*fracVolumeSampled), size = 1, prob = mutantFraction)
# Calculate mutant fraction in sampled molecules
sum(moleculeMutant)/length(moleculeMutant)
}
simulateUncertainty = function(mtDNAPerWell=1000, mutantFraction=0.95, fracVolumeSampled=1.0/3.0, reps = 5000){
@CnrLwlss
CnrLwlss / rwalk.R
Created February 13, 2021 15:54
Plotting random walks
N = 10000
Ncurve = 1000
png("Walk.png",width=3000,height=1000,pointsize=12,type="cairo-png")
plot(NULL,ylim=c(-200,200),axes=FALSE,xlim=c(N/2,N),xlab="",ylab="")
for(i in 1:Ncurve) points(cumsum(rnorm(N,0,0.5)),type="l",col=rgb(0,0,0,0.1),lwd=2)
dev.off()
@CnrLwlss
CnrLwlss / sigdiff.R
Created October 22, 2020 17:07
Permutation test vs. bootstrap for hypothesis testing
nA = 8
meanA = 48
sdA = 3
nB = 10
meanB = 53
sdB = 4
set.seed(42)
nBoot = 100000
@CnrLwlss
CnrLwlss / laser_neighbours.R
Last active August 2, 2020 22:24
Calculates and visualises proportion of fibres that can be extracted/sampled, from a skeletal muscle section leaving all immediate neighbours of sampled fibres in place.
library(deldir)
library(png)
dat = read.delim("results.csv",sep=",",stringsAsFactors=FALSE)
im = readPNG("AVE_mitocyto.png")
h = dim(im)[1]
w = dim(im)[2]
td = data.frame(
xCoord = dat$Value[dat$Channel=="xCoord"],
@CnrLwlss
CnrLwlss / SciProg2020.md
Last active May 14, 2020 09:32
Scientific programming

What makes a great scientific computing language?

  • Expressivity: should be possible to express mathematical & programming concepts concisely & elegantly. This is important to reduce the mental overhead required for writing down and reading models and algorithms in the form of code.
  • Speed: should be possible to convert code into software/program that gets the most out of modern computer hardware
    • Functional Programming
    • Parallel computing
  • Extensibility: should have a powerful, unambiguous, easy to use package management system built right into the core of the language
  • Visualisation: a large and very important part of scientific programming is generating side-effects: writing reports, generating plots, creating interactive documents

R logo

@CnrLwlss
CnrLwlss / SciProg2020.md
Created May 13, 2020 22:53
Scientific programming

Why Julia?

  • Scientific programming language
  • Open source
  • Package management
  • Supports functional programming
  • Designed to take advantage of computers with multiple CPUs

Why R?

@CnrLwlss
CnrLwlss / usingSpeedTest.R
Created November 13, 2019 12:06
Generate broadband speed test reports
#https://github.com/hrbrmstr/speedtest
library(speedtest)
fname = "speedtest_results2.txt"
makeplots = FALSE
if(!makeplots){
config = spd_config()
servers = spd_servers(config = config)
servers = spd_closest_servers(servers, config)
best = spd_best_servers(servers, config, max = 3)
@CnrLwlss
CnrLwlss / StripchartOpacity.R
Last active June 14, 2019 16:57
R script demonstrating a few things: 1) drawing boxplots with notches roughly indicating significance of differences 2) stripcharts using transparency to highlight values of high density 3) overlaying boxplot on stripcharts and 4) writing plots as multi-page .pdf reports
# Info about boxplot notches https://sites.google.com/site/davidsstatistics/home/notched-box-plots
# Article about why not to use barplots https://doi.org/10.1371/journal.pbio.1002128
# Article about being wary of summary statistics and why raw data plots are better than boxplots https://www.autodeskresearch.com/publications/samestats
# Generate some fake data
concs = seq(0,10,1)
concobs = rep(concs,each=500)
mdel = function(x) -x^2+10*x+20
vals = mdel(concobs) + rnorm(length(concobs),0,12)
dat = data.frame(conc=concobs,val=vals)