Introduction to microarray exploration and analysis with R...Introduction to microarray exploration...

10
Introduction to microarray exploration and analysis with R by Alex Sanchez March 2, 2010 1 Introduction This document is intended as a short introduction to managing microarray data using R for people who are new to either microarrays, R or both. Although most people working with microarrays and R use one or more of the many freely available R packages to work with microarrays, no specific libraries will be used in this introduction. In spite of the apparent diversity Bioconductor’s packages (www.bioconductor. org)appear to be the natural choice as of February 2005. Also, if before, or after, you proceed with these exercises you feel you need more practice with R you will find many freely available exercises in the net. 2 A first look at microarray data In this first exercise we will lok at some datasets using raw R functions. No Bioconductor package will be used. A microarray data set has been stored in a folder callow 2 000. You can down- load it from this link: http://www.ub.edu/stat/personal/alexsanchez/presentations/MDA/Zaragoza_ 2004/callow_2000.zip . This data corresponds to one of the first papers where statisticians were involved in the analysis of microarray data. You will find information about it in the following address: http://www.stat.berkeley.edu/~terry/zarray/ Html/matt.htmlhttp://www.stat.berkeley.edu/ terry/zarray/Html/matt.html In the following we assume that you have downloaded and unzipped it in another folder “data” pending from your working directory. 2.1 Reading and exploring microarray data The data provided in the example consist of 32 columns 16 for red channel and 16 for green channel of 16 two colour arrays, 8 of which correspond to samples of 8 different mutant mice (with one gene KO) and the other 8 correspond to samples control mice. All have been hybridized against a pooled RNA obtained from the 8 control mice. The goal of the study was to find out genes which were up or down regulated as a consequence of knocking out one gene in the KO group. 1

Transcript of Introduction to microarray exploration and analysis with R...Introduction to microarray exploration...

Page 1: Introduction to microarray exploration and analysis with R...Introduction to microarray exploration and analysis with R by Alex Sanchez March 2, 2010 1 Introduction This document is

Introduction to microarray exploration and

analysis with R

by Alex Sanchez

March 2, 2010

1 Introduction

This document is intended as a short introduction to managing microarray datausing R for people who are new to either microarrays, R or both.

Although most people working with microarrays and R use one or moreof the many freely available R packages to work with microarrays, no specificlibraries will be used in this introduction.

In spite of the apparent diversity Bioconductor’s packages (www.bioconductor.org)appear to be the natural choice as of February 2005.

Also, if before, or after, you proceed with these exercises you feel you needmore practice with R you will find many freely available exercises in the net.

2 A first look at microarray data

In this first exercise we will lok at some datasets using raw R functions. NoBioconductor package will be used.

A microarray data set has been stored in a folder callow2000. You can down-load it from this link:http://www.ub.edu/stat/personal/alexsanchez/presentations/MDA/Zaragoza_2004/callow_2000.zip .

This data corresponds to one of the first papers where statisticians wereinvolved in the analysis of microarray data. You will find information aboutit in the following address: http://www.stat.berkeley.edu/~terry/zarray/Html/matt.htmlhttp://www.stat.berkeley.edu/ terry/zarray/Html/matt.html

In the following we assume that you have downloaded and unzipped it inanother folder “data” pending from your working directory.

2.1 Reading and exploring microarray data

The data provided in the example consist of 32 columns 16 for red channel and16 for green channel of 16 two colour arrays, 8 of which correspond to samplesof 8 different mutant mice (with one gene KO) and the other 8 correspond tosamples control mice. All have been hybridized against a pooled RNA obtainedfrom the 8 control mice.

The goal of the study was to find out genes which were up or down regulatedas a consequence of knocking out one gene in the KO group.

1

Page 2: Introduction to microarray exploration and analysis with R...Introduction to microarray exploration and analysis with R by Alex Sanchez March 2, 2010 1 Introduction This document is

The data are provided as tab-delimited files so they can be read as usual inR.

> datadir <- "./data/callow_2000"

> x <- read.table(file.path(datadir, "matt.rawdat.txt"), header = TRUE, sep = ",")

Now, give a look at the object we have just created

> dim(x)

[1] 6384 33

> names(x)

[1] "row.names" "c1G" "c1R" "c2G" "c2R" "c3G" "c3R" "c4G" "c4R" "c5G" "c5R" "c6G" "c6R" "c7G" "c7R" "c8G" "c8R"[18] "k1G" "k1R" "k2G" "k2R" "k3G" "k3R" "k4G" "k4R" "k5G" "k5R" "k6G" "k6R" "k7G" "k7R" "k8G" "k8R"

> summary(x[, 1])

Min. 1st Qu. Median Mean 3rd Qu. Max.1 1597 3192 3192 4788 6384

We can make x the default data frame so that we don’t have to use x$ to accesscolumns

> attach(x)

The following object(s) are masked from x ( position 3 ) :

c1G c1R c2G c2R c3G c3R c4G c4R c5G c5R c6G c6R c7G c7R c8G c8R k1G k1R k2G k2R k3G k3R k4G k4R k5G k5R k6G k6R k7G k7R k8G k8R row.names

The following object(s) are masked from x ( position 4 ) :

c1G c1R c2G c2R c3G c3R c4G c4R c5G c5R c6G c6R c7G c7R c8G c8R k1G k1R k2G k2R k3G k3R k4G k4R k5G k5R k6G k6R k7G k7R k8G k8R row.names

The following object(s) are masked from x ( position 5 ) :

c1G c1R c2G c2R c3G c3R c4G c4R c5G c5R c6G c6R c7G c7R c8G c8R k1G k1R k2G k2R k3G k3R k4G k4R k5G k5R k6G k6R k7G k7R k8G k8R row.names

The following object(s) are masked from x ( position 7 ) :

c1G c1R c2G c2R c3G c3R c4G c4R c5G c5R c6G c6R c7G c7R c8G c8R k1G k1R k2G k2R k3G k3R k4G k4R k5G k5R k6G k6R k7G k7R k8G k8R row.names

The following object(s) are masked from x ( position 9 ) :

c1G c1R c2G c2R c3G c3R c4G c4R c5G c5R c6G c6R c7G c7R c8G c8R k1G k1R k2G k2R k3G k3R k4G k4R k5G k5R k6G k6R k7G k7R k8G k8R row.names

Define ratios and log ratios for 1st array

2

Page 3: Introduction to microarray exploration and analysis with R...Introduction to microarray exploration and analysis with R by Alex Sanchez March 2, 2010 1 Introduction This document is

> hist(R.1)

Histogram of R.1

R.1

Fre

quen

cy

0 2 4 6

010

0020

0030

0040

0050

00

Figure 1: Frequency histogram. No parameters

3

Page 4: Introduction to microarray exploration and analysis with R...Introduction to microarray exploration and analysis with R by Alex Sanchez March 2, 2010 1 Introduction This document is

> hist(M.1, main = "Expression values", xlab = "Expression", ylab = "# of spots", col = 4)

Expression values

Expression

# of

spo

ts

−2 −1 0 1 2 3

050

010

0015

0020

0025

00

Figure 2: Frequency histogram. More detailed info is given to the plottinginstruction

> R.1 <- c1R/c1G

> M.1 <- log2(R.1)

We can make some plots, either histograms:We can also draw scatterplot of log(Green) vs log(Red), and M-A plotBoxplots are often used to decide if data should be normalizedPlots can also be saved as graphic files. Type help(device) to see formats

available

> pdf("diagnostics.pdf")

> par(mfrow = c(2, 1))

> plot(A.1, M.1)

> abline(h = 0, col = "yellow")

> boxplot(M.1, col = "red")

> dev.off()

windows2

4

Page 5: Introduction to microarray exploration and analysis with R...Introduction to microarray exploration and analysis with R by Alex Sanchez March 2, 2010 1 Introduction This document is

> opt <- par(mfcol = c(2, 1))

> plot(log2(c1G), log2(c1R))

> abline(0, 1, col = "yellow")

> A.1 <- log2(c1R * c1G)

> plot(A.1, M.1)

> abline(h = 0, col = "yellow")

●●

● ●●

●●

●●

●●

● ●●

●●

