22
Distances Between Genes and Samples Naomi Altman Oct. 06

Distances Between Genes and Samples Naomi Altman Oct. 06

Embed Size (px)

Citation preview

Page 1: Distances Between Genes and Samples Naomi Altman Oct. 06

Distances Between Genes and Samples

Naomi Altman

Oct. 06

Page 2: Distances Between Genes and Samples Naomi Altman Oct. 06

Why Do We Care about Distance?

Genes that are "close" may be in the same pathway or have similar function.

Samples that are "close" may come from similar subpopulations, or have an evolutionary relationship.

Page 3: Distances Between Genes and Samples Naomi Altman Oct. 06

Human Vs Chimp Brains

Page 4: Distances Between Genes and Samples Naomi Altman Oct. 06

Some ideas from the picture

1. Some genes are much more highly expressed in some tissue.

2. Brain regions are more similar across species than species across brain regions (for these genes).

Page 5: Distances Between Genes and Samples Naomi Altman Oct. 06

Some questions based on the picture

Suppose that we were missing the expression for a gene in this picture for a particular sample. How might we "impute" a value?

Suppose we had a new sample and wanted to know the species and brain region? How could we infer this?

Suppose we have a gene of unknown function in the first cluster. What might one infer about the function?

Page 6: Distances Between Genes and Samples Naomi Altman Oct. 06

Which gene is closest in expression pattern to the black gene?

Page 7: Distances Between Genes and Samples Naomi Altman Oct. 06

Some common distance measures

'euclidean': Usual square distance between the two vectors (2 norm).

'maximum': Maximum distance between two components of x and y (supremum norm)

'manhattan': Absolute distance between the two vectors (1 norm).

'canberra': sum(|x_i - y_i| / |x_i + y_i|). Terms with zero numerator and denominator are omitted from the sum and treated as if the values were missing.

'minkowski': The p norm, the pth root of the sum of the pth powers of the differences of the components.

'correlation': 1-r where r is the Pearson or Spearman correlation

'absolute correlation': 1-|r|

Page 8: Distances Between Genes and Samples Naomi Altman Oct. 06

PreprocessingOften we preprocess, either by gene (row) or by

sample (or treatment) (column)

Centering

Y-c(Y) where c(Y) is the sample mean or

sample median

Standardizing (scaling, z-score)

Y-c(Y) where s(Y) is a measure of spread

s(Y) such as SD or IQR

Page 9: Distances Between Genes and Samples Naomi Altman Oct. 06

Which gene is closest in expression pattern to the black gene?

Page 10: Distances Between Genes and Samples Naomi Altman Oct. 06

Centered

Page 11: Distances Between Genes and Samples Naomi Altman Oct. 06

Centered and Scaled

Page 12: Distances Between Genes and Samples Naomi Altman Oct. 06

Data Imputation

Some classification and clustering methods require expression values for every sample (or every gene in every sample)

Imputation is a technical term for clever methods to make up data.

2 reasonable methods:

K-nearest neighbors (KNN)

Singular Value Decomposition (SVD)

Page 13: Distances Between Genes and Samples Naomi Altman Oct. 06

KNNBased on the distance metric of your choice, and

all the non-missing values of your gene G

compute d(G,x) for all other genes and select

the K closest x1 ... xk

The imputed value is the weighted average

wixi where closer genes are more heavily weighted.

Naturally, we use the imputed value only to fill in the missing value - the other values for G are kept.

Page 14: Distances Between Genes and Samples Naomi Altman Oct. 06

SVDAny matrix M can be decomposed as

Mg,s=Ug,gDg,sV's,s where D is zero except on the

diagonal

Then Mvi = divi and uiM=diui

V captures the main patterns of variation in the rows of M

U captures the main directions of variation in the columns of M

Page 15: Distances Between Genes and Samples Naomi Altman Oct. 06

SVD I made up a matrix as follows:

x=1:12

G15,12 has 4 rows which are sin(2 x/12) + noise

3 rows which are sin(2 x/12 + 1.5) +noise

7 rows which are noise

Page 16: Distances Between Genes and Samples Naomi Altman Oct. 06

SVDAny matrix M can be decomposed as

Mg,s=Ug,gDg,sVs,s where D is zero except on the

diagonal

Use the k columns of V corresponding to the largest values of D

Then

is considered to be a less noisy version of M

M is the gene expression matrix with rows=genes and columns = samples.

We start by putting the row average in any missing value and then iteratively estimate V and regress the observed values of the gene on the selected columns of V to fill in the missing values

Page 17: Distances Between Genes and Samples Naomi Altman Oct. 06

SVDg.svd=svd(g)

Page 18: Distances Between Genes and Samples Naomi Altman Oct. 06

Using SVDThe diagonal elements of D are called the

eigenvalues. The sum of the elements squared is a measure of the overall variability of the data.

We generally assume that treatment differences create more variability than the noise in the data.

So, the largest eigenvalues should express the variability due to the treatments.

Page 19: Distances Between Genes and Samples Naomi Altman Oct. 06

Using SVD

Scree is the jumble of rock at the base of a mountain.

The scree plot (eigenvalues vs rank) is used to pick out the informative eigenvalues from the jumble (noise).

Page 20: Distances Between Genes and Samples Naomi Altman Oct. 06

"Denoised Reconstruction"Mg,s=Ug,gDg,sV's,s

If there are k informative eigenvalues, we pick the corresponding k columns of U and V

M*=Ug,kDk,kV's,k is a denoised reconstruction of M

To use to fill in missing data: start by filling in M with some estimate (e.g. row or column mean)

Compute M* and replace missing values in M by corresponding values in M*

Iterate

Page 21: Distances Between Genes and Samples Naomi Altman Oct. 06

The first 9 rows of the matrix and the reconstruction based on 2 eigenvalues.

Note that rows 8 and 9 are where the pure noise begin.

Page 22: Distances Between Genes and Samples Naomi Altman Oct. 06

Some terminology for Data Imputation

• Missing completely at random:

Pr( R| X(obs), X(miss) ) = Pr( R )

does not depend on the values in X .

• Missing at random:

Pr( R| X(obs), X(miss) ) = Pr( R| X(obs) )

depends on the values in X only through the ones we get to observe.

• Missing NOT at random:

Pr( R| X(obs), X(miss) )

depends also on the values we do not get to observe – most complicated situation

(These simple imputation methods do not work.)