From 5adfd54f3e4642a361832ca287b6e4a608d60c4a Mon Sep 17 00:00:00 2001 From: Ryan Collins Date: Fri, 27 May 2022 16:32:51 -0400 Subject: [PATCH] Raster art updates --- .../large_segments/plot_dnm_comparisons.R | 7 +++-- .../plot/large_segments/plot_example_miami.R | 8 ++++++ .../plot_sliding_window_pval_distribs.R | 28 ++++++++++++++----- docker/rcnv-base/Dockerfile | 2 +- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/analysis/paper/plot/large_segments/plot_dnm_comparisons.R b/analysis/paper/plot/large_segments/plot_dnm_comparisons.R index 26dbd68..5a8a02d 100755 --- a/analysis/paper/plot/large_segments/plot_dnm_comparisons.R +++ b/analysis/paper/plot/large_segments/plot_dnm_comparisons.R @@ -663,6 +663,7 @@ sapply(names(dnms), function(cohort){ # Collapsed distribution of excess DNMs across all NDD segments pct.cutoff <- 0 +width.buffer <- 0 sapply(names(dnms), function(cohort){ if(cohort == "DDD_plus_ASC"){ min.excess.for.norm <- 1.9 @@ -670,9 +671,11 @@ sapply(names(dnms), function(cohort){ }else if(cohort == "DDD"){ min.excess.for.norm <- 0.9 min.excess.ineq <- ">=" + width.buffer <- 0.3 }else{ min.excess.for.norm <- 0.1 min.excess.ineq <- ">" + width.buffer <- 0.3 } sapply(csqs, function(csq){ cnv.marker.wex <- 0 @@ -701,7 +704,7 @@ sapply(names(dnms), function(cohort){ round(min.excess.for.norm, 0), ")'", sep="") } pdf(paste(out.prefix, cohort, csq, "excess_dnm_distrib_bygene.pdf", sep="."), - height=2, width=2.75) + height=2, width=2.75+width.buffer) dnm.excess.cdf.barplots(ndd.segs[which(ndd.segs$cnv %in% cnv.types), ], dnms[[cohort]], cohort=cohort, csq=csq, norm=F, legend=T, pct.cutoff=pct.cutoff, @@ -710,7 +713,7 @@ sapply(names(dnms), function(cohort){ dev.off() cat(paste(cohort, csq, "\n")) pdf(paste(out.prefix, cohort, csq, "excess_dnm_distrib_bygene.norm.pdf", sep="."), - height=2, width=2.5) + height=2, width=2.5+width.buffer) dnm.excess.cdf.barplots(ndd.segs[which(ndd.segs$cnv %in% cnv.types), ], dnms[[cohort]], cohort=cohort, csq=csq, min.excess=min.excess.for.norm, norm=T, legend=F, diff --git a/analysis/paper/plot/large_segments/plot_example_miami.R b/analysis/paper/plot/large_segments/plot_example_miami.R index 6f75a6a..b040b16 100755 --- a/analysis/paper/plot/large_segments/plot_example_miami.R +++ b/analysis/paper/plot/large_segments/plot_example_miami.R @@ -178,6 +178,7 @@ mini.miami <- function(del, dup, max.p=10, ### RSCRIPT BLOCK ### ##################### require(rCNV2, quietly=T) +require(rasterpdf, quietly=T) require(optparse, quietly=T) # List of command-line options @@ -231,4 +232,11 @@ png(out.png, height=dim.scalar*1.4*300, width=dim.scalar*1.95*300, res=300, fami mini.miami(del, dup, del.cutoff=del.cutoff, dup.cutoff=dup.cutoff, cutoff.label=cutoff.label, middle.axis.width=1.25, xaxis.label=xaxis.label, sig.col=graphabs.green, max.p=8) dev.off() +out.pdf <- gsub(".png$", ".pdf", out.png) +raster_pdf(out.pdf, height=dim.scalar*1.4, width=dim.scalar*1.95, units="in", res=600) +# pdf(out.pdf, height=dim.scalar*1.4, width=dim.scalar*1.95) +mini.miami(del, dup, del.cutoff=del.cutoff, dup.cutoff=dup.cutoff, cutoff.label=cutoff.label, + middle.axis.width=1.25, xaxis.label=xaxis.label, sig.col=graphabs.green, max.p=8) +dev.off() + diff --git a/analysis/paper/plot/large_segments/plot_sliding_window_pval_distribs.R b/analysis/paper/plot/large_segments/plot_sliding_window_pval_distribs.R index 71fd52c..485224e 100755 --- a/analysis/paper/plot/large_segments/plot_sliding_window_pval_distribs.R +++ b/analysis/paper/plot/large_segments/plot_sliding_window_pval_distribs.R @@ -319,6 +319,7 @@ primary.vs.secondary.scatter <- function(pvals.1, pvals.2, keep.idx=NULL, ### RSCRIPT BLOCK ### ##################### require(rCNV2, quietly=T) +require(rasterpdf, quietly=T) require(optparse, quietly=T) # List of command-line options @@ -404,9 +405,14 @@ cat(paste("Median lambda, deletions & duplications only:", round(median(c(del.1$ n.plots.wide <- 9 n.plots.tall <- ceiling(length(hpos) / n.plots.wide) dim.scalar <- 7.5 / 10 -png(paste(out.prefix, "qq_grid_byHPO.png", sep="."), - height=dim.scalar*300*n.plots.tall, width=dim.scalar*300*n.plots.wide, - res=300) +# png(paste(out.prefix, "qq_grid_byHPO.png", sep="."), +# height=dim.scalar*300*n.plots.tall, width=dim.scalar*300*n.plots.wide, +# res=300) +raster_pdf(paste(out.prefix, "qq_grid_byHPO.pdf", sep="."), + height=dim.scalar*n.plots.tall, width=dim.scalar*n.plots.wide, + units="in", res=600) +# pdf(paste(out.prefix, "qq_grid_byHPO.pdf", sep="."), +# height=dim.scalar*n.plots.tall, width=dim.scalar*n.plots.wide) par(mfrow=c(n.plots.tall, n.plots.wide)) for(hpo in hpos){ mini.qq(del.1, dup.1, hpo, title.cex=0.42, axis.cex=0.7, blue.bg=FALSE) @@ -426,14 +432,22 @@ lambda.scatter(del.1, dup.1, hpo.n, blue.bg=FALSE) dev.off() # Scatterplots of primary vs. secondary P-values -png(paste(out.prefix, "primary_vs_secondary_pvalue.DEL.png", sep="."), - height=prim.vs.sec.png.dim*300, width=prim.vs.sec.png.dim*300, res=300) +# png(paste(out.prefix, "primary_vs_secondary_pvalue.DEL.png", sep="."), +# height=prim.vs.sec.png.dim*300, width=prim.vs.sec.png.dim*300, res=300) +raster_pdf(paste(out.prefix, "primary_vs_secondary_pvalue.DEL.pdf", sep="."), + height=prim.vs.sec.png.dim, width=prim.vs.sec.png.dim, units="in", res=600) +# pdf(paste(out.prefix, "primary_vs_secondary_pvalue.DEL.pdf", sep="."), +# height=prim.vs.sec.png.dim, width=prim.vs.sec.png.dim) primary.vs.secondary.scatter(del.1$pvals, del.2$pvals, cutoff.1=del.cutoff, sig.color=cnv.colors[1], nonsig.color=control.cnv.colors[1], pt.cex=0.175, blue.bg=FALSE, parmar=c(2.5, 2.5, 0.15, 0.15)) dev.off() -png(paste(out.prefix, "primary_vs_secondary_pvalue.DUP.png", sep="."), - height=prim.vs.sec.png.dim*300, width=prim.vs.sec.png.dim*300, res=300) +# png(paste(out.prefix, "primary_vs_secondary_pvalue.DUP.png", sep="."), +# height=prim.vs.sec.png.dim*300, width=prim.vs.sec.png.dim*300, res=300) +raster_pdf(paste(out.prefix, "primary_vs_secondary_pvalue.DUP.pdf", sep="."), + height=prim.vs.sec.png.dim, width=prim.vs.sec.png.dim, units="in", res=600) +# pdf(paste(out.prefix, "primary_vs_secondary_pvalue.DUP.pdf", sep="."), +# height=prim.vs.sec.png.dim, width=prim.vs.sec.png.dim) primary.vs.secondary.scatter(dup.1$pvals, dup.2$pvals, cutoff.1=dup.cutoff, sig.color=cnv.colors[2], nonsig.color=control.cnv.colors[2], pt.cex=0.175, blue.bg=FALSE, parmar=c(2.5, 2.5, 0.15, 0.15)) diff --git a/docker/rcnv-base/Dockerfile b/docker/rcnv-base/Dockerfile index 0b41676..120a34e 100644 --- a/docker/rcnv-base/Dockerfile +++ b/docker/rcnv-base/Dockerfile @@ -88,7 +88,7 @@ RUN apt-get -qqy clean && \ # (Note that beeswarm _is_ available through conda but we need >=v0.4, and there # is a very complex dependency issue in conda that makes it easier to install # directly with R here) -RUN Rscript -e "sapply(c('EQL', 'beeswarm'),\ +RUN Rscript -e "sapply(c('EQL', 'beeswarm', 'rasterpdf'),\ function(pkg){install.packages(pkg,repos='https://cloud.r-project.org')})" ARG rCNV2_Rpkg_source="/opt/rCNV2/source/rCNV2_0.1.0.tar.gz" RUN Rscript -e "install.packages('$rCNV2_Rpkg_source', source=TRUE, repos=NULL)"