Skip to content

Instantly share code, notes, and snippets.


Aaron Statham astatham

  • Garvan Institute of Medical Research
  • Sydney, Australia
View GitHub Profile
astatham / JIRAtable.R
Last active Jan 15, 2017
Print a data.frame in JIRA/Confluence markup
View JIRAtable.R
JIRAtable <- function(x) {
message(paste0("||", paste(names(x), collapse="||"), "||"))
for (i in 1:nrow(x)) message(paste0("|", paste(sapply(x[i,], as.character), collapse="|"), "|"))
astatham /
Last active Sep 9, 2015
Convert a hg19 vcf to a b37d5 vcf - only handles chr1-22, X, Y & M
#!/bin/bash -e
if [[ ! -f "${1}" ]] ; then
echo "File $1 does not exist, aborting."
exit 1
# Replace double digit chromosomes first
for i in `seq 10 22` `seq 1 9` X Y; do
cmd="$cmd -e 's/chr$i/$i/g'"
astatham / logging.schema
Created Aug 6, 2014
logging qstat (DIRRTTY)
View logging.schema
account TEXT TEXT,
env_list TEXT,
gid TEXT,
grp TEXT,
job_name TEXT,
job_number TEXT,
jobshare TEXT,
mail_list TEXT,
astatham / 0_reuse_code.js
Created Jul 22, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
astatham / download_SRA.R
Created Mar 25, 2014
Example to download an SRA study wholly within R on wolfpack (our internal cluster)
View download_SRA.R
# wolfpack modules required: hugfre/R/3.0.2 fabbus/aspera/
ascpCMD <- "ascp -QT -l1000M -i /share/ClusterShare/software/contrib/fabbus/aspera/"
if (!file.exists("../SRAmetadb.sqlite")) db <- getSRAdbFile("../") else db <- "../SRAmetadb.sqlite"
con <- dbConnect(dbDriver("SQLite"), db) # load the SRA database
accession <- "SRP026604"
astatham / plotDensities.R
Created Feb 27, 2013
Lineplot of densities
View plotDensities.R
plotDensities <- function(s, col=NULL, xlim=NULL, ylim=NULL, na.rm=TRUE, lty=rep(1, length(s)), ...) {
if (!is.list(s)) s <- list(s)
if (is.null(col)) col <- rainbow(length(s))
sD <- lapply(s, density, na.rm=na.rm)
if (is.null(xlim)) xlim <- range(sapply(sD, function(x) range(x$x)))
if (is.null(ylim))ylim <- range(sapply(sD, function(x) range(x$y)))
plot(0, type="n", xlim=xlim, ylim=ylim, ...)
for (i in 1:length(sD)) lines(sD[[i]], col=col[i], lty=lty[i], ...)
astatham / lboxplot.R
Created Jul 5, 2012
lboxplot function - boxplots lists of lists
View lboxplot.R
lboxplot <- function(x, cols=2:(length(x)+1), ...) {
xl <- length(x)
if (xl<2) stop("Length of x must be >=2")
xn <- sapply(x, length)
if (!all(xn==xn[1])) stop ("Element lengths of x must all be the same")
xnames <- sapply(x, names)
if (!all(apply(xnames, 1, function(y) all(y==y[1])))) stop("Each element of x must have matching names")
xn <- xn[1]
xu <- unlist(x, recursive=FALSE)[rep(1:xn, each=xl)+rep((1:xl-1)*xn, xn)]
boxplot(xu, col=cols, xaxt="n", ...)
astatham / NOMe_plot.R
Created Jun 18, 2012
NOMe chart generator
View NOMe_plot.R
GpCplot <- function(amplicon, reads, main="", minScore=150) {
if (class(amplicon)=="character") amplicon <- DNAString(amplicon)
amplicon.conv <- DNAString(gsub("C", "T", gsub("GC", "GY", gsub("CG", "YG", amplicon))))
reads <- read.DNAStringSet(reads)
readsHitAll <- list("plus"=pairwiseAlignment(reads, amplicon.conv, type="local-global"), "minus"=pairwiseAlignment(reverseComplement(reads), amplicon.conv, type="local-global"))
readsStrand <- ifelse(score(readsHitAll$plus)>score(readsHitAll$minus), "+", "-")
reads2 <- reads
View cufflinks2TranscriptDB.R
cufflinks2TranscriptDB <- function(filename, verbose=TRUE) {
requiredAttribs <- c("gene_id", "transcript_id", "exon_number")
if (verbose) message("Importing ", filename)
tmp <- import.gff(filename, asRangedData=FALSE)
astatham /
Created May 11, 2011
Hacked together script to find all my .R files, and git the changes (to be run daily as a cron job)
#Important notes
#if backupdir is under homedir then backupdir must be included in the "$backupdir"/exclude file otherwise it will recurse
#also "$backupdir"/exclude file must not contain blank lines (match everything therefore backup nothing)
find "$homedir" -name "*.R" | grep -v -f "$backupdir"/exclude | grep -o \\/.*\\/ | sort | uniq | sed -e "s%"$homedir"/%"$backupdir"/%" -e 's% %_%g'| xargs mkdir -p