●●●

●●●

●●●

●●

●●●

●●

●●

●●

●●●●●

●●

●●

●●

●●

● ●

●●

●●

●●●

●●

●●●

●●

●●●

● ●●

● ●

● ●●

●●

●●●

● ●●●

● ●●●

● ●●

●● ●●

●●

● ●

● ●

●●

●● ● ●

● ●

● ●

●●

●●● ●●

● ●●●

●●

●●

●●●●●

●● ●●●●

●●●

●● ●

●● ●

●●

●●●

●●

●●

●●

●●●● ●

●●●●

●●

●●

●●

●●●● ●

●●● ●●

● ●●●●

●●

● ●●

● ●●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●●●

●●●

●●

●●●

●●

●●

● ●●

●●

●●●

●●

●●

●●●●

●●● ●

●● ●

●●●●

●● ● ●

●●●●

●●

●●●

●● ●●

●●

●● ●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●●

● ●

●●●

●●● ●

●●●

● ●●● ●

● ●●

●●

●●

● ●

● ●

●●

●●

●● ●

●●●

●●

●●

●●

● ●

●●●

●●●

● ●

●●

●●

●●

●●

●●● ●

● ●●●●

●●

●●●

●●●

●●

●●●

●●

●●

●● ●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●● ●

●●●

●●

●● ●

●●●●

●●●

●●

●●●

●●

●●

●●

●●●

●●●

●●

●●

● ●

● ●●

●●

●●●●

● ●●● ●

●●●●●● ●

● ●●●●●

●●●

●●

●●

●●●

● ●●

●●

● ● ●●● ●

● ●

●●

●●●

●●●

●●

●●

● ●●

●● ●

●● ●●

●●

●●

● ●●●

●●

●●

●●● ●

● ●

●●

●●●●● ●● ●● ●

●●●

●●

●●● ●●

●●

●●

●●●●

●●●

●●

● ●

●●

●●

●●●●●

●●

●●

●●

●●

●●

● ●

●●

● ●

●●

●● ●

● ●

●●

● ●

●● ●

●●

●●

●●

●●●

●●● ●

● ●●

●●

●●

● ●

●● ●

● ●

●●

●●

●●

●● ●●

●●●

●●

●●

●●●

●●●

● ●

●●

●●●

●●

●●●

● ●

●●

●●●

●●

●●●●●

●●●

●●

●●●

●●● ●

●●

●●

●●● ●

●●●

●● ●●●

●● ● ●●●

●●●

●●

● ●● ●●● ●

●●●

●●●●

●●

●●

●● ●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

●●

●●●

●●

●●

●●

●● ●

●●

● ●

●●●

●● ●

● ●

● ●●●

●● ●

●●

●●

●●

●●

●●

●●

● ●

●●

●●● ●●●

●● ●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●● ●

●●

●●

● ●

●●

●●

●●● ●

●● ● ●●

●●

●●

●●

●●

●●

●●● ●

●●

●●●

●●●

●●

● ●●

●●

●● ●

●●●

●●

●●

●●

●●●

●●

●●

●●●

● ●●

●●●

●●

●●●●

●●

●● ●●●●

●● ●●

●●

●●●

● ●

●●●●●

● ●●

●●●●●

●●

●●

●●

●●● ● ●

●●

● ●●

●●

●● ●●●

●●

●●● ●

●●

●●●

●●●

●●●●

●●●● ●●

●●●

● ●

●●●

●●●●

●●

●●

●●●

● ●

●●●

●●

●●●

●●

● ●

●●

●●●

●●●

●●

● ●●●● ●

●●

●●

● ●

● ●●●

●●

●●

●●

●●●

●●

● ●● ●

●●

●●

●●

●●●●

●●● ●●●●

● ●

● ●●●

●●●●

●● ●● ●

●●

●●● ●

●●

●● ●

●●

●●

●●

●●

●●

●●

●●●

● ● ●●

● ●

● ●●

● ●● ● ●

●●●

●●

● ●●

●●

●●

●●

●●●

● ●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●●

●●●

●●

● ●●

●●

●●●

●●●

●● ●

●●

● ●

●●

●●●

●● ●

●●

● ●

●●

●●●● ●

●●●●●●●

● ●

●●●

●●

●●

● ●●●

●●●●

●●●●●● ●

●●

●●

●●●●●

●●●

●●●

●●●

●●●

●●

●●●●

●●

●● ●

●●●

●●

●●●

●●

●●

●●

●●●

●●

● ●●●

● ●● ●●●

●●●

●●

●●

● ●●

●●

●● ● ●●● ●

●●

●● ●

●● ●

● ●

● ●●●●●●

●●●●●

●●

● ●●

● ●●

●●●

● ●●●

●●●

●●●

● ●

●●●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●

●●

● ●

● ●

●●

●●

●●

●●●

●●

● ●●●

●●● ●

● ●

●●

●●●●

● ●

●●●

●●

●●

●●

●● ●

●●

●●

●●●●

●●●

●●

●●●●●●●

●●

●●

●●

●●

●●

●●● ●

●●●●●

●●

●● ●●

●●

●●●●

●●● ●●●●

● ●●●●●●● ●● ●

●●● ●

●●●●●

●● ●●

● ●●●● ●

●●

● ● ●●

●●

● ●●●

●●●

●●●

●●

● ●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●● ●

●●

●●

●●

● ●

●●

●● ●●●●●

●●●●●● ●●●●● ●● ●

●●●

●●●

●●

●●●

●●

●●

●● ●

●●

●●●

●●

●●

●●

●●

●●●

●●

●●

●●●●

● ●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●

● ● ●●

●●

●●

●● ●

●●

●●

●●●

●●

●●

● ● ●●●●

●● ●

● ●● ●●

●● ●

●●

●●●●●

●●

●●

●●

●● ●

●● ●

●●

●●

● ●●●

●●●●

●●

●●● ●● ●●●●●●

● ●●

●●●

●●

●●●●

●●

●●

●●

●●

● ●

●●

●●

●● ●●

●●

● ● ●

●●

●●●

●●

●●

●●

●●

● ●

●●

●●

●●●

●●

●● ●●

●●

●● ●●

●●

●●

● ●

●●●

●●●●

●●

●●

●●●●

●● ●●●●

●●●

●● ●●● ● ●●● ●●●

●●●●●

●●

●●

●●

●●●●

●●

●●

●●

●●● ●

●●

● ●

●●

●●

● ●

●●

●●●

●●

●●

● ●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●●

●●

● ●●

●●

●●●

●●

●●●

●●

●●

●● ● ● ● ●

●●

●●

●●●

●●

●●

●●●

●●

● ●

●●●●

●● ●

●●

●●

●●

●●●

●●

●●●

●● ●

●●

●●

●●

● ●● ●● ●

●●

●●●●

●●●

●● ●●●●●

● ●●●●

●●●

●●

● ●● ●

●● ●

●●●

●●●

●●

●●

●● ●

●●

●● ●

●●

●●●

● ●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●●●

●●●

●●

●●

●●●

● ●●

●●

●●

●●●

●● ●

●●

●●

●●●●●●● ● ●

●●●

●●

●●

● ●●

●●●●

●●

●●

●●

●●

●●

● ● ●

●●

●●●

● ●

●●

●●

●●

●●●

●●●

● ●

●●●

●●

● ●

●●

● ●●

●●●●

●●●

● ●

●●●

●●

● ●●

●●

● ●●

●●● ●

● ●

●●

● ●

●●● ●

●●

●●

● ●

●●

●●

●●

●●

●●

●● ●●

●●

● ● ●●

●●

●●

●●●

●●●

●●

●●●

● ●●

●●

●●● ●● ●●●

●●●●●

●●●

●●

●●

●●●●●●

●●●●

●●●●●● ●

●●

●●

●●

●● ●●

●●●

●●●●

●●

●●

●●

● ●

●●

● ●●

●●●●

●● ●

●●

●●●

●●

●●

●●

●●

●●

●● ●

● ●

●●

●●●

●●

●●

●●●

● ● ●

●●●

●●

●● ●●●

●●

● ● ●

●●

●●

●●

● ●●●●

● ● ●

●●

●●●

●●

●● ●

●●●

●●

● ●●

●●

●●●

●●

●●●

● ●

●●

●●●

●●●

● ●

●●

●●●

●●●●

● ●

●●

●●

●●

●●●●

●●●

●●

● ●● ●●

●●

●●

● ●●

●●

●●

●●

●●

●●●●●

●●●● ●

●●●

●●

● ● ●●● ●● ●

●●

● ●●●●●●

●●●

● ● ●●●● ●

● ●●●

●● ●●

●●●

●●●●●●

●●●

● ●●● ●

●●●

● ●●●

●●

●●

●●●●●●●● ●

●●

● ●●●

●●●●● ●●●● ●●●●●●●●●● ●●

●●

● ●●

●●

●●●

●●●

●●

●● ●

●●

●●

●●

●●

●●

● ●●

●●● ●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

● ●●●

●● ●

●●

●●●

● ●

●●

●●●●●●●● ●●● ● ●●●●

● ● ●●● ●●

●●

●●●●

●●●●●

● ●

●●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

● ●●

● ●

●●

●●

●●

●●

●● ●●

●●

●●●

●●

●●

●●

●●

● ● ●● ●

●●●

●●

●● ●●

● ●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●●

● ●●

●●●

●● ● ●●●●● ●●●

●●●● ●

●●

● ●●●●

●●●●

●●●

●●

● ●●●●● ●

● ●●

●● ●●●● ●

●● ●●

●●

●●

●●

●●● ●● ●●● ● ●

● ●

●●● ●●● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

● ●

●●●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●

● ●●

● ●●

●●

●●

●● ●

● ●

●●

●●

●●●● ●●●●●●

●● ●

●●●●

●●●

●●●

●●

●●

●●

●●

●●

● ●●

● ●

● ●●

●● ● ●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●●●

●● ●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ● ●

●●●

● ●

●●

●●● ●

● ●

●●

●● ●

●●

●●

●●●

●●

●●

●● ● ●●●

●●

●●

●●

● ●● ●● ●

● ●●●●

●●●●●

●●

●● ●●●●

●●

●●●

● ●● ●

● ●

●● ●●

●●●●

●●●●

● ●

●● ●

● ●

●●

●●●

●●● ●●

●●

●●

●●●

●● ●●

●●●

●● ●●●

● ●●

●● ●

●● ●

●●●

● ●

●●

●●● ●

●●

●●●●

●●

●●●●

●●●

●●

●●

●●

●●

●●●

●●●●

●●●●●●●●●

●●

●●

●●

● ●●●

●●

●●

●●

●●

●●

● ●●

● ●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

● ●●

●●

●●

●●●

● ●

●●

● ●

●●

●●

●●●

●●

●●●

● ●●

●●

●●●●

●● ●●●

●●●● ●

●●

●●

●●● ●●

●●

●● ● ●●●

●●

● ●

●●●

● ●●●

● ●●

●●●

● ●● ● ●●

●●●●

●●●

●●

●●● ●

●●

●●●●

●●

●●

● ●●●

●●

●●

●●

●●

●●

●● ●

●●●

●●●●

●●●

●●

●●

●● ●

●●

●●

●●

●●●

● ●●

●● ●●

● ●●●●

●●●

●●

●●●●

●●●

●●

●●

●●

●●●

●●

●● ●●●

● ●

●●

●●

●●●●

●●●

●●

●●

● ●

●●

●●●●

●●

●●

●●

●●

● ●●

●●

●●

●●

●●●

●●

●● ●

●●

●●

●●

●●

●●●●

●●

●●●

●●

● ●

●●

●●

●●

●●

●●

●●

● ●●

●●●

●● ●●●

●●

●●

●●

●●●

●●

●●

●●●●

●●●●

● ●●●●

● ●●●

●●

●●●

●●● ●

●●●

●●●●●● ● ●●

●●●

●●●

●●

●●

●●

●●●● ●

●●

●●

●●

●●●

●● ●

●●●●

● ●

●●●

●●

●●●

●●●

●●

● ● ●

● ●

●●●

●●

●●●●

●●

●● ●●

● ●●

● ●●

●●

●●

●●

● ●

●●

● ●●●

●●

●● ●●

● ●●

●●

●●

●●

●● ●

●●

●●

● ●●

●●

●●

● ●

●● ●

●●

● ●

●●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

● ●●●

●●

●● ● ● ●●●

● ●

●●

●●

●●

●●

●●

● ●●

●●●

●●●●●

●●●

● ●●

●●

●●

●●

●●

●●

●●

● ● ●●●●

●●● ●●●

● ●●●

● ●●● ●

●●

●●●●

●●● ●

●●

●●

●● ●

● ●●●●●

●● ●

●●

●●

●●●

●● ●

● ●● ●

●●●●●

●● ●●● ●●●

●●

●●●

●●●

●●

●●●●

●● ●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●●

●●

●●

●●

●●

● ●

●●●●

●●●

●●

●●

●●●●

●●

●● ●

●●

●● ●

●● ●●

●●

●●

●●●

●●

●●

●● ●●

●●

●●

●●

●●

●●

●●

●●●● ●●

●●●● ●

●●

●●●●

●●

●● ●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●●

●●

●●●●

●●

●●

● ●

●●

●●

●●

●●

● ●

●●

●●●

●●

●●

●●

●●

● ●

●●

●●

● ●●●

●●

●●

● ●●

●●

●●●

● ●●●

●●

●●

●●●●

●●

●●

●●

●●●●●

●●

●●● ●●●

● ●●

●●

●●●●●

● ●

●●

●●

●●

●●●

●●

●●●●

●●●

● ●●●●●

●●● ●●

●● ●

●●●

●●

● ●●●

●●

●●

●●

●●

●●●●

●● ●

●●

● ●

●●

●●●●

●●

● ●●

●●

● ●

● ● ●

● ●● ●●● ●

●●

●●●

● ●

●●●● ●

●●

●● ●●

8 10 12 14

810

14

log2(c1G)

log2

(c1R

)

●●●

●●

●● ● ●●

●●●

●●● ●●

●●●

●●● ● ●●●● ●

●●●●

● ● ●● ●● ●● ●

●●●

●●●

● ●●

●●

●●●●

●●

●● ●

● ●●●● ●

●● ●●●●

●●

●●● ● ●●

● ●●

●●

●●

●●●

●●

●● ●●

●●

●● ●●●

●●

●●

● ●● ● ●

●●

●●●●●● ●●

● ● ●●

●●

●●● ● ●

●● ●●●

● ●●●●

● ● ● ●●●

●●● ●● ●●

●●● ●●●●

● ● ●●

●● ●

● ●● ●●●●

●●● ●●●

●●● ●

●●

●●● ●

● ●●●

●●

●●

●●●

●●●●

●●●

●●

●●

●●

●●

●●● ●● ●●●

●●●●●●

●●●●●

●●

●●●

●●

● ●●●●●

●●

●●

● ●●●

●●

● ●● ● ●●

●● ●● ●

● ● ●● ●●

●● ●

● ●●

●● ●●

●●

●●●

●●

●●

●●

●●●●

●●

●●

●●●

●●●

●●●

●●● ●●

●●

●●

●●

●●

●●

●● ●● ●● ●●●

●●● ●

●● ●

●●

● ●●●●

●●●●●

● ●● ●●

●●●●

●●

●●

● ●●●

● ● ●● ●

●●●●

●● ●●

● ● ●●● ●● ●

●● ●● ●●●●●

●●●

●● ●● ●● ●●●●

●●

●●●●

●●

●●

● ● ●● ●●●● ●

●● ●

●●●

●●●●

● ●●

● ●●●● ● ●

●●● ●● ●●

●●●●●

● ●●● ●●● ● ●

●● ●●

●●

●●

●●● ●●●● ● ●●● ●● ● ●●

● ●● ●● ●● ●● ●●●●

● ●● ●●●● ● ● ●●

●● ●●●

●●●

●●

●●● ●

●● ●●● ●

●●

●●

●●●●● ●● ●●●

● ●●

●● ●●●

● ●●●● ●

●●

●●● ●●● ● ●●

●●● ●● ● ●●●●

●●

● ●

●● ●

● ●●●

● ●●● ●● ● ●●● ●●●●

●●

●●● ●●●

● ●●

●● ●●●●● ●●

●● ●

●●

●● ●

●●●

●● ●

●● ● ●●

●●●

●●

●●●

●●●

●● ●●

●●

● ●●●● ●

● ●●

● ● ●●● ●

●●● ●● ●● ●

●●

●●● ●●●●

●●●●

●● ●

●●

●● ●●

●●●●●●

●●●

●●●

●●●●

●●●

●●

●●●

●●●●● ●

●●

●●

●● ●

●● ●●●

●●

● ● ●●●

●●

●●

●●

●● ● ●

●● ● ●●●

●●●

●●● ●● ●●

●●

●●

●●● ● ●

●●● ●

●●●

●● ●

●● ●●● ●● ●● ●● ●

●● ●●

●●

●●

●●

● ●●●

● ●●

●●●

●●

●● ●● ●

●●

●●

● ●●

●●●● ●

● ●●● ●● ●● ●●●

●● ●●● ●●

●● ●●●● ●●●

●●

●● ● ●●● ●●●

●●●●●● ●●

●●

●● ● ● ●●●●●

●●

●●●

● ●●● ● ●

●●●

●●

●●●●●

● ●● ●● ●

●● ●

● ●●●●

● ●●

●●●●● ● ●

● ●●● ●●●●

●● ●

● ●● ●●●● ● ●

●● ●●●

●●

●●● ●

●●● ●●

● ●●●●

●●● ●

●● ●●

●●

● ●●●● ●● ●●

●●

●●

●●

● ●●● ●● ●●

● ●●●

●●●● ●● ●●

●●●●

●●●

● ● ●●● ●

●●

●● ● ●

● ● ●●

●● ●

●●

●●●

● ●●

●●

●●

●●

●●●● ●●

●●

●●

●●

●●●●●●● ●● ● ●

●●

● ●●●

●●● ●● ● ●●

●●●●● ● ●●● ●

●●

● ●● ●●

● ●●

●● ●●●●

●●

●●●

● ●● ●● ●●

●● ●●

●●●●

● ●● ●

●● ●● ●

●● ●●●

●●●● ● ●●

●● ●● ● ●●● ●●● ● ●

●●●●●●

● ●●

●●●●

●● ●●

●●●

●●●●

●● ●●● ● ● ●●

●●●

●● ●● ● ●

●● ● ●●●

●●●●● ●●● ● ●

●●● ● ●●●

●●

●● ●●● ●●●●

●● ●● ●● ●● ●

●●

●●●●●

●●

●●●●

● ● ●●● ●●

●●

●●●●●

●●●

●●

●●

●●● ●

● ●●

●● ●●

● ●● ●●

●● ●

●●

●●● ●●● ●

●● ●● ●●●●

●●●

●●

● ●●

●●● ●● ●● ●

●●

● ●●

● ●●

●●

●●●

●●

●●●

●●

● ●●● ●

●●

●●●

●●●

● ●

●●

●●●

●●

●●

●●

● ●●●

●●

●● ●

●●

● ● ●●

● ●

● ●

●●

●●

●●●● ●●● ●● ●

●● ●●●●

●●●●

●●● ●●

●●

●● ●●

●● ● ●

●●

●●●●●

●●●●●

●● ●

●● ●●●

●● ●

●●●● ●

●●●●●

●● ●● ● ● ●●

●●

●●●● ●●●

●● ●●

● ●● ●●● ●● ●●

●● ●● ●● ● ●●

● ● ● ●●

●●

●●●●● ● ●● ●●

● ● ●●●

● ●● ●●● ●● ●

●●● ●●●

●● ●

● ●●

●●● ●

●● ●

●●

● ●●● ●

●●●●

●● ●● ●● ● ●●

●● ●●

●● ●●● ●●

●● ●● ●●● ● ●●●

●● ●

●● ● ● ●●

●●●●

●●

● ●●●

● ●●●

●●

●●

● ●● ●●

●● ●

●●

●● ●● ●●●

●● ● ●●●

●●● ●● ●● ●

●●

●●

●●

●●●

●● ●●

●●●●

●●● ●●●

●● ●●●● ●●●●

●●

●● ●●● ●● ●●● ●

●●●

● ● ●●● ● ●● ●● ●●

●● ●●

●●●●

●●●

●●

●●

● ●● ●●

●●

●● ●●●●●● ●

●●

●●

●●

●●

●●

●●●

●●

●● ●

●● ●●●●●

●●

●● ●

● ● ●

●●

●●●

● ●●

●●●●

●●●●● ●●

●●

●●

●●

●●●● ●●

●●

●●●●

●●●● ●

●●● ●● ●

●●●

●●●●● ● ●●●

● ●●

●● ● ●●●●

●●

●● ● ●●●

●●

●●●● ●●● ●●

●●●●● ●● ●

●●●●●●●

●●●

●● ●●● ●

●● ●

●●●● ●● ● ●●●● ●●

●● ● ● ●

●● ●●●●●●●●●●

●●● ● ●● ●●● ●

●● ●●●

●●●

●● ● ●●

●●●●● ●

●● ●●

●●

●●

●●● ●●

● ● ●●

●●

● ●●

● ●●●

●●●

● ●●●

●●

●●●● ●●●

● ●●●●●

●●●

● ●●●●

●●

●●●● ●

●●●● ●

●●●●

●●●

●●● ●●●●

● ●●●●

●●● ●●●

●●

●●

● ●●●● ●

●●●●

●●● ●● ●

● ●●●●

●● ●●

● ●●

●●●

●●●

●● ●●●

●●

●●

● ●

●●●

●●

●●

●●

● ●●● ●●

●●●●

●● ●

●●●

●●

●●

●●

●●

● ●●● ●● ●●

●●

●● ●

●●

●●

● ● ●●● ●●●

●●

● ●●●●●

●●●

●●●●

●●●●● ● ●

●●●

●●●●●

●●

●● ● ●

● ●●●● ●

● ●●

●●● ●●● ●

● ●●

●●

● ●

●●●●● ●● ●● ●●●

● ●● ● ●●●● ●●

●●●

●●

●●●

●●

●● ● ●●●●

●● ●●

●● ●● ●●●●●

●●● ●●● ●● ●

●●●● ● ●●●●

●● ●● ●●● ●●●● ●

● ●●

●●● ● ●●●● ●● ●●●● ●● ● ● ●

●●●● ●● ●●●● ● ● ●● ●●

●●● ●●

●●●●● ● ●● ●● ● ●● ●

● ●●●

●●●

●●

● ●

●●

● ●● ●●●

●●

●●

●●●● ●●

●●

● ●●

● ●

● ●● ●

●●

● ● ●

●●

●●●

●●●

●●●●●●

●●●●

●●●●

●●

●●●

●●

●●●

●●

●●

●●

● ●

●● ●

● ●●● ●

●●

●●

●●● ●●

●●●

● ● ●●● ● ●● ●

●●●●

●●●

●●●● ●

●● ●●

● ●●●●●

●●

●● ●●

● ●●● ●●

● ●●

●●

●●●

● ●●● ●●●

●●●●●

●●●

●●

●●

●●● ●

●● ●

●●●

●●●

●●● ●●

● ●● ●

●●

●●

●●●●

●●

●●●

●●●

●●

● ●●● ● ●●● ●

●●

●●

● ●● ●● ●●● ● ●● ●● ●● ● ●● ●●

● ●● ●● ●●●●

●●●

● ●●

● ●● ●

●●

●●● ● ●●

● ●●

●● ●●●

● ●● ●

● ● ●●

●● ●●●●● ●●● ●

●●●●●

●● ● ● ●●●

● ●●

● ●● ●●● ●●●●●● ●● ●

●● ● ●●●

● ● ● ●● ● ●● ● ●● ●●

●●●●●

●●●

● ●●● ● ●●●● ●

●●● ● ●

●●●●

●●●

●●

●●

●● ●●

●●●● ●

●●

●●●

●●

● ●●

●●● ●

●●

● ●

●●●

● ●●

●●●

●● ●

●● ●●

● ●

●●

● ●●●

●●●

●●●

●●●

● ●

●●

●●●

●●●

●● ●●●

●●

●●● ●● ●●

●●

●● ●●

● ● ●●●●

●●

●●●

●●

● ●●

●●●●

● ●

● ●● ●

●● ●

●●

●● ● ●●

●●

●●●●

●●

●●

●●

●●

●● ●●

●●●

●● ●

●●

●●

● ● ●●●

●●

●●

●●

●●

●●

●●●●●●●

●●●

●● ●

● ●●●

●●

●●

●●

● ●●

●● ●

● ●●

●●

● ●●

●● ● ●● ●●●

● ●●●●

●● ●

●●

●● ●●● ● ●

●● ●

●● ●●●

●●

● ●●● ●

●●

●●

●●

●●●● ●●

●● ●

●●

●●●●

●● ● ●●● ●

●●

●●

●●●●

●●

● ●● ●●● ●● ● ●

●●

● ●● ●●

●●

●●

●●●●● ●

●● ●● ●●●● ●● ●● ● ●● ●● ●

●●● ● ● ●●● ● ●●● ●●

● ● ●●●● ●●

●● ●● ●● ●●● ●●

●●●

●●● ●

●●

●●

●●● ●

●●●

● ●

●●●● ●● ● ●

●●

●● ●●● ●

●●

●●●

●●● ●●

●●

●● ●●●

●●

●●●●●●

●●● ●●●

● ●●●● ●●● ●

●● ●

● ●●

●●●●●● ●

●●

●●●

●● ●

●● ●●●

●●●●

●●

●●● ●

●● ●

● ●

●●

●●● ●● ●●●●● ●

● ●

● ●●● ●

●●●●

● ●● ●

● ●●

●● ●●

●●

● ●

●●

●●●●

● ●●

● ●●● ●

●●

● ●●

●●● ●

● ●

● ●

●●

●●

●● ●●

●●●

●● ●● ●● ●●

●● ●

●●

● ● ● ●●●

● ●●● ●● ●●●● ●●●● ●●●● ●●● ●

●●● ●● ●● ●●● ●

●● ●●

●● ● ● ●●●●

●●●

●●● ●● ●● ●● ●

●●

●●

●●

●●●●

●●●

●● ●●

●●●

●● ●●● ●●●●●●●●

●● ●●● ● ●●●

●●

●● ●●●●●●

●●●

●●● ●● ●● ●

● ●●● ● ●●●

● ● ●●

●● ● ● ●●● ●●●●●● ●●●

● ● ●●●

●●● ●● ●● ●

●●●

● ●●●●●

●●

● ●●●

● ● ●●●●

●● ●●

● ●●●●● ●●

●●

●●●

●● ●

●●

●●

●●

●● ●●●

●● ●●● ● ●● ●●●●

●● ●●●●●●●

●●

●●●

●●

●●

●●

●●

●● ●●

● ●●

●●

●● ●

●●● ●

●●●

●●

●●● ●

●●

●●●

●●

● ●● ●●

●● ● ●●● ●●●

●●●●

●●●

●● ●

●●

●●● ●●

● ●●●

●●●

●●

● ●

●●

● ●●

●●

● ●●

●●

●●●

●●●●●●

●●● ● ●●

●●

●● ●●●●●

●● ●

●●●

●●●

●●

●● ● ●

●●●●●●●

●● ●

●● ● ●

●● ●● ●

●●●

● ●●●● ●

●●●● ●

● ● ● ●●● ●●●●●●

●●● ●

●●

●●

●●●●

● ●●●●

● ●●● ●

●●●

●●●● ●● ●●

●●

●●●● ●

●●

● ●● ●● ●●

● ●●

●●

●●●

●●

●●●● ●●

● ● ●●●● ● ● ●●●

●● ●● ● ●● ● ●

●●●

●● ● ●● ●●

● ●●●

●● ●● ●● ●

●● ●●

●●● ●● ●●

●●●●

●● ●●

●●●

●●

●●

●●●●

●● ●●●●●

●●●

●●●●

● ●●

● ●

● ●●● ● ●

●●●●

●●●

●●●

●●

●●

●●

●●●

●●

●●● ●

● ●●● ●●

●● ●● ●

●●●●

●●●● ●●

●●

●●

●●

●●

● ● ●●

● ●● ●

●●

●● ●●

●●●

●●

●● ●●●● ● ●●

●●

●● ●●●

●●

●● ●●● ●●

●●●●

●● ●●●● ●

●●

●●

●●

●●●

●●

●●

●●●● ●●

●●● ● ●

● ●

●● ●

●●

●●

●● ●●●●

●●●

●●● ●

●● ●

●●● ●

●●

●●

●● ● ●●●

●● ●

● ●●

●●

●● ●

●● ●●

●●

●●●

●● ●

●● ●

●●

●● ●

●●● ● ●

●● ●●

●●

●●

●●●

●●

●●● ●

● ●●●●

● ●●●

● ●

●●●●

● ●●●● ●

●● ● ●● ●

●●●

●●

●● ●

●● ● ●● ●● ●●

● ●● ●●●

●●

●●

●● ●●● ●● ●● ●●

●● ●●

●●●

●●●●● ● ●

●●●●

●●

●● ●

●●●

●●● ●

●●● ● ●●

●●●

●●

●●

●●● ●●

● ●● ● ●

●●●

●●●

● ●

● ●

●●● ●

●● ●● ●● ●●

●●

●●

●●

●●

●●

●●● ●●

●●

●●● ●

● ●

●●

●●

●● ●●● ● ●● ● ●

●●● ●●

●●

●● ● ●●

● ●●●●

●●

● ●

●●

●●

●● ●●● ●

●●●● ● ●

●●

●●●

●●

●●●●

●●

● ●

●●●

●● ●● ●● ●

●●●

●●● ●● ●●

●●

●●

●●

●● ●

●●

●●● ●●

●● ●●

●●

● ●● ●

●●●●●●●●● ●

●●● ●

●●●

●●●● ●

●●●

●●

●●●● ●● ●● ●●

●● ●

●●

●●

●●

●●

●● ●

●●

●●

●● ●●

● ● ●●●

●● ●●

● ●● ●

●●●

●●

● ●●●

●●●

●●●● ● ●

●●

●●

●●

●●

●●

●● ●

●● ●●●

●●

●●

●●

●●●

● ●●

● ● ●●●

● ● ●●

●●

●●●

●●

●●●

●●

●● ●

● ●●

●●

●● ●

●●●

● ●●

●●

●●●●

●●●●

●●

●● ●

●● ●●

●●

●●

●●● ●●

●● ● ●●

● ●●

●●●●

●●●

● ●●

●●●

● ●●

●●

●●

●● ● ●

●●

● ●●

●●

●●

● ● ●●

●●

●●

●●

●●

●●

●● ●●

●●●

●● ●

●●

● ●●

●●●

● ●●●

●●● ●

● ●●●● ●

●●

●●

●●

●●

●●●

●●●●

●● ●●

●●●

●● ●

●●

●● ●

●● ●●●

●●

●●● ●

●●●

●●●● ●

●●

● ●

●● ● ●●●●

●●

●●●

●●●●●● ●

●●

●●

●●

● ●● ●

●●

●●

●●●●

●● ● ●●

●●●●●

●●

●● ● ●

●● ● ●

● ●● ● ●

●●

●●●

●● ●

●●●

● ●●●

●● ●

●● ●

● ●

●●

●●● ● ●●●●

●● ●●●

●●●

●●●

● ● ●●●●

●●●● ●

●●

●● ●●●

●● ●●●

● ●●● ●●●●

●●

●●●●

●●●● ●● ●

●● ●● ●

●●● ●

●● ●●

●●

●●

●● ●●

●● ● ●

●● ● ●● ●●●

●●●●●

●● ●

●● ● ●

● ●●

●●●

● ●● ●● ●●

● ●

●● ●●

●●●● ●●● ●● ●●●●●●

●●

●●

●●

● ●● ●●●●●

● ●

●●● ●●●

●●

●●●●

●● ●

●●

●●●

●●●● ● ●● ●●● ●●●

●●

●●

●●●●

●●● ●●●●

●●

●●●

●●

●●● ●

●●●

●●

● ●

●●

●●●

●●

●●●

●●●

● ● ●

●●

●●●

● ●●●●

● ●

●● ●

● ●

●●

● ●

●●

● ●●

●●

●●

●● ●

●●

●●●

●●

●●

●●

●●

●● ●

●● ●●

●●● ●

●●

●●

●●

●● ● ●●

● ●●●

●●●●●●

●●

●● ●● ●

●●●● ●

●● ●

● ●●●

● ● ●●●●

●● ●● ● ● ●

●● ●●●

●● ● ●●● ● ● ●●

●●

●●●

●●●●● ●

●●●● ●●●●

●●

● ●●

● ●●●●● ● ●● ●●● ● ● ●●●

●●

●●

●●●

●● ●●● ● ●●

●●●

●●●

● ●

●● ●● ●●● ●●●

●● ●● ●●●

●● ●●●●

●●●

●● ●● ●●● ●● ● ●

●●

●●●

●●

● ●●● ●● ●●● ●●

● ●●●● ●

●●●

●●

●●● ●●●●

●● ●●●●

●●

●●●

●● ● ●●

●●

●● ●●● ●●●●● ●

●● ● ●●●

●●●

●●●

●●● ●

●●●● ●

●●

●● ●● ●●

●●●●● ●

●●

●●●

●●●●●●

●●● ●●

●●● ●

●● ●●●

●● ● ●

●●●

● ● ●●

●●●●● ●

● ● ●●●●

● ●●

● ●● ●●●

●●●●

●●●●

●●

● ●●●●●

●●

●●●

●● ● ● ●

●●● ●● ●●

●●

●●

●●

●●

●●

●●

●●●

●●

● ●●

●●

●● ●

●●

● ●●●

●●●●

● ●● ●

●●● ●

●●●●

●●● ●●●● ● ●●● ●● ●

●●

●●

●●●● ● ●●● ●

●●● ●

●●●●● ● ●

●●●●●

●●

●●

●● ●●

●●

●●●

● ●●●

●●

●●

●●●●

●●

● ●

●●●

●●●

●● ●●

●●

●●

●●

●●

●●

●●

●●● ●●

● ●●●●

●● ●

●●

●●●

●●

●● ●

● ●●

●● ●

●●

●●

●●●●

●●●

●●●● ● ●

●●

●●● ●

●●

●●●

●●●●

●● ●●● ● ●

●●

● ●●● ●

●●

●●● ●

● ●●●●

●●

●●

●●

●●

●● ●●

● ●● ●

●●

●●

● ●●●●

●●●●●● ●

●●

●● ●

●● ●●

●● ●

●●

● ●●●●

●●●

●● ●●

●●●

●●

●●

●● ●●

●●

● ●●●

●● ●

●●

●●

●●

●● ●

●● ●

●●

●●

●●●●●●

●● ●

●●

● ●● ●

●●

●●●

●●

●● ●●

●●

● ●

● ●●

●●● ●● ●

●●●●●

●●●

●● ●

●●●

●●

●●

●●●

● ●

15 20 25 30

−2

02

A.1

M.1

Figure 3: Panel graphic windows (2rows, 1 colum)

2.2 Exercises

1. Create two data frames which contain respectively the Red and Greenintensities for all 16 slides. [Hint]Use R’s subsetting capabilities to extracta subset of columns from the original data frame.

2. Create one data frame with M values log2(Ri/Gi) and another with Avalues log2(Ri*Gi) for all 16 slides. Give them respectively names “Ms”and “As”.

3. Use the data frame Ms to draw a multiple boxplot to compare all slides inone figure.

4. Use both data frames Ms and Asto draw one M-A plot per slide in thesame figure (use par() to plot several scatterplots in one graph).

5

Page 6: Introduction to microarray exploration and analysis with R...Introduction to microarray exploration and analysis with R by Alex Sanchez March 2, 2010 1 Introduction This document is

> M.2 <- log2(c2R/c2G)

> M.9 <- log2(k1R/k1G)

> M.10 <- log2(k2R/k2G)

> par(mfcol = c(1, 1))

> boxplot(data.frame(M.1, M.2, M.9, M.10), col = rainbow(4), main = "Expression values for 2 control and 2 knocked slides", xlab = "Slides", ylab = "Log rato distribution")

> abline(0, 0, col = "black")

●●●●

●●

●●●●

●●●

●●●

●●●

●●

●●

●●●●

●●

●●

●●

●●

●●●

●●●●●

●●

●●

●●●●●●●●●●●●●●●

●●●

●●●

●●●●●●

●●●●●●●●

●●

●●●●

●●●

●●

●●●●

●●●●●

●●

●●

●●●

●●

●●●●●●●●

●●

●●

●●●

●●

●●

●●

●●●

●●●●●

●●●●●●

●●

●●

●●●●●●●●●

●●●

●●

●●

●●●●●

●●●

●●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

M.1 M.2 M.9 M.10

−4

−2

02

Expression values for 2 control and 2 knocked slides

Slides

Log

rato

dis

trib

utio

n

2.3 Looking for differentially expressed genes

In this section we assume that the data have already been normalized, so thatwe can proceed to compare them to see if there is differential expression betweentwo conditions.

Normalized data for this experiment have been stored in the file ./data/callow_-2000/matt_norm_ratios.txt

First read the data:

> mouse.exprs <- read.table(file.path(datadir, "matt_norm_ratios.txt"), header = TRUE, sep = "\t", row.names = 1)

> mouse.gnames <- read.delim(file.path(datadir, "matt.genenames.txt"), header = TRUE, sep = "\t", fill = TRUE)

> mouse.class <- c(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1)

> head(mouse.exprs)

C1.data C2.data C3.data C4.data C5.data C6.data C7.data C8.data K1.data K2.data K3.data K4.data K5.data K6.data K7.data K8.data1 -0.23457737 -0.83158063 -0.6180309 -1.46073302 0.16698661 -0.843864843 -0.4209371 -1.07416419 0.09609868 -0.42979572 0.8626526 -0.60073175 0.04014791 -0.16330174 0.2688845 -0.303794362 0.05101557 0.14054098 0.2064007 0.04617628 0.73971571 0.021971569 0.6933016 -0.10209606 0.97495050 0.61914978 1.3210929 0.03594104 1.12799669 1.06330881 1.2594082 0.571855743 -0.22116314 -0.68723114 -0.7469853 -0.96496408 1.38126671 -0.306123534 -0.3222581 -0.14976971 -0.12355114 -0.44678701 -0.3368338 0.25751030 -0.83565547 0.87560379 0.5391692 0.662773494 -0.17614774 -0.06022798 -0.2793193 -0.09527858 0.47475606 -0.080751780 -0.1003728 -0.07623446 0.29122076 0.19763873 -0.1028259 -0.23627043 -0.34607777 0.19509152 -0.1249309 0.04845121

6

Page 7: Introduction to microarray exploration and analysis with R...Introduction to microarray exploration and analysis with R by Alex Sanchez March 2, 2010 1 Introduction This document is

5 -0.84518668 -0.09472253 -0.0948846 -0.26148475 -0.42953666 0.009062893 -0.2668316 -0.04148026 -0.05430977 0.28000254 -0.2264584 -0.23060642 0.08664487 -0.04729377 0.3809822 -0.382459446 -0.30824961 0.17702764 -0.3411856 -0.33593135 -0.07958284 0.106530106 -0.3597629 0.01545710 -0.34705768 0.09509325 -0.3062049 -0.39884527 0.07176649 0.07685888 0.1457991 -0.55076585

> head(mouse.gnames)

spot NAME TYPE CLID ACC1 1 Cy3RT Control BLANK BLANK2 2 Cy5RT Control BLANK BLANK3 3 mSRB1 cDNA mSRB1 mSRB14 4 BLANK BLANK BLANK BLANK5 5 BLANK BLANK BLANK BLANK6 6 BLANK BLANK BLANK BLANK

We can check up to what point the normalization has been successful usinga boxplot:

> boxplot(mouse.exprs, main = "Normalized expression values", xlab = "Slides", ylab = "Log ratio distribution", las = 2, col = c(rep("yellow", 8), rep("blue", 8)))

> abline(0, 0, col = "black")

●●●●

●●

●●

●●●●●

●●

●●

●●●

●●

●●●

●●

●●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●●●●●●●●●

●●●

●●●●●

●●●●●●●

●●

●●●●●●●●●●●●●

●●●●●

●●●

●●●●●●●●●●

●●

●●●

●●

●●

●●

●●

●●●

●●●●●●●

●●●●●●

●●●

●●●●●

●●

●●●

●●

●●●●●●

●●

●●●●

●●●

●●

●●●

●●●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●●

●●●●

●●

●●

●●●

●●

●●●●

●●

●●

●●

●●●●●●●●●●

●●

●●

●●●●

●●●

●●

●●●●●●●●

●●

●●

●●●

●●●●●●●●●●●

●●

●●●

●●●

●●

●●

●●●●●●

●●●●●●●

●●

●●

●●●●●

●●●

●●●

●●

●●●●●●●

●●

●●

●●●

●●

●●

●●●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●●

●●

●●●●●●

●●●●

●●●

●●●●

●●●●●●●

●●

●●

●●

●●●●

●●

●●●

●●●●

●●●●●●●●

●●●

●●●●

●●●●

●●●●

●●●

●●●

●●●●●

●●●●●

●●

●●●●●●

●●●

●●●

●●●

●●●

●●●●●

●●●●

●●

●●●

●●●

●●●

●●●

●●

●●●

●●

●●●●

●●●

●●●

●●●●●●

●●

●●●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●●●

●●

●●●●●●●

●●

●●

●●●

●●

●●

●●●●●●

●●

●●●

●●

●●●

●●

●●

●●●

●●

●●●●

●●●●●

●●

●●

●●●

●●

●●

●●

●●●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●●

●●●●

●●

●●●●●

●●

●●

●●

●●●

●●

●●

●●●

●●●

●●

●●●

●●●●●●●

●●●●●

●●●●●●●

●●●●●●

●●

●●●

●●

●●●

●●●●●●

●●●●●●●●

●●

●●

●●

●●●

●●●

●●●●

●●

●●

●●●●●

●●

●●●●●●

●●●●●●

●●

●●●

● ●

●●

●●●●●●●●●

●●

●●

●●

●●●●●●●●

●●

●●●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●●

●●●●●●●

●●

●●

●●●

●●●●

●●●

●●●●●●●

●●

●●●●●●

●●●●●●●

●●●

●●●

●●●●●

●●●●

●●●

●●

●●

●●●●●●●

●●●

●●●●●●

●●●

●●●●●●

●●

●●●●●

●●●●●●●●

●●

● ●

●●

●●

●●●●

●●

●●●

●●●●●●●●●●●●

●●●

●●●

●●●●

●●

●●

●●

●●

●●

●●●

●●●●

●●

●●●

●●

●●

●●●●

●●

●●●●●

●●

●●●●●●

●●●●●●

●●●

●●●●

●●●●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●●●

●●●●●

●●

●●●●

●●●

●●

●●

●●●

●●●●●

●●●●●●●●●

●●●

●●●●●

●●●●

●●●●

●●●●●●

●●●●●●●

●●●

●●●●●●●●

●●●●●

●●●●●●●

●●

●●●●●●●●●●●

●●●●

●●●

●●●●

●●

●●

●●●●●

●●●●●

●●

●●●●●●●

●●●●

●●●

●●

●●●

●●●●

●●●

●●

●●●●●●

●●●●

●●

●●

●●●●

●●

●●

●●

●●

●●●●●●

●●●

●●●●●●●●●●●

●●●●●●●●●●

●●

●●●●●●●●●

●●●●●●●●●●●●●●●●●

●●●●●●●●

●●●●

●●

●●●

●●●●●

●●●●

●●●●●●●●●●●●●●

●●●●●●

●●●●●●●●●

●●●●●

●●●

●●●●

●●●●

●●

●●●●●●●

●●

●●●●●●●●●●

●●●●●●●●●●●●●●

●●●●●

●●●

●●●●●●●●●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●●●

●●

●●

●●

●●

●●●●

●●●●●●●

●●●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●●●

●●

●●●●●●●●

●●

●●●●

●●●●●

●●

●●●

●●●

●●

●●

●●●●

●●

●●

●●

●●●●●●●●

●●●●●●

●●

●●

●●

●●

●●●●●●●●●●●●●

●●●●●

●●●●

●●●●

●●

●●

●●

●●

●●●

●●

●●

●●●●

●●●●●●●●

●●●●

●●

●●

●●●●●

●●●

●●

●●●●

●●●

●●

●●●●

●●

●●●●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●●●

●●

●●

●●

●●

●●●●●

●●●

●●●

●●

●●

●●●

●●

●●●●●●

●●●●●

●●●●●●●

●●

●●●●

●●

●●●

●●●

●●

●●

●●

●●●

●●●●●●

●●●●

● ●

●●

●●

●●

●●●●●●

●●

●●

●●

●●

●●●●

●●

●●●

●●

●●●●●

●●

●●

●●●

●●●

●●●●

●●●●

●●●●●●

●●●●●●

●●●

●●●●●

●●

●●

●●●

●●●

●●

●●●●●●

●●●

●●

●●

●●●

●●

●●●●

●●●

●●

●●●●

●●●●●

●●

●●

●● ●●●

●●●

●●●●●

●●●●●

●●●●●●

●●●●●●●●●

●●●●●

●●●●

●●●●●

●●●●

●●

●●●

●●●●

●●

●●●●●

●●●●

●●●●

●●

●●●●●●●●

●●●●●●●

●●●●●●

●●●

●●

●●●●●●

●●●●

●●

●●●●●●

●●

●●●●

●●

●●

●●●

●●●●●●

●●

●●●●

●●

●●

●●●

●●

●●●●

●●

●●●

●●●●●●

●●●

●●●●

●●●

●●●

●●

●●

●●●●

●●

●●●●

●●●

●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●●●●●

●●●

●●●●●●

●●●●●●

●●

●●

●●●

●●●●●

●●●●●

●●●

●●●

●●●

●●●●●●

●●

●●

●●

●●●●●●●●●●●●

●●●●

●●

●●

●●

●●●

●●

●●●

●●●●

●●●●●●

●●

●●●●●●

●●

●●●●●●

●●●●

●●●

●●●●●

●●●●●●

●●●

●●●●

●●●●●

●●●●

●●

●●●

●●●●●●●

●●●●●●

●●●●●●●

●●

●●●

●●

●●●

●●●●●

●●●

●●●

●●

●●

●●●●

●●●

●●●

●●

●●

●●

●●

●●

●●●●●●●

●●

●●

●●●

●●

●●●

●●●

●●●●●●

●●

●●

●●●

●●

●●●

●●

●●●

●●●

●●

●●●●

●●●●

●●●●●●●●●

●●

●●●●●●

●●●

●●

●●●

●●

●●

●●

●●

●●●●●

●●

●●●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●●●

●●

●●●

●●

●●

●●●

●●●●

●●

●●●●●

●●●

●●

●●●●●●●

●●

●●●

●●

●●

●●

●●

●●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●●

●●

●●●

●●●●●

●●●●

●●

●●●●●

●●

●●

●●

●●

●●●●●

●●●

●●

●●●●●●●

●●●●●●●●●●●●●●

●●●●●●

●●●●●●●●

●●●

●●

●●

●●

●●

●●

●●●●●●

●●●●●●●

●●●●●

●●

●●●

●●

●●●●

●●●

●●●

●●●●

●●●●●●●●●●

●●●

●●●●

●●

●●

●●●●

●●

●●●

●●●●●

●●●

●●

●●●

●●

●●●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●●●●

●●

●●

●●●●●

●●

●●●●●

●●

●●

●●

●●

●●

●●●●●

●●

●●●●●●●●●●●●●●●

●●

●●

●●●●●●

●●●●

●●

●●●●●

●●●●●●●●●●●

●●●

●●

●●

●●●●●●●●●

●●●●●

