Skip to content

Instantly share code, notes, and snippets.

@mw55309
mw55309 / excel_my_barplot.R
Created Jan 10, 2016
R code to create Excel-like barplot
View excel_my_barplot.R
x <- data.frame(d=runif(12), g=rep(1:4, each =3))
my.col <- c("deepskyblue3","darkorange2","darkgray","gold")
spacer <- c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0.1)
bw <- 0.8
xmax <- (sum(spacer) * bw) + (nrow(x) * bw)
View clear RAM
sync; echo 1 > /proc/sys/vm/drop_caches
View EU Remain
# data from https://twitter.com/LukeTurnerEsq/status/738308821207142400
d <- data.frame(min=c(18,30,40,50,60), max=c(29,39,49,59,85), remain=c(73,64,46,45,35), stringsAsFactors=FALSE)
# calc mid-points
mid <- d$min + ((d$max - d$min) / 2)
# fit model and plot
lmfit <- lm(d$remain~mid)
plot(mid, d$remain, pch=16, xlab="Age", ylab="% who support REMAIN in EURef")
abline(lmfit)
View yapyap example
YAPYAP first uniquely mapped primary;second uniquely mapped primary 152876366
YAPYAP first uniquely mapped primary;second uniquely mapped primary soft-clipped 7347030
YAPYAP first uniquely mapped primary soft-clipped;second uniquely mapped primary soft-clipped 3420363
YAPYAP first uniquely mapped primary soft-clipped;second uniquely mapped primary 2772544
YAPYAP first unmapped;second unmapped 579939
YAPYAP first uniquely mapped primary;second unmapped 522762
YAPYAP first uniquely mapped primary;second multi-mapped one primary 228682
YAPYAP first multi-mapped one primary;second uniquely mapped primary soft-clipped 183838
YAPYAP first uniquely mapped primary soft-clipped;second multi-mapped one primary 175894
YAPYAP first multi-mapped one primary;second uniquely mapped primary 148302
View brexit
d <- read.csv("http://www.electoralcommission.org.uk/__data/assets/file/0014/212135/EU-referendum-result-data.csv")
vec <- rep(1, nrow(d))
vec[d$Region=="Scotland"] <- 1
vec[d$Region=="North East"] <- 2
vec[d$Region=="North West"] <- 3
vec[d$Region=="East Midlands"] <- 4
vec[d$Region=="West Midlands"] <- 5
vec[d$Region=="Yorkshire and The Humber"] <- 6
vec[d$Region=="Northern Ireland"] <- 7
View pore_for_nick
mydir <- "/data2/minion/R7/Ebola/PRJEB10571_ERR1014225/014370/pass/"
meta <- read.meta.info(dir=mydir, path.t="/Analyses/Basecall_2D_000/", path.c="Analyses/Basecall_2D_000/")
yield <- plot.cumulative.yield(meta)
plot.length.histogram(meta)
meta.s <- summarise.by.channel(meta)
View Shuffle fasta output from Polyester
# Polyester (https://github.com/alyssafrazee/polyester) simulates RNA-Seq reads
# Output is FASTA and sorted by input transcript ID
# Some tools don't like this e.g. Salmon, and want a more random order
# Here is a one-liner for shuffling the reads from sample 1 in output directory test.out
cat test.out/sample_01.fasta | paste - - | shuf | awk '{print $1"\n"$2}' > test.out/sample_01.shuf.fasta
View sqrt plot
par(mar=c(2,2,1,1))
plot(sqrt, bty="n", xaxt="n", yaxt="n", xlab="", ylab="")
axis(side=1, at=seq(0,1,by=0.2), las=1, labels=FALSE)
axis(side=2, at=seq(0,1,by=0.2), las=2, labels=FALSE)
axis(side=1, at=seq(0,1,by=0.2), las=1, labels=TRUE, tick=FALSE, line=-0.5, cex.axis=0.8)
axis(side=2, at=seq(0,1,by=0.2), las=2, labels=TRUE, tick=FALSE, line=-0.5, cex.axis=0.8)
axis(side=1, at=0.5, labels="x", tick=FALSE, line=0)
View cowplot_mimic
## functions
plot.histograms <- function(cname="", flip=FALSE, xlim) {
dse <- density(setosa[, cname])
dve <- density(versicolor[, cname])
dvi <- density(virginica[, cname])
ymax <- max(c(dse$y, dve$y, dvi$y))
View magpy_thoughts
Download Miniconda
Main env (python 3.5):
- snakemake
- Ete3?
- CheckM
- HMMER
- pplacer
- FastTree
- Prodigal