Skip to content

Instantly share code, notes, and snippets.

@sonali-bioc
Created February 4, 2014 00:31
Show Gist options
  • Save sonali-bioc/8795338 to your computer and use it in GitHub Desktop.
Save sonali-bioc/8795338 to your computer and use it in GitHub Desktop.
use pshannon-bioc / binnedCounts.R and plot the counts for Tumor and Normal Sample Data
plotbinnedCounts <- function(filename, tumor, normal, ylim )
{
y1 <- tumor
y2 <- normal
png(file= filename, bg="white")
plot( y1,
col="red",
xlab= "bins",
ylab =" reads",
ylim =ylim )
lines( y2,
col="darkgreen")
legend("topright",
col=c("red","darkgreen"),
legend = c("Tumor", "Normal"),
text.width = strwidth("1,000,000"),
lty = 1:2, xjust = 1, yjust = 1,
title = "Sample Types")
dev.off()
}
source("binnedCounts.R")
binSize =10000
tumor.bins <- binnedCounts("tumorA.chr4.bam", "chr4", binSize=binSize)
normal.bins <- binnedCounts("normalA.chr4.bam", "chr4", binSize=binSize)
#raw
y1 <- tumor.bins$count
y2 <- normal.bins$count
plotbinnedCounts("count.png", y1, y2,ylim=c(0,max(y1,y2)))
#normalised
normNormal <- normal.bins$count /10000
normTumor <- tumor.bins$count /10000
y1 <- normTumor
y2 <- normNormal
plotbinnedCounts("normalized-count.png", y1, y2,ylim=c(0,2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment