Save multiple plots into single pdf from Deseq2 analysis?
1
0
Entering edit mode
Bio_Ram • 0
@bio_ram-12851
Last seen 6.2 years ago

I am doing Deseq2 analysis and would like to save all the plots in a single pdf file. For that i have written a function and try to use the function to save plots one after the other in a single pdf file. Here is the sample code and so far i was not succesful

pdf="Results_Deseq2.pdf"
if (!(is.null(pdf))){
  pdf(pdf,paper="a4r")
}
window=function(x){
  if(is.null(pdf)){
windows()
    } else {
    par(mfrow=c(1,1))
  }

##### Analysis##########

window()

DESeq2::plotMA(dds)

dev.off()

rld <- rlog(dds, blind=FALSE) # rlog
vsd <- varianceStabilizingTransformation(dds, blind=FALSE) 
notAllZero <- (rowSums(counts(dds))>0)
par(mfrow=c(2,2))

window()
meanSdPlot(log2(counts(dds,normalized=TRUE) + 1)) ## log transformation log2(n+1) counts 
meanSdPlot(assay(rld[notAllZero,])) ##rlog transformation
meanSdPlot(assay(vsd[notAllZero,])) ##variance stabilizing transformation
distro_expr(rld,plot_type = "boxplot")
dev.off()

 

plot pdf dev.off • 1.7k views
ADD COMMENT
0
Entering edit mode
@wolfgang-huber-3550
Last seen 12 weeks ago
EMBL European Molecular Biology Laborat…

You say "i was not succesful" but not really what you consider your problem is...

However, I'd recommend taking a much better approach, namely use Rmarkdown (or knitr) to prepare your analysis script, and use PDF as the output format.

 

ADD COMMENT

Login before adding your answer.

Traffic: 553 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6