diff --git a/bin/cnv_facets.R b/bin/cnv_facets.R index 69c3bfe..c4141a0 100755 --- a/bin/cnv_facets.R +++ b/bin/cnv_facets.R @@ -31,7 +31,7 @@ suppressMessages(library(gridExtra)) # ----------------------------------------------------------------------------- -VERSION= sprintf('0.15.0; facets=%s', packageVersion('facets')) +VERSION= sprintf('0.16.0; facets=%s', packageVersion('facets')) docstring<- sprintf('DESCRIPTION \\n\\ Detect somatic copy number variants (CNVs) and estimate purity and ploidy in a\\n\\ @@ -131,6 +131,10 @@ parser$add_argument('--unmatched', '-u', help= 'Normal sample is unmatched. If set, heterozygote SNPs are\\n\\ called using tumor reads only and logOR calculations are different', action= 'store_true') +parser$add_argument('--no-cov-plot', '-np', help= +'Do not produce coverage plots (they can be memory intensive).\\n\\ +Other plots remain unaffected', action= 'store_true') + def_rnd<- 'The name of the input file' parser$add_argument('--rnd-seed', '-s', help= sprintf( 'Seed for random number generator. Default: %s', def_rnd), type= 'character', default= def_rnd) @@ -812,11 +816,13 @@ if(sys.nframe() == 0){ } rcmat_flt<- filter_rcmat(rcmat= rcmat[['pileup']], min_ndepth= xargs$depth[1], max_ndepth= xargs$depth[2], target_bed= targets) - - write(sprintf('[%s] Plotting histogram of coverage...', Sys.time()), stderr()) - plot_coverage(rcmat= rcmat[['pileup']], rcmat_flt= rcmat_flt, - fname= paste0(xargs$out, '.cov.pdf'), title= paste0('Depth of coverage\n', xargs$out)) - + + if(xargs$no_cov_plot == FALSE){ + write(sprintf('[%s] Plotting histogram of coverage...', Sys.time()), stderr()) + plot_coverage(rcmat= rcmat[['pileup']], rcmat_flt= rcmat_flt, + fname= paste0(xargs$out, '.cov.pdf'), title= paste0('Depth of coverage\n', xargs$out)) + } + rcmat[['pileup']]<- NULL x_ <- gc(verbose= FALSE) @@ -887,7 +893,7 @@ if(sys.nframe() == 0){ par(las= 1, mar= c(3, 3, 1, 1), mgp= c(1.5, 0.5, 0), tcl= -0.3) logRlogORspider(facets$proc_out$out, facets$proc_out$dipLogR) x_ <- dev.off() - + si<- capture.output(sessionInfo()) write(si, stderr()) } diff --git a/test/test_cnv_facets.py b/test/test_cnv_facets.py index d58e6d0..3172925 100755 --- a/test/test_cnv_facets.py +++ b/test/test_cnv_facets.py @@ -84,6 +84,15 @@ def testBamInput(self): self.assertTrue(os.path.exists('test_out/out.csv.gz')) self.assertEqual('', vcf_validator('test_out/out.vcf.gz')) + def testDoNotPlot(self): + p = sp.Popen("""../bin/cnv_facets.R --no-cov-plot -t data/TCRBOA6-T-WEX.sample.bam -n data/TCRBOA6-N-WEX.sample.bam -vcf data/common.sample.vcf.gz -o test_out/out""", shell=True, stdout= sp.PIPE, stderr= sp.PIPE) + stdout, stderr = p.communicate() + self.assertEqual(0, p.returncode) + self.assertTrue(os.path.exists('test_out/out.vcf.gz')) + self.assertTrue(os.path.exists('test_out/out.cnv.png')) + self.assertTrue(os.path.exists('test_out/out.spider.pdf')) + self.assertTrue(not os.path.exists('test_out/out.cov.pdf')) + def testBamInputNotProperlyPaired(self): # Prepare a bam files with 'properly paired' flag removed p = sp.Popen(r"""