Running the mdp package

Melissa Lever

2020-04-27

About

The Molecular Degree of Perturbation allows you to quantify the heterogeneity of transcriptome data samples. The mdp takes data containing at least two classes (control and test) and assigns a score to all samples based on how perturbed they are compared to the controls. Gene perturbation scores are calculated for each gene within each class. The algorithm is based on the Molecular Distance to Health which was first implemented in Pankla et al. 2009. It expands on this algorithm by adding the options to calculate the z-score using the modified z-score (using median absolute deviation), change the z-score zeroing threshold, and look at genes that are most perturbed in the test versus control classes.

Basic usage

Load expression and pheno data and run:

library(mdp)
data(example_data) # expression data has gene names in the rows
data(example_pheno) # pheno data needs a Sample and Class column
mdp.results <- mdp(data=example_data, pdata=example_pheno, control_lab = "baseline")
#> Calculating Z score
#> Calculating gene scores
#> Calculating sample scores
#> printing
#> Warning: `fun.y` is deprecated. Use `fun` instead.

#> Warning: `fun.y` is deprecated. Use `fun` instead.

Sample scores

The sample scores can be accessed from the sample_scores element of the mdp results.

Z-score

The mdp works by calulating the z-score relative to the control samples, taking the absolute value of this matrix and setting all vlaues below a threshold (2 as a default) to 0. Expression values that are not 0 are perturbed. You can access this thresholded z-score matrix by,

Gene scores

For each gene in each class, a gene score is calculated, which is the average thresholded z-score value for that gene. A gene frequency is also calculated, which is the frequency that the gene is perturbed in a class.

Perturbed genes

The mdp ranks genes according to the difference between their gene score in the test versus the control samples. The fraction_genes option for the mdp function allows you to control what top fraction of these ranked genes will count as the perturbed_genes. You can obtain a list of the perturbed genes from the mdp results,

Further usage

Adding pathways

Sample scores can also be calculated using genes that are within certain genesets. The mdp will accept genesets that are in the form of a list (see example below). You can read in a .gmt file of genesets using the fgsea::gmtPathways function from the fgsea package.

For each pathway, the signal-to-noise ratio of the test versus control sample scores will be calculated. You can access these results in the pathways element of the mdp results.

Z-score calculation options

As a default, the mdp z-score normalises the expression data using the median as the averaging statistic. The standard deviation is estimated using the median absolute deviation mad function from the Stats package. If you would like to use the mean instead, select “mean”.

You can calculate the thresholded z-score using the compute_zscore function. A vector of control sample names must be provided.