comparison QDNAseq-plot.R @ 87:8391cdb7479c draft

Uploaded
author stef
date Thu, 28 May 2015 14:19:57 -0400
parents 5eec30e0fcce
children d2ea2b842c21
comparison
equal deleted inserted replaced
86:9802eea2eeb8 87:8391cdb7479c
45 45
46 ## COPYNUMBER PLOT 46 ## COPYNUMBER PLOT
47 sample <- SAMPLE_INDEX 47 sample <- SAMPLE_INDEX
48 png( outputPngPath, width=PLOT_WIDTH, height=PLOT_HEIGHT, res=PLOT_RES ) 48 png( outputPngPath, width=PLOT_WIDTH, height=PLOT_HEIGHT, res=PLOT_RES )
49 par( PAR_SET ) 49 par( PAR_SET )
50 ylab_text <- "log2 read counts"
50 if ( whatToPlot == 'everything' ){ 51 if ( whatToPlot == 'everything' ){
51 catMsg( c( "Plotting all data in object" ) ) 52 catMsg( c( "Plotting all data in object" ) )
52 plot( qdnaseqObject[ ,sample ] ) 53 plot( qdnaseqObject[ ,sample ], ylab=ylab_text )
54 abline( h=c(-2,-1,1,2,3,4), lty=1, lwd=0.5, col="grey" )
53 } else if( whatToPlot == 'chromosomes' ){ 55 } else if( whatToPlot == 'chromosomes' ){
54 catMsg( c( "Plotting subset of chromosomes" ) ) 56 catMsg( c( "Plotting subset of chromosomes" ) )
55 fdata <- qdnaseqObject@featureData@data 57 fdata <- qdnaseqObject@featureData@data
56 idx_region <- which( fdata$chromosome %in% chromosomesToPlot ) 58 idx_region <- which( fdata$chromosome %in% chromosomesToPlot )
57 plot( qdnaseqObject[ idx_region, sample ] ) 59 plot( qdnaseqObject[ idx_region, sample ], ylab=ylab_text )
60 abline( h=c(-2,-1,1,2,3,4), lty=1, lwd=0.5, col="grey" )
58 } else if( whatToPlot == 'region' ){ 61 } else if( whatToPlot == 'region' ){
59 regionC <- chrName 62 regionC <- chrName
60 regionS <- chrStart 63 regionS <- chrStart
61 regionE <- chrEnd 64 regionE <- chrEnd
62 if ( regionS > regionE ) stop("Chosen start is > end") 65 if ( regionS > regionE ) stop("Chosen start is > end")
63 catMsg( c( "Plotting genomic region (chr=", regionC, " start=", regionS, " end=", regionE, ")" ) ) 66 catMsg( c( "Plotting genomic region (chr=", regionC, " start=", regionS, " end=", regionE, ")" ) )
64 67
65 fdata <- qdnaseqObject@featureData@data 68 fdata <- qdnaseqObject@featureData@data
66 idx_region <- which( fdata$chromosome == regionC & fdata$start > regionS & fdata$end < regionE ) 69 idx_region <- which( fdata$chromosome == regionC & fdata$start > regionS & fdata$end < regionE )
70 cat( idx_region, "\n")
67 71
68 plot( qdnaseqObject[ idx_region, sample ], doCalls=FALSE ) 72 plot( qdnaseqObject[ idx_region, sample ], doCalls=FALSE, ylab=ylab_text )
69 } 73 }
70 #mtext( "plotted in galaxy", 3 ) 74 #mtext( "plotted in galaxy", 3 )
71 abline( h=c(-2,-1,1,2,3,4), lty=1, lwd=0.5, col="grey" ) 75
72 dev.off() 76 dev.off()
73 77
74 78
75 ## all ok 79 ## all ok
76 q(status=0) 80 q(status=0)