Top Banner
Microarray PhD Course November 2007 Generating reports Steffen Durinck
33

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

Mar 24, 2019

Download

Documents

truonghanh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Generating reports copenhagenweb.math.ku.dk/~richard/courses/bioconductor2007/CDrom/biomaRt/... · Microarray PhD Course November 2007 Example Genomic signatures to guide the use

Microarray PhD CourseNovember 2007

Generating reports

Steffen Durinck

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

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

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

Microarray PhD CourseNovember 2007

Workflow

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

Microarray PhD CourseNovember 2007

Report

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

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

Microarray PhD CourseNovember 2007

Workflow

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

Microarray PhD CourseNovember 2007

Report

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

Reproducable

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Microarray PhD CourseNovember 2007

Sweave

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

automatically

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

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

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

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

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

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}

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

Microarray PhD CourseNovember 2007

Rnw example

> Sweave(“example.Rnw”)

% latex example.tex

example.pdf

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

Microarray PhD CourseNovember 2007

Rnw example

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

Microarray PhD CourseNovember 2007

Rnw

• R-code enclosed in

<<>>= R-code goes here@

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

Microarray PhD CourseNovember 2007

Sweave options

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

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

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

Microarray PhD CourseNovember 2007

Sweave options

• fig:• TRUE• To plot and include images

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

Microarray PhD CourseNovember 2007

Rnw

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

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

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’)@

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

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)@

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

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.

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

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

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

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

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

Microarray PhD CourseNovember 2007

Weaver

Usage:

In Rnw file:<<cache = TRUE>>

your code to cache @

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

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

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!

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

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

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

Microarray PhD CourseNovember 2007

Live demo

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

Microarray PhD CourseNovember 2007

References

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