Description Usage Arguments Details Author(s) Examples
View source: R/test_specificities.R
Given an RNA expression matrix (and optionally a matching protein expresison matrix), this function calculates a score reflecting how specific the expresison of each gene is for each sample category compared to the rest. Then, it uses permutations to tests if the gene is more specific than expected by chance.
1 | testSpecificities(rna, protein, sample_groups)
|
sample.labels |
List of sample categories (eg. biological replicates, cell types, tissues, etc...). Must be a character vector. Its elements must match the column names of the RNA (and protein) matrices. Each category is listed only once. |
weight.rna |
When considering both RNA and protein expression, weight assigned to the RNA data. Defaults to 0.5. Must be a number between 0 and 1. |
weight.protein |
When considering both RNA and protein expression, weight assigned to the protein data. Defaults to 0.5. Must be a number between 0 and 1. |
iter |
Number of permutations run when testing for statistical signifiance. Defaults to 1000. |
rna |
RNA expression matrix. Must be a data.frame with columns named after sample category and rows named after genes. Expression values must be possitive and comparable across samples (ie. normalized for library size) before running this function. |
protein |
Protein expression matrix (optional). Defaults to "none". Must be a data.frame with columns named after sample category and rows named after genes. Rows and sample categories must match those of the RNA matrix. Expression values must be possitive and comparable across samples. |
This function takes either one or two correlated expression matrices (eg. RNA and protein expression from the same set of samples) and calculates a specificity score for each sample category (eg. tissue, cell type or biological replicate). Specificity score calculation is done using getSpecificities() (see documentation for this function). After computing specificity scores, the function generates null distributions by randomly permuting the matrix sample names. This is done as many times as specified by the user. The observed specificity score is compared to the scores observed in the permuted data and a P value is calculated as the number of times the observed score is larger than the permuted score. To account for multiple hypothesis testing, the function also implements P-value correction using the Benjamini-Hochberg method (see documentation for p.adjust()).
Eddie Cano-Gamez, ecg@sanger.ac.uk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ## USING ONE DATA SET ONLY (eg. RNA ONLY)
# Simulating mock RNA data:
rna.example <- data.frame(matrix(rnorm(9000,mean=2000,sd=100),ncol=9,nrow=100))
sample_groups <- c("A","B","C")
gene_names <- paste("g",1:100,sep="")
colnames(rna.example) <- rep(sample_groups,each=3)
rownames(rna.example) <- gene_names
# Simulating sets of highly expressed genes in each sample group only
rna.example[1:10,1:3] <- rna.example[1:10,1:3] + rnorm(1,mean=4000,sd=1000)
rna.example[20:30,4:6] <- rna.example[20:30,4:6] + rnorm(1,mean=4000,sd=1000)
rna.example[90:100,7:9] <- rna.example[90:100,7:9] + rnorm(1,mean=4000,sd=1000)
# Running the function:
testSpecificities(rna.example, sample.labels = sample_groups, iter=1000)
## USING TWO MATCHING DATA SETS (eg. RNA AND PROTEIN)
# Simulating matching mock Protein data:
prot.example <- data.frame(matrix(rnorm(9000,mean=7000,sd=100),ncol=9,nrow=100))
colnames(prot.example) <- rep(sample_groups,each=3)
rownames(prot.example) <- gene_names
# Simulating sets of highly expressed proteins in each sample group only:
prot.example[1:10,1:3] <- prot.example[1:10,1:3] + rnorm(1,mean=1500,sd=1000)
prot.example[20:30,4:6] <- prot.example[20:30,4:6] + rnorm(1,mean=1500,sd=1000)
prot.example[90:100,7:9] <- prot.example[90:100,7:9] + rnorm(1,mean=1500,sd=1000)
# Running the function:
testSpecificities(rna.example, prot.example, sample.labels = sample_groups, iter=1000)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.