Search
Question: Error in plot.new() : figure margins too large
0
7 months ago by

Hi, I got Error in plot.new() : figure margins too large with the below code:

> logCPM <- cpm(y, prior.count=2, log=TRUE)
> head(y$genes) gene_name gene_description 3 sp0000003 <NA> 4 sp0000004 <NA> 5 sp0000005 PUA domain 6 sp0000006 Sugar efflux transporter for intercellular exchange 8 sp0000008 <NA> 12 sp0000012 Ankyrin repeats (many copies) > y$samples$group [1] Root_tip.1.5 Root_tip.1.5 Root_tip.1.5 Root_tip.1.5 Leaves.1.5 Leaves.1.5 [7] Leaves.1.5 Leaves.1.5 Root_tip.2 Root_tip.2 Root_tip.2 Root_tip.2 [13] Leaves.2 Leaves.2 Leaves.2 Leaves.2 Root_tip.3 Root_tip.3 [19] Root_tip.3 Root_tip.3 Leaves.3 Leaves.3 Leaves.3 Leaves.3 Levels: Leaves.1.5 Leaves.2 Leaves.3 Root_tip.1.5 Root_tip.2 Root_tip.3 > rownames(logCPM) <- y$genes$genes > colnames(logCPM) <- paste(y$samples$group, 1:2, sep="-") > o <- order(tr$table\$PValue)
> logCPM <- logCPM[o[1:30],]
> logCPM <- t(scale(t(logCPM)))
> library(gplots)

Attaching package: ‘gplots’

The following object is masked from ‘package:stats’:

lowess

> col.pan <- colorpanel(100, "blue", "white", "red")
> heatmap.2(logCPM, col=col.pan, Rowv=TRUE, scale="none",
+           trace="none", dendrogram="both", cexRow=1, cexCol=1.4, density.info="none",
+           margin=c(10,9), lhei=c(2,10), lwid=c(2,6))
Error in plot.new() : figure margins too large


What did I miss?

modified 7 months ago by Gordon Smyth33k • written 7 months ago by mictadlo0
2
7 months ago by
Gordon Smyth33k
Walter and Eliza Hall Institute of Medical Research, Melbourne, Australia
Gordon Smyth33k wrote:

I can see that you are copying code verbatim from the edgeR case study workflow published on F1000Research: https://f1000research.com/articles/5-1438 . It would be a good idea to say this in your question so that people know what the question is about.

The obvious problem is that the case study in F1000Research had only 6 samples whereas your data has 23 samples. So obviously your heatmap will be wider than the one in the published workflow. So you won't be able to leave as much space for margins.

The code in the workflow wasn't intended to be copied verbatim into new analyses. It is just as example of how R and Bioconductor can be used. For normal routine use of heatmap.2 you don't need to set the detailed graphical parameters such as margin, lhei or lwid. You can just omit them.

Can I suggest that you try:

logCPM <- cpm(y, log=TRUE, prior.count=3)
logCPM <- logCPM[o[1:30],]
coolmap(logCPM)
2
7 months ago by
United States
James W. MacDonald46k wrote:

Two things. First, this question has nothing to do with edgeR, nor ggplot2, so you shouldn't be tagging with those tags. The tags actually have a purpose, as some maintainers just follow certain tags for their own packages, and you stand a chance of them missing your post if you just use random tags.

Second, while you might be using edgeR for your analysis, the question you have is about heatmap.2, which is a CRAN package, not Bioconductor. If you want to ask questions about CRAN packages (and about using R in general), you should A.) try to figure it out yourself by googling the error, etc, and then B.) posting to R-help (r-help@r-project.org). But do note that people on R-help can be less forgiving of those who seem not to have tried to figure things out themselves first, so do A first.

If you want to generate heatmaps using a Bioconductor package, you might look at ComplexHeatmap, which is a bit nicer IMO than heatmap.2, which is pretty old school.

Thank you for pointing out that it is a CRAN package.

0
7 months ago by
United States
Peter Langfelder1.4k wrote:

To the OP's question, the error usually means the plotting window, or the current plot area of  a plot window, is too small to accommodate the requested plot margins. The fix may be as easy as enlarging the plot window but you may have to modify the  the margins and lhei, lwid arguments. See ?heatmap.2 for details.