Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you...

42
Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in .CEL format A CDF (chip definition file) that is appropriate to the array platform (different for exon and gene arrays!) The affy package for R The makecdfenv package for R

Transcript of Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you...

Page 1: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Analysis of Affy 1.0 ST Gene Array Data in R

To analyze Affymetrix 1.0 ST data (exon or gene) you need:• Expression data in .CEL format• A CDF (chip definition file) that is appropriate to the array platform

(different for exon and gene arrays!)• The affy package for R• The makecdfenv package for R

Page 2: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Analysis of Affy 1.0 ST Gene Array Data in R

1. Affy package information:

http://www.bioconductor.org/packages/2.3/bioc/html/affy.html

Affy package installation R commands:

source("http://bioconductor.org/biocLite.R")

biocLite("affy")

2. Makecdfenv package information:

http://www.bioconductor.org/packages/2.2/bioc/html/makecdfenv.html

 

Makecdfenv package installation R commands:

source("http://bioconductor.org/biocLite.R")

biocLite("makecdfenv")

Page 3: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.
Page 4: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Open the rma.expr.dat text file using Excel. Save as a new file (tab delimited text format) such as “mydata.dat”

Page 5: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.
Page 6: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.
Page 7: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

#Create a boxplot of the normalized databoxplot(mydata[-1], main = "Normalized Intensities", xlab="Array", ylab="Intensities", col="blue")

#To save the boxplot as a jpeg filejpeg("normal_boxplot.jpg")boxplot(mydata[-1], main = "Normalized Intensities", xlab="Array", ylab="Intensities", col="blue")dev.off()

Page 8: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Microarray Data Analysis

(slides used with permission of Dr. John Quackenbush, Dana Farber –creator of MeV software )

http://www.tm4.org/mev/

Page 9: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

The Expression Matrix is a representation of data from multiplemicroarray experiments.

Each element is a log ratio(usually log 2 (Cy5 / Cy3) )

Red indicates a positive log ratio, i.e, Cy5 > Cy3

Green indicates anegative log ratio , i.e.,Cy5 < Cy3

Black indicates a logratio of zero, i. e., Cy5 and Cy3 are very close in value

Exp 1 Exp 2 Exp 3 Exp 4 Exp 5 Exp 6

Gene 1

Gene 2

Gene 3

Gene 4

Gene 5

Gene 6

Gray indicates missing data

Page 10: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Differential gene expression:• T-test• Analysis of Variance• Significance of Microarray (SAM)

Classification:• Hierarchical clustering• K-means clustering

Coherence:• PCA• Relevance Network

Page 11: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

1. Assign experiments to two groups, e.g., in the expression matrix below, assign Experiments 1, 2 and 5 to group A, and experiments 3, 4 and 6 to group B.

Exp 1 Exp 2 Exp 3 Exp 4 Exp 5 Exp 6

Gene 1

Gene 2

Gene 3

Gene 4

Gene 5

Gene 6

2. Question: Is mean expression level of a gene in group A significantly different from mean expression level in group B?

Exp 1 Exp 2 Exp 3 Exp 4Exp 5 Exp 6

Gene 1

Gene 2

Gene 3

Gene 4

Gene 5

Gene 6

Group A Group B

T-Tests (TTEST) – Between subjects (or unpaired) - 1

Page 12: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

3. Calculate t-statistic for each gene

4. Calculate probability value of the t-statistic for each gene either from:

A. Theoretical t-distribution

OR

B. Permutation tests.

TTEST – Between subjects - 2

Page 13: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Permutation tests

i) For each gene, compute t-statistic

ii) Randomly shuffle the values of the gene between groups A and B,such that the reshuffled groups A and B respectively have the same number of elements as the original groups A and B.

Exp 1 Exp 2 Exp 3 Exp 4Exp 5 Exp 6

Gene 1

Group A Group B

Exp 1Exp 4 Exp 5Exp 2Exp 3 Exp 6

Gene 1

Group A Group B

Original grouping

Randomized grouping

TTEST - Between subjects - 3

Page 14: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Permutation tests - continued

iii) Compute t-statistic for the randomized gene

iv) Repeat steps i-iii n times (where n is specified by the user).

v) Let x = the number of times the absolute value of the original t-statistic exceeds the absolute values of the randomized t-statistic over n randomizations.

vi) Then, the p-value associated with the gene = 1 – (x/n)

TTEST - Between subjects - 4

Page 15: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

5. Determine whether a gene’s expression levels are significantly different between the two groups by one of three methods:

A) Just alpha: If the calculated p-value for a gene is less than or equal to the user-input alpha (critical p-value), the gene isconsidered significant.

ORUse Bonferroni corrections to reduce the probability of erroneously classifying non-significant genes as significant.

B) Standard Bonferroni correction: The user-input alpha is divided by the total number of genes to give a critical p-value that is usedas above.

TTEST - Between subjects - 5

Page 16: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

5C) Adjusted Bonferroni:

i) The t-values for all the genes are ranked in descending order.

ii) For the gene with the highest t-value, the critical p-value becomes (alpha / N), where N is the total number of genes; for the gene with the second-highest t-value, the critical p-value will be (alpha/ N-1), and so on.

TTEST - Between subjects – 6

Page 17: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

The problem of multiple testing(adapted from presentation by Anja von Heydebreck, Max–Planck–Institute for Molecular Genetics,Dept. Computational Molecular Biology, Berlin, Germanyhttp://www.bioconductor.org/workshops/Heidelberg02/mult.pdf)

• Let’s imagine there are 10,000 genes on a chip, AND

• None of them is differentially expressed.

• Suppose we use a statistical test for differential expression, where we consider a gene to be differentially expressed if it meets the criterion at a p-value of p < 0.05.

Page 18: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

The problem of multiple testing – 2

• Let’s say that applying this test to gene “G1” yields a p-value of p = 0.01

• Remember that a p-value of 0.01 means that there is a 1% chance that the gene is not differentially expressed, i.e.,

• Even though we conclude that the gene is differentially expressed (because p < 0.05), there is a 1% chance that our conclusion is wrong.

• We might be willing to live with such a low probabilityof being wrong

BUT .....

Page 19: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

The problem of multiple testing – 3

• We are testing 10,000 genes, not just one!!!

• Even though none of the genes is differentially expressed, about 5% of the genes (i.e., 500 genes) will be erroneously concluded to be differentially expressed, because we have decided to “live with” a p-value of 0.05

• If only one gene were being studied, a 5% margin of error might not be a big deal, but 500 false conclusions in one study? That doesn’t sound too good.

Page 20: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

The problem of multiple testing - 4

• There are “tricks” we can use to reduce the severity of this problem.

• They all involve “slashing” the p-value for each test (i.e., gene), so that while the critical p-value for the entiredata set might still equal 0.05, each gene will be evaluated at a lower p-value.

Page 21: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

• Don’t get too hung up on p-values.

• Ultimately, what matters is biological relevance. P-values should help you evaluate the strength of the evidence, rather than being used as an absolute yardstick of significance. Statistical significance is not necessarily the same as biological significance.

Page 22: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Significance analysis of microarrays (SAM)

• SAM can be used to pick out significant genes based on differential expression between sets of samples.

Page 23: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

SAM -2• SAM gives estimates of the False Discovery Rate (FDR),

which is the proportion of genes likely to have been wrongly identified by chance as being significant.

• It is a very interactive algorithm – allows users to dynamically change thresholds for significance (through the tuning parameter delta) after looking at the distribution of the test statistic.

• The ability to dynamically alter the input parameters based on immediate visual feedback, even before completing the analysis, should make the data-mining process more sensitive.

Page 24: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Two-class unpaired: to pick out genes whose mean expression level is significantly different between two groups of samples (analogous to between subjects t-test).

Two-class paired: samples are split into two groups, and there is a 1-to-1 correspondence between an sample in group A and one in group B (analogous to paired t-test).

SAM designs

Page 25: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

SAM designs - 2

Multi-class: picks up genes whose mean expression is different across > 2 groups of samples (analogous to one-way ANOVA)

Censored survival: picks up genes whose expression levels are correlated with duration of survival.

One-class: picks up genes whose mean expression across experiments is different from a user-specified mean.

Page 26: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

SAM Two-Class Unpaired– 4 Significant positive genes (i.e., mean expression of group B >mean expression of group A) in red

Significant negative genes (i.e., mean expression of group A > mean expression of group B) in green

“Observed d = expected d” line

Tuning parameter“delta” limits, can be dynamically changed by using the slider bar or entering a value in the text field.

The more a gene deviates from the “observed = expected” line, the more likely it is to be significant. Any gene beyond the first gene in the +ve or –ve direction on the x-axis (including the first gene), whose observed exceeds the expected by at least delta, is considered significant.

Page 27: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Hierarchical Clustering (HCL)

HCL is an agglomerative clustering method which joins similar genes into groups. The iterative process continues with the joining of resulting groups based on their similarity until all groups are connected in a hierarchical tree.

(HCL-1)

Page 28: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Hierarchical Clustering

g8g1 g2 g3 g4 g5 g6 g7

g7g1 g8 g2 g3 g4 g5 g6

g7g1 g8 g4 g2 g3 g5 g6

g1 is most like g8

g4 is most like {g1, g8}

(HCL-2)

Page 29: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

g7g1 g8 g4 g2 g3 g5 g6

g6g1 g8 g4 g2 g3 g5 g7

g6g1 g8 g4 g5 g7 g2 g3

Hierarchical Clustering

g5 is most like g7

{g5,g7} is most like {g1, g4, g8}

(HCL-3)

Page 30: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

g6g1 g8 g4 g5 g7 g2 g3

Hierarchical Tree

(HCL-4)

Page 31: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Hierarchical Clustering

During construction of the hierarchy, decisions must be made to determine which clusters should be joined. The distance or similarity between clusters must be calculated. The rules that govern this calculation are linkage methods.

(HCL-5)

Page 32: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Agglomerative Linkage Methods

Linkage methods are rules or metrics that return a value that can be used to determine which elements (clusters) should be linked.

Three linkage methods that are commonly used are:

• Single Linkage• Average Linkage• Complete Linkage

(HCL-6)

Page 33: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Comparison of Linkage Methods

Single Ave. Complete(HCL-10)

Page 34: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Bootstrapping (ST)

Bootstrapping – resampling with replacement

Original expression matrix:

Exp 1 Exp 2 Exp 3 Exp 4 Exp 5 Exp 6

Gene 1

Gene 2

Gene 3

Gene 4

Gene 5

Gene 6

Various bootstrapped matrices (by experiments):

Exp 2 Exp 3 Exp 4

Gene 1

Gene 2

Gene 3

Gene 4

Gene 5

Gene 6

Exp 2 Exp 4 Exp 4 Exp 1 Exp 3 Exp 5 Exp 6

Gene 1

Gene 2

Gene 3

Gene 4

Gene 5

Gene 6

Exp 1 Exp 5

Page 35: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Jackknifing (ST)Jackknifing – resampling without replacement

Original expression matrix:

Exp 1 Exp 2 Exp 3 Exp 4 Exp 5 Exp 6

Gene 1

Gene 2

Gene 3

Gene 4

Gene 5

Gene 6

Various jackknifed matrices (by experiments):

Exp 1 Exp 3 Exp 4 Exp 5 Exp 6

Gene 1

Gene 2

Gene 3

Gene 4

Gene 5

Gene 6

Exp 1 Exp 2 Exp 3 Exp 4 Exp 6

Gene 1

Gene 2

Gene 3

Gene 4

Gene 5

Gene 6

Page 36: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Analysis of Bootstrapped and Jackknifed Support Trees

• Bootstrapped or jackknifed expression matrices are created many times by randomly resampling the original expression matrix, using either the bootstrap or jackknife procedure.

• Each time, hierarchical trees are created from the resampled matrices.

• The trees are compared to the tree obtained from the original data set.

• The more frequently a given cluster from the original tree is found in the resampled trees, the stronger the support for the cluster.

• As each resampled matrix lacks some of the original data, high support for a cluster means that the clustering is not biased by a small subset of the data.

Page 37: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

1. Specify number of clusters, e.g., 5.

2. Randomly assign genes to clusters.

G1 G2 G3 G4 G5 G6 G7 G8 G9 G10 G11 G12 G13

K-Means / K-Medians Clustering (KMC)– 1

Page 38: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

K-Means Clustering – 2

3. Calculate mean / median expression profile of each cluster.

4. Shuffle genes among clusters such that each gene is now in the cluster whose mean / median expression profile (calculated in step 3) is the closest to that gene’s expression profile.

G1 G2G3 G4 G5G6

G7

G8 G9G10

G11

G12

G13

5. Repeat steps 3 and 4 until genes cannot be shuffled around any more, OR a user-specified number of iterations has been reached.

K-Means / K-Medians is most useful when the user has an a-priori hypothesis about the number of clusters the genes should group into.

Page 39: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Principal Components (PCAG and PCAE) – 1

1. PCA simplifies the “views” of the data.

2. Suppose we have measurements for each gene on multiple experiments.

3. Suppose some of the experiments are correlated.

4. PCA will ignore the redundant experiments, and will take aweighted average of some of the experiments, thus possibly making the trends in the data more interpretable.

5. The components can be thought of as axes in n-dimensional space, where n is the number of components. Each axis represents adifferent trend in the data.

Page 40: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

PCAG and PCAE - 2

“Cloud” of data points (e.g., genes) in 3-dimensional space

x

y

z

Data points resolved along 3 principalcomponent axes.In this example,

x-axis could mean a continuum from over-to under-expression (“blue” and “green”genes over-expressed, yellow genes under-expressed)

y-axis could mean that “gray” genes are over-expressed in first five expts and under expressed in The remaining expts, while “brown” genes are under-expressed in the first five expts, and over-expressed in the remaining expts.

z-axis might represent different cyclic patterns, e.g., “red” genes might be over-expressed in odd-numbered expts and under-expressed in even-numbered ones, whereas the opposite is true for “purple” genes.

Interpretation of components is somewhat subjective.

Page 41: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Relevance Networks

Set of genes whose expression profiles are predictive of one another.

Genes with low entropy (least variable across experiments)are excluded from analysis.

H = -p(x)log2(p(x))x=1

10

Can be used to identify negative correlations between genes

Page 42: Analysis of Affy 1.0 ST Gene Array Data in R To analyze Affymetrix 1.0 ST data (exon or gene) you need: Expression data in.CEL format A CDF (chip definition.

Relevance Networks

Correlation coefficients outside the boundaries defined by the minimum and maximum thresholds are eliminated.

A

D

E B

C

.28

.75

.15.37

.40

.02

.51

.11

.63

.92A

D

E B

C

Tmin = 0.50The expression pattern of each gene compared to that of every other gene.

The ability of each gene to predict the expression of each other gene is assigned a correlation coefficient

Tmax = 0.90

The remaining relationships between genes define the subnets