Error in plot.new() : figure margins too large
3
0
Entering edit mode
mictadlo ▴ 10
@mictadlo-10885
Last seen 4.2 years ago

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?

Thank you in advance.

edger • 4.5k views
ADD COMMENT
2
Entering edit mode
@gordon-smyth
Last seen 3 hours ago
WEHI, Melbourne, Australia

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)
ADD COMMENT
2
Entering edit mode
@james-w-macdonald-5106
Last seen 9 minutes ago
United States

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.

ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode
@peter-langfelder-4469
Last seen 2 days ago
United States

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.

ADD COMMENT

Login before adding your answer.

Traffic: 837 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