This is a test version of Biostars. For the public version, visit https://www.biostars.org.
DNAcopy plot error

I am running DNAcopy package for copy number analysis on whole genome sequencing data. I successfully plotted chromosome and map position but when i was trying to plot by chromosome , I am continuously getting an error. Following is my code and error.

> setwd("C:/Users/User/Desktop/DNAcopy")

> library(DNAcopy)

> P1 = read.table ("R025.output.copynumber.called", header=TRUE)

> CNA.object <- CNA( genomdat = P1[,7], chrom = P1[,1], maploc = P1 [,2], data.type = 'logratio',sampleid="R025")

> CNA.object.smoothed     <- smooth.CNA(CNA.object)

> CNA.object.smoothed.seg <- segment(CNA.object.smoothed, verbose=0, min.width=2)

> seg.pvalue <- segments.p(CNA.object.smoothed.seg, ngrid=100, tol=1e-6, alpha=0.05, search.range=100, nperm=1000)

> write.table (seg.pvalue,file="R025_DNAcopy.pvalue", row.names=F, col.names=T, quote=F, sep="\t")

> jpeg("R025.jpeg")

> plot(CNA.object.smoothed.seg, plot.type="w")

> dev.off()

null device 
          1 

> plot(CNA.object.smoothed.seg, plot.type="s")

Setting multi-figure configuration

Error in plot.new() : figure margins too large
r sequencing cnv analysis next-gen

Please use the formatting bar (especially the code option) to present your post better. I've done it for you this time.
code_formatting

Thanks!

1 answer

"1) "Error in plot.new() : figure margins too large"

This error indicates that the margins of the particular plot are very large while the region allocated for the plot is too small. You can solve this problem by increasing the size of the plots pane. " - via https://support.rstudio.com/hc/en-us/articles/200488548-Problem-with-Plots-or-Graphics-Device

Also, try not to save your figures as JPG, PNG, BMP, or any other pixel format. These are difficult to manipulate later and can look grainy and horrendous when zoomed in. Use vector-based image formats, like PDF and SVG.

In your code above, I would do:

pdf('image1.pdf', width = 12, height = 12)
  plot(CNA.object.smoothed.seg, plot.type="w")
dev.off()

pdf('image1.pdf', width = 12, height = 12)
  plot(CNA.object.smoothed.seg, plot.type="s")
dev.off()

Thank you for your suggestion. It worked for me.

Log in to answer this question.