Mercurial > repos > stef > qdnaseq_test
diff QDNAseq-plot.R @ 27:f89205f51e27 draft default tip
Uploaded
author | stef |
---|---|
date | Mon, 06 Jul 2015 05:41:08 -0400 |
parents | 4943308e95fc |
children |
line wrap: on
line diff
--- a/QDNAseq-plot.R Mon Jul 06 05:38:44 2015 -0400 +++ b/QDNAseq-plot.R Mon Jul 06 05:41:08 2015 -0400 @@ -37,13 +37,42 @@ catMsg( c( rVersion ) ) qdnaseqObject <- readRDS( rdsFilePath ) +chromosomesToPlot <- unlist( strsplit( chromosomesToPlotString, ",") ) + +#cat( "CHROM: ", chromosomesToPlotString, "\n" ) +#cat( "REGION: ", regionToPlotString, "\n" ) +#cat( "What to plot: ", whatToPlot, "\n" ) + ## COPYNUMBER PLOT sample <- SAMPLE_INDEX png( outputPngPath, width=PLOT_WIDTH, height=PLOT_HEIGHT, res=PLOT_RES ) par( PAR_SET ) - plot( qdnaseqObject[ ,sample ] ) + ylab_text <- "log2 read counts" + if ( whatToPlot == 'everything' ){ + catMsg( c( "Plotting all data in object" ) ) + plot( qdnaseqObject[ ,sample ], ylab=ylab_text ) + abline( h=c(-4,-3,-2,-1,1,2,3,4), lty=1, lwd=0.5, col="grey" ) + } else if( whatToPlot == 'chromosomes' ){ + catMsg( c( "Plotting subset of chromosomes" ) ) + fdata <- qdnaseqObject@featureData@data + idx_region <- which( fdata$chromosome %in% chromosomesToPlot ) + plot( qdnaseqObject[ idx_region, sample ], ylab=ylab_text ) + abline( h=c(-4,-3,-2,-1,1,2,3,4), lty=1, lwd=0.5, col="grey" ) + } else if( whatToPlot == 'region' ){ + regionC <- chrName + regionS <- chrStart + regionE <- chrEnd + if ( regionS > regionE ) stop("Chosen start is > end") + catMsg( c( "Plotting genomic region (chr=", regionC, " start=", regionS, " end=", regionE, ")" ) ) + + fdata <- qdnaseqObject@featureData@data + idx_region <- which( fdata$chromosome == regionC & fdata$start > regionS & fdata$end < regionE ) + cat( idx_region, "\n") + + plot( qdnaseqObject[ idx_region, sample ], doCalls=FALSE, ylab=ylab_text ) + } #mtext( "plotted in galaxy", 3 ) - abline( h=c(-2,-1,1,2,3,4), lty=1, lwd=0.5, col="grey" ) + dev.off()