Script to save plots in Pdf format ( DNAcopy)
2
0
Entering edit mode
nac ▴ 280
@nac-4545
Last seen 9.6 years ago
dear All, I am using the DNA copy package to get my CGH files (Agilent 244K arrays) analysed. I am using this command to plot them one by one : >plot(CNA.object, plot.type="w") This is a very slow and time consuming process and I have ~60 files to plot . I am quite novice in R and was wondering whether anybody could advise on a simple script to get all files plotted and the plots saved into a single pdf file ( or nay other format)? Many thanks in advance for any advice, Nathalie -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE.
CGH PROcess CGH PROcess • 2.4k views
ADD COMMENT
0
Entering edit mode
@thomas-hampton-2820
Last seen 9.6 years ago
Here is an example of making 3 pdf plots. It consists of a loop, marked off with curly brackets, executed for the variable i, which ranges from 1 to 3. The file names are 1.pdf, 2.pdf, and 3.pdf, generated using the R paste function. The data are two sets of 10 random numbers, generated by rnorm. The pdf function creates the output, but in order for it to write out the final result, you need to call the dev.off function. for(i in 1:3){ pdf(file=paste(i,"pdf", sep='.')) plot(rnorm(10), rnorm(10)) dev.off() } Best, Tom On Apr 6, 2011, at 6:45 AM, Nathalie Conte wrote: > dear All, > I am using the DNA copy package to get my CGH files (Agilent 244K > arrays) analysed. > I am using this command to plot them one by one : > >plot(CNA.object, plot.type="w") > This is a very slow and time consuming process and I have ~60 files > to plot . I am quite novice in R and was wondering whether anybody > could advise on a simple script to get all files plotted and the > plots saved into a single pdf file ( or nay other format)? > Many thanks in advance for any advice, > > Nathalie > > > -- > The Wellcome Trust Sanger Institute is operated by Genome Research > Limited, a charity registered in England with number 1021457 and a > company registered in England with number 2742969, whose registered > office is 215 Euston Road, London, NW1 2BE. > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
ADD COMMENT
0
Entering edit mode
pdf() supports multiple pages so if you do pdf(file = "tmp.pdf") plot() plot() plot() dev.off() you'll get one pdf file with three pages. Not all devices (example: png()) support multiple pages. Essentially, move the loop inside the pdf() call in the two previous emails. Kasper On Wed, Apr 6, 2011 at 9:25 AM, Thomas Hampton <thomas.h.hampton at="" dartmouth.edu=""> wrote: > Here is an example of making 3 pdf ?plots. > > It consists of a loop, marked off with curly brackets, executed for the > variable i, > which ranges from 1 to 3. The file names are 1.pdf, 2.pdf, and 3.pdf, > generated using the ?R paste function. > > The data are two sets of 10 random numbers, generated by rnorm. > > The pdf function creates the output, but in order for it to write out the > final result, you need to call the dev.off function. > > for(i in 1:3){ > ? ? ? ?pdf(file=paste(i,"pdf", sep='.')) > ? ? ? ?plot(rnorm(10), rnorm(10)) > ? ? ? ?dev.off() > } > > > Best, > > Tom > On Apr 6, 2011, at 6:45 AM, Nathalie Conte wrote: > >> dear All, >> I am ?using the DNA copy package to get my CGH files (Agilent 244K arrays) >> analysed. >> I am using this command to plot them one by one : >> >plot(CNA.object, plot.type="w") >> This is a very slow and time consuming process and I have ~60 files to >> plot . I am quite novice in R and was wondering whether anybody could advise >> on a simple script to get all files ?plotted and the plots saved into a >> single pdf file ( or nay other format)? >> Many thanks in advance for any advice, >> >> Nathalie >> >> >> -- >> The Wellcome Trust Sanger Institute is operated by Genome Research >> Limited, a charity registered in England with number 1021457 and a company >> registered in England with number 2742969, whose registered office is 215 >> Euston Road, London, NW1 2BE. >> >> _______________________________________________ >> Bioconductor mailing list >> Bioconductor at r-project.org >> https://stat.ethz.ch/mailman/listinfo/bioconductor >> Search the archives: >> http://news.gmane.org/gmane.science.biology.informatics.conductor > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor >
ADD REPLY
0
Entering edit mode
@rene-dreos-3880
Last seen 9.6 years ago
Hi Nathalie, if I understand correctly, you have 60 DNAcopy object you need to plot. The following code will do the trick: The first step is to create a vector with the name of the 60 objects: object.list <- c("DNAcopy1", "DNAcopy2"..."DNAcopy60") than do a loop to plot them as pdf file: for (I in object.list) { pdf(file=paste(I, ".pdf", sep=""), height=10, width=10) plot(I, plot.type="w") dev.off() } you can modify the height and width in the pdf function to increase or reduce the plot dimensions best r On 6 April 2011 12:45, Nathalie Conte <nac@sanger.ac.uk> wrote: > dear All, > I am using the DNA copy package to get my CGH files (Agilent 244K arrays) > analysed. > I am using this command to plot them one by one : > >plot(CNA.object, plot.type="w") > This is a very slow and time consuming process and I have ~60 files to plot > . I am quite novice in R and was wondering whether anybody could advise on a > simple script to get all files plotted and the plots saved into a single > pdf file ( or nay other format)? > Many thanks in advance for any advice, > > Nathalie > > > -- > The Wellcome Trust Sanger Institute is operated by Genome Research Limited, > a charity registered in England with number 1021457 and a company registered > in England with number 2742969, whose registered offic...{{dropped:19}}
ADD COMMENT

Login before adding your answer.

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