[BioC] Microarray image files in PDF files

James W. MacDonald jmacdon at med.umich.edu
Tue Apr 13 17:22:32 CEST 2010


Hi Mike,

Mike Walter wrote:
> Hi Jim,
> 
> We are a core lab. So I'd like to generate a QC report for our
> customers with all kind of plots to judge the quality of the data.
> This includes e.g. density plots, boxplots before and after
> normalization, RNA degradation plots, PCA, MAS5 scaling factor, rel
> log expression etc. All these plots are quite small and you can
> easily just make a script that produces the pdf. However, when I use
> for example
> 
> library(affyPLM) data = ReadAffy(celfile.path=celfile,
> filenames=filenames) qcPLM = fitPLM(data) pdf("QC_report.pdf",
> paper="a4", version="1.4") for (i in 1:length(data)){ image(qc.PLM,
> which=i, add.legend=TRUE, main=paste(sampleNames(data)[i], "weights",
> sep=" - ")) } dev.off()
> 
> Then the pdf files become quite large. Of course, I can use png() or
> savepng() instead of pdf(), but then the files are not in my pdf file
> and I have to generate a pdf from the images manually and attach it
> to the QC report. Thus my question was: Can I generate a low
> resolution image that is then put forward to the pdf device. I
> already played a little bit with dev.print() and dev.copy() functions
> but had no real clue how to make it.
> 
> I hope this makes my question a little bit clearer.

Yep. I thought you were doing something like that. At one time I worked 
in a core lab as well, and I used Sweave to create all the reports I 
gave to my clients.

The downside of using Sweave is that you have to learn LaTeX markup as 
well, but you end up with one document that contains all the verbiage 
that you give to your clients as well as the code to create the plots 
and do all the analysis.

All of the BioC packages contain at least one vignette that is based on 
Sweave, so you can look in the /doc directory for anything with a .Rnw 
extension for an example. The affycoretools.Rnw file in my affycoretools 
package is an example of something similar to what I gave my clients.

One slight problem with using Sweave is that the default for all plots 
is to use a pdf, which doesn't help your situation. There are more 
elegant ways to get around this obstacle, but I use the klugetastic 
method of creating the png file and then inserting it manually. As an 
example (which won't likely make sense just yet):

<<echo=false, results=hide>>=
png("thefile.png")
image(qc.PLM, which=1, add.legend=TRUE, <otherargs>)
dev.off()
@

\begin{figure}[htbp]
\centering
\includegraphics{thefile}
\caption{An image}
\end{figure}

The first part creates the image invisibly (tin the output file) and the 
second part puts it in the document. If you have multiple images, you 
can put them up four at a time using layout(matrix(1:4, ncol = 2, byrow 
= TRUE)) to save space.

The various vignettes are an excellent resource to get started, and the 
main Sweave documentation can be found at:

http://www.stat.uni-muenchen.de/~leisch/Sweave/

Best,

Jim


> 
> Thanks for your help and kind regards,
> 
> Mike
> 
> 
> 
> 
> 
> -----Ursprüngliche Nachricht----- Von: "James W. MacDonald"
> <jmacdon at med.umich.edu> Gesendet: 13.04.2010 15:27:32 An: Mike Walter
> <michael_walter at email.de> Betreff: Re: [BioC] Microarray image files
> in PDF files
> 
>> Hi Mike,
>> 
>> Mike Walter wrote:
>>> Hi all,
>>> 
>>> 
>>> 
>>> I'm looking at images of Affy arrays for QC using
>>> images(Affybatch) or images(affyPLMObject). However, when I
>>> include this images in PDF files these tend to get incredibly
>>> large. Therefore, my question would be, is there a method to
>>> generate a png or jpg image and include this in the pdf file?
>> The simple answer is yes. See ?png. But somehow I think the
>> question is more involved than that. Rather than speculating as to
>> what you want, do you have a more directed question with perhaps an
>> example?
>> 
>> Best,
>> 
>> Jim
>> 
>> 
>>> 
>>> 
>>> Any hints are highly appreciated,
>>> 
>>> 
>>> 
>>> Kind regards,
>>> 
>>> 
>>> 
>>> Mike
>>> 
>>> _______________________________________________ Bioconductor
>>> mailing list Bioconductor at stat.math.ethz.ch 
>>> https://stat.ethz.ch/mailman/listinfo/bioconductor Search the 
>>> archives: 
>>> http://news.gmane.org/gmane.science.biology.informatics.conductor
>>> 
>> -- James W. MacDonald, M.S. Biostatistician Douglas Lab University
>> of Michigan Department of Human Genetics 5912 Buhl 1241 E.
>> Catherine St. Ann Arbor MI 48109-5618 734-615-7826 
>> ********************************************************** 
>> Electronic Mail is not secure, may not be read every day, and
>> should not be used for urgent or sensitive issues

-- 
James W. MacDonald, M.S.
Biostatistician
Douglas Lab
University of Michigan
Department of Human Genetics
5912 Buhl
1241 E. Catherine St.
Ann Arbor MI 48109-5618
734-615-7826
**********************************************************
Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues 


More information about the Bioconductor mailing list