Skip to content

Instantly share code, notes, and snippets.

@rajarshi
Created May 17, 2016 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajarshi/3a266308363e2ae25eec77f45c9966a1 to your computer and use it in GitHub Desktop.
Save rajarshi/3a266308363e2ae25eec77f45c9966a1 to your computer and use it in GitHub Desktop.
library(ncgchts)
library(ggplot2)
library(RColorBrewer)
library(stringr)
data(sample.info)
con <- get.connection('hts', 'ncgc', 'probedb')
curve.order <- c(-1.1, -1.2, -2.1, -2.2, -1.3, -2.3, -1.4, -2.4, 1.1, 1.2, 2.1, 2.2, 1.3, 2.3, 1.4, 2.4, -3.0, 3.0, 4.0, 5.0)
protos <- c('s-levens-topo-HCT116-1', 's-levens-topo-mutant-1')
curves <- lapply(protos, function(p) {
proto <- query.protocol(con, p, 'activity')
proto <- data.frame(proto, prefix=I(base.id(proto$SID)), sdt=I("activity"), protocol=I(p))
proto <- dedup.curves(proto)
return(proto)
})
curves <- do.call(rbind,curves)
sids <- read.table(textConnection('NCGC00250412-01
NCGC00344588-01'), header=FALSE, as.is=TRUE)
cols <- brewer.pal(2, 'Set1')
junk <- apply(sids, 1, function(row) {
sid <- row[1]
dat <- subset(curves, base.id(SID) == base.id(sid))
dat <- dat[order(dat$protocol),]
if (nrow(dat) == 0) {
cat("No data for",sid, '\n')
return(NA)
}
dat <- data.frame(dat, pch=c(15,16), col=c('black', 'red'))
print(dat[, c('protocol', 'col')])
names(dat)[1] <- 'sdid'
par(mar=c(4.2, 4.2, 1,1), cex=1.2, cex.axis=0.8, cex.lab=1.1, tcl=-0.5 * 1)
if (is.na(dat$sdid[1])) {
cat("***", sid, '\n')
return(NA)
} else {
junk <- plot.hill2(con, dat, force=TRUE, lwd=2,
xlab='log Concentration (M)', ylab='% Response', ylim=c(0, 130),
las = 1
)
sname <- subset(sample.info, base.id(SAMPLE_ID) == base.id(sid))$SAMPLE_NAME[1]
dev.copy(pdf, sprintf("topo-%s-%s.pdf", sid, sname), 6, 6/1.618);dev.off()
##return(with(dat, TAUC[1] - TAUC[2]))
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment