33
Microarray PhD Course November 2007 Generating reports Steffen Durinck

Generating reports copenhagenweb.math.ku.dk/~richard/courses/bioconductor2007/CDrom/biomaRt/... · Microarray PhD Course November 2007 Example Genomic signatures to guide the use

Embed Size (px)

Citation preview

Microarray PhD CourseNovember 2007

Generating reports

Steffen Durinck

Microarray PhD CourseNovember 2007

Traditional way of writingreports

• Analyze the data• Copy results of the analysis in a report• Copy results from report into paper to

submit

Microarray PhD CourseNovember 2007

Workflow

Microarray PhD CourseNovember 2007

Report

• Easy to update analysis• Contain R analysis code• Dynamic• pdf format

Microarray PhD CourseNovember 2007

Workflow

Microarray PhD CourseNovember 2007

Report

• Easy to update analysis• Contain R analysis code• Dynamic• pdf format

Reproducable

Microarray PhD CourseNovember 2007

Forensic bioinformatics

• Keith Baggerley recent talk coined term“Forensic Bioinformatics

What the methods section in the papersays that has been done

Try to reconstruct the analysis that wasactually performed

Microarray PhD CourseNovember 2007

Example

Genomic signatures to guide the use ofchemotherapeutics

Potti et al., Nature Medicine - 12, 1294 - 1300 (2006)

Microarrays: retracing steps - pp1276 - 1277Kevin R Coombes, Jing Wang & Keith A BaggerlyThis week’s Nature Medicine

Microarray PhD CourseNovember 2007

Example

• NCI60 cell lines– Drug response data– Microarray expression data

• Use NCI60 expression data to find set ofgenes that can be used as predictor fortreatment outcome in cancer tumors

Microarray PhD CourseNovember 2007

Example

“Recent studies have suggested how this approach might workusing a widely-used panel of cell lines, the NCI60, to assemble theresponse signatures for several drugs. Unfortunately, ambiguitiesassociated with analyzing the data have made these resultsdifficult to reproduce.”

Keith Baggerly - Mathematical Systems Biology of Cancer II talk

Microarray PhD CourseNovember 2007

Example

• Prediction on other samples workedusing their software

• But same gene set could also predictoutcome for other drugs????

Keith Baggerly - Mathematical Systems Biology ofCancer II talk

Microarray PhD CourseNovember 2007

Forensic bioinformatics:investigation results

• Gene signature was offset by 1 -> indexingerror

• Training of algorithm was performed ontraining + test set=> Near perfect prediction results

Keith Baggerly - Mathematical Systems Biology ofCancer II talk

Microarray PhD CourseNovember 2007

Sweave

• Developed by Friedrich Leisch• A tool that allows Embedding of R code

in LaTeX documents• Code, results and descriptions are

presented in a consistent way

Microarray PhD CourseNovember 2007

Sweave

• Tables, graphs generated on the fly• Dynamic reports which can be updated

automatically

Microarray PhD CourseNovember 2007

Sweave - how it works

Write mix of LaTeX code and R code in.Rnw file

Run Sweave function in R on the created.Rnw

Run latex on the created .tex file

Microarray PhD CourseNovember 2007

Rnw example\documentclass[11pt]{article}\usepackage{hyperref}\usepackage{url}\usepackage[authoryear,round]{natbib}\newcommand{\Rfunction}[1]{{\texttt{#1}}}\newcommand{\Robject}[1]{{\texttt{#1}}}\newcommand{\Rpackage}[1]{{\textit{#1}}}

\author{Steffen Durinck\footnote{[email protected]}}\begin{document}\title{PhD course Copenhagen}\maketitle

Microarray PhD CourseNovember 2007

Rnw example\section{Selecting a BioMart database and dataset}

\subsection{Selecting a BioMart database}

Every analysis with \Rpackage{biomaRt} starts with selecting aBioMart database to use. A first step is to check which BioMartweb services are available. The function \Rfunction{listMarts}will display all available BioMart web services

\begin{scriptsize}<<>>=library(biomaRt)listMarts()@\end{document}

Microarray PhD CourseNovember 2007

Rnw example

> Sweave(“example.Rnw”)

% latex example.tex

example.pdf

Microarray PhD CourseNovember 2007

Rnw example

Microarray PhD CourseNovember 2007

Rnw

• R-code enclosed in

<<>>= R-code goes here@

Microarray PhD CourseNovember 2007

Sweave options

• echo:• TRUE/FALSE• To display code or not

• eval:• TRUE/FALSE• To evaluate code or not

Microarray PhD CourseNovember 2007

Sweave options

• fig:• TRUE• To plot and include images

Microarray PhD CourseNovember 2007

Rnw

Lets create a data object<<>>= a = seq(1:4)@Lets create a second object<<echo = FALSE>>=b = a^2@

Microarray PhD CourseNovember 2007

Rnw

Now some code we don’t want to be evaluated<<eval=FALSE>>= print(a)@Lets make a plot<<fig=TRUE>>=plot(a,b, pch=16, col=‘lightblue’)@

Microarray PhD CourseNovember 2007

tablesDo the analysis<<>>=data(cats, package=“MASS”)lmout = lm(Hwt ~ Bwt * Sex , data = cats)@

Create a table<<results = tex>>=library(xtable)xtable(lmout)@

Microarray PhD CourseNovember 2007

Report versions of usedpackages

• Output of analysis may depend on version ofpackages used.

• E.g. GO or annotation packages• Report package vesion by including

toLatex(sessionInfo())

in your report.

Microarray PhD CourseNovember 2007

Stangle

• Extract R-code only from Rnw file

> Stangle("rnw-example.Rnw")Writing to file rnw-example.R

Code can then be sourced (and run) in R

Microarray PhD CourseNovember 2007

Weaver

• Developed by Seth Falcon• Caching of results• Avoids having to re-compute a

computationally intensive piece of codeeach time one changes the document

Microarray PhD CourseNovember 2007

Weaver

Usage:

In Rnw file:<<cache = TRUE>>

your code to cache @

Sweave(“yourRnw.Rnw”, driver = weaver())

Microarray PhD CourseNovember 2007

Weaver

• Note:

– No side effects (e.g. printing, plotting) will work ina cache = TRUE code chunk

– If change in code chunk is detected cache will berecomputed

– Cache is not document specific. Two documentswith same piece of code in same directory will givesame cache!

Microarray PhD CourseNovember 2007

Compendia

• Combine data and data analysis in an Rpackage

• Easy way to add to publication• Can also be published on BioC site as

example data analysis

Microarray PhD CourseNovember 2007

Live demo

Microarray PhD CourseNovember 2007

References

http://www.ci.tuwien.ac.at/~leisch/Sweave/