Question: Script to save plots in Pdf format ( DNAcopy)
0
gravatar for nac
8.3 years ago by
nac280
nac280 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.
cgh process • 1.4k views
ADD COMMENTlink modified 8.3 years ago by Thomas Hampton740 • written 8.3 years ago by nac280
Answer: Script to save plots in Pdf format ( DNAcopy)
0
gravatar for Thomas Hampton
8.3 years ago by
Thomas Hampton740 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
ADD COMMENTlink written 8.3 years ago by Thomas Hampton740
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 REPLYlink written 8.3 years ago by Kasper Daniel Hansen6.4k
Answer: Script to save plots in Pdf format ( DNAcopy)
0
gravatar for René Dreos
8.3 years ago by
René Dreos80
René Dreos80 wrote:
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 COMMENTlink written 8.3 years ago by René Dreos80
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 145 users visited in the last hour