●●●●●●●●

●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●

●●

●●●

●●●●

●●

●●●●●●●●●

●●

●●●●●●●

●●

●●

●●●

●●

●●●

●●

●●●●

●●●●●●●

●●

●●●●●●●●●●

●●●

●●●●●●●●●●●●●●

●●●●●●●●

●●

●●

●●●●●●

●●●

●●●●

●●

●●

●●●

●●●●●●

●●

●●

●●●●●●●

●●●●

●●●●

●●●●

●●●●●●

●●●

●●

C1.

data

C2.

data

C3.

data

C4.

data

C5.

data

C6.

data

C7.

data

C8.

data

K1.

data

K2.

data

K3.

data

K4.

data

K5.

data

K6.

data

K7.

data

K8.

data

−4

−2

0

2

4

Normalized expression values

Slides

Log

ratio

dis

trib

utio

n

The following loop performs a comparison of means between the two groups.using a Stdent’s t-test such as the built in function called t.test. We can adaptit to our needs:

> ttest = function(x) {

+ tt = t.test(x[1:8], x[9:16])

+ return(c(tt$statistic, tt$p.value))

+ }

7

Page 8: Introduction to microarray exploration and analysis with R...Introduction to microarray exploration and analysis with R by Alex Sanchez March 2, 2010 1 Introduction This document is

and call it using apply again:

> ans = apply(x, 1, ttest)

> teststat <- ans[1, ]

> pvals = ans[2, ]

These values can be explored to guide selection of genes differentially ex-pressed.

t-values can be explored graphically using QQ-plots. QQ plots informallycorrect for the large number of comparisons and the points which deviate markedlyfrom an otherwise linear relationship are likely to correspond to those geneswhose expression levels differ between the control and treatment groups.

> qqnorm(teststat)

> qqline(teststat)

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●●

●●●

●●

●●

●●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●

●●●●

●●

●●●●

●●

●●●

●●

●●

●●

●●

●●

●●●

● ●●●●

●●

●●

●●

●●

●●●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●

●● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●

●●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●

●●●● ●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●●

●●●

●●

●●

●● ●●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●● ●

●●

●●

●●

●●●

●●

●●●

●●

●●

●●●

●●

●●●●

●●●

●●●

●●

●●●

●●●

●●●●

●●●

●●●

●●

●●●

●● ●

●●●

●●

●●

●●

●●

●●●

●●

●●

●●

● ●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●●

●●●

●●

●●

●●●●

● ●●

●●

●●

●●●

●●

●●●

●●

●●

●●●

●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●●●

●●

●●

●●●●

●●

●●

●●

●●●

●●●

●●●●●

●●

●●

●●

●●●

●●●

●●

●●

●●

●●●

●●●

●●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●● ●●

●●

● ●●●

●●

●●●●

●●●●●

●●●

●●

●●●●●●●●●●

●●●●

●●

●●

●●● ●

●●●●

● ●

●●●●●

●●

●●

●●

●●

●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●●●

●●

●●

●●●

●●

●●

●●

●●●●●●●

●●

●●

●●●

●●

●●●

●●

●●

●●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●●

●●●●●

●●

●●

●●

●●●●●

●●

●●

●●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●●●

●●

●●

●●●●●

●●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●● ●●

●●

●●

●●

●●●

●●●

●●●●

●●

●●●

●●

●●●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●●●

●●

●●●

● ●●

●●●●●●●

●●

●●●●●●●

●●●

●●●●

●●●●

●●

●●●

●●●

●●●

●●●

●●

●●

●●

●●●

●●

●●●●●●●●

●●●●●●●●●●●●●

●●

●●

●●

●●

●●

●●

●●●●

●●

● ●

● ●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●● ●●●●●

● ●●●

●●●

●●●●●●

●●●

●●

●●●

●●

●●

●●

●●

●●●●

●●

●●●

●●

●●●

●●●

●●

● ●

●●

●●

●●

●●

●●

●●

● ●

●●●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●●●●●●●●

●●●●●

●●●

●●●

●●

●●

●●●

●●●●

●●

●●●●

●●

●●●●●

●●

●●●●● ●

●●

●●●●●●●●

●●●●●●●

●●●

●●●●●

●●

●●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●●

●●

●●●●●

●●

●●

●●●

●●

●●

●●

●●

●●●●●●●●

●●●●●●

●●

●●●●●●

●●●

●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●●

●●●

●●●

●●

●●

●●

● ●●●

●●

●●

●●

●●●

●●

●● ●●

●●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●●●

●●●

●●●●

●●●

●●

●●

●●

●●●

●●●

●●●

●●●

●●●

●●●●

● ●● ●●

●●●

●●

●●

●●●●

●●●●●

●●●

●●

●●

●●●●●

●●●

●●●

●●

●●

●●●

●●●●

●●

●●

●●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

● ●●●●

● ●●●●●●●

●●

● ●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●● ●●

●●

●●

●●

●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●●●

●●

●●

●●

●●●

●●

●●●

●●●

●●

●●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●●

●●

●●●● ●

●●●

●●

●●●

●●●

●●

●●

●●

●●

●●●●

●●

●●

●●●●●

●●●●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●●●●

●● ●●

●●●

●●●●●

●●

●●

●●●●●

●●

●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●●●●

●●

●●

●●●

●●

●●

●●

● ●

●●

●●

●●

●●●●●●

●●●

●●

●●●●

●●

●●●

●●●

● ●●

●●

●●

●●

●●

●●

●●

● ●

●●

●●●●

●●

●●●

●●

●●

●●

●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●●●

●●●●●●●

●●

●●

●●

●● ●● ●

●●●●●● ●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●●●●

●●●●

●●

●●

●●●●

●●

●●

●●●

●●●

●●

●●●

●●

●●

●●

● ●

●●

●●●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●●

●●●

●●●

●●●

● ●●●

●●●

●●●●

●●

●●●●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●●●●

●●

●●

● ●●

●●

●●●

●●●

●●●

●●●

●●●

●●

●●

●●

●●

●●

●●

● ●●

●●

●●

●●

●●

●●●

●●●●

●●

●●●

●●●

●●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●●

●●●

●●●

●●●

●●

●●

●●

●●

●●

●●●●

●●●

●●

●●●●●

●●

●● ● ●

●●●●●●●

●●

●●

●●●●

●●●●

●●●

●●●

●●●

−4 −2 0 2 4

−2

02

46

Normal Q−Q Plot

Theoretical Quantiles

Sam

ple

Qua

ntile

s

Figure 4: QQ plot of tests statistics.

Before we can decide if a gene is differentially expressed we should performsome type of multiple testing adjustment. For practical purposes we can simplydecide to keep the 10 genes with the largest absolute value of t-statistic

> rank.test <- rank(abs(teststat))

> res <- data.frame(mouse.gnames$NAME, rank.test, teststat)

> ranked.genes <- res[order(res[, 2], decreasing = TRUE), ]

> names(ranked.genes) <- c("Gene Name", "Rank", "t-value")

> ranked.genes[1:10, ]

8

Page 9: Introduction to microarray exploration and analysis with R...Introduction to microarray exploration and analysis with R by Alex Sanchez March 2, 2010 1 Introduction This document is

> hist(teststat)

Histogram of teststat

teststat

Fre

quen

cy

−2 0 2 4 6

050

010

0015

0020

00

Figure 5: Histogram of t-statistics.

9

Page 10: Introduction to microarray exploration and analysis with R...Introduction to microarray exploration and analysis with R by Alex Sanchez March 2, 2010 1 Introduction This document is

Gene Name Rank t-value1424 MDB1309 6384 5.7467331403 MDB0702 6383 4.4532251383 MDB0132 6382 4.3641861954 Cytochrome P450, 4a14 6381 4.1184881404 MDB0704 6380 4.1005001445 BLANK 6379 4.0464534940 PUTATIVE ACETYLCHOLINE REGULATOR UNC-18, Brain-Img 6378 3.9268671405 MDB0706 6377 3.714223802 BLANK 6376 3.637099317 est 6375 3.546960

The APO-AI, the gene which was knocked out in the KO group appears infirst position: this is the most changed gene, as was expected.

10