dev.off() might help you out to show your plots again

no plot in the pane

Are you looking for a solution for this issue?: suddenly Rstudio's plot pane stop showing any plots.

"dev.off()" might help you out!

I've been stuck with this issue till few hours ago, and I thought that was my computer's problem; he/she might not be able to handle this script (namely, "arrayQualityMetrics()" in R) without restarting my R session.

But that wasn't true!

The solution was to add the "dev.off()" at the end of the script if I changed the output directory to other than the current working directory. Might be so basic to Data Scientists... 🙄

When I tried this, my problem was gone, made me super happy.

dev.off() in R

Cannot guarantee if this solve your issue as well, but worth trying.

What I did

Just in case, I wrote my code below to make this clearer. If you're interested, please keep reading.

I was working on a workflow for differential gene expression using Affymetrix microarrays.

Reference: Klaus B and Reisenauer S. An end to end workflow for differential gene expression using Affymetrix microarrays [version 2; peer review: 2 approved]. F1000Research 2018, 5:1384 (https://doi.org/10.12688/f1000research.8967.2)

In this workflow, they introduce arrayQualityMetrics() as one of the elaborate quality control packages. Though they aren't discussing this further, I wanted to try this one as a part of this workflow, then stuck there for hours...

# The plot pane stopped showing plots after this script.
arrayQualityMetrics(expressionset = raw_data,
                    outdir = tempdir(),
                    force = TRUE, do.logtransform = TRUE,
                    intgroup = c("Factor.Value.disease.", "Factor.Value.phenotype."))

I was able to get out of there after adding "dev.off()" as shown below.

arrayQualityMetrics(expressionset = raw_data,
                    outdir = tempdir(),
                    force = TRUE, do.logtransform = TRUE,
                    intgroup = c("Factor.Value.disease.", "Factor.Value.phenotype."))

dev.off() 
# Thank you dev.off()...

What I learned

I didn't know that dev.off() was that important and powerful command. From now on, I won't be in the same situation anymore. (hopefully)

And also, when I browsed the vignette of arrayQualityMetrics(), I came to know that "outdir = " would automatically create a new directory in my current working directory. So I changed there from " outdir = 'tempdir()' " to " outdir = 'QCreport' " thereafter.

Anyway, I'm so relieved to know that I don't have to restart my R session whenever I want to have these informative quality control reports.

Hope this memo also help you!

\ Share /

Leave a Comment

CAPTCHA