getSpecificities: Specificity Score Calculation

Description Usage Arguments Details Author(s) Examples

View source: R/get_specificities.R

Description

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.

Usage

1
getSpecificities(rna, protein, sample_groups)

Arguments

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.

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.

Details

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). This specificity score goes from 0 to 1, where 1 means the gene is expressed only in that particular sample group/tissue/cell type but not in the others, while 0 means the gene is not expressed in that sample group. To calcualte this score, the function averages all replicates gene-wise to obtain the mean expression value of each gene per sample group. Then, it performs Euclidean normalization to obtain a specificity score per gene. When two matching data sets are included (eg. RNA and protein), normalization is done independently for each data set and then a combined socre is derived via a weighted sum of scores. These weights default to 0.5 but can be fine tuned by the user.

Author(s)

Eddie Cano-Gamez, ecg@sanger.ac.uk

Examples

 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:
getSpecificities(rna.example, sample.labels = sample_groups)

## 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:
getSpecificities(rna.example, prot.example, sample.labels = sample_groups)

eddiecg/proteogenomic documentation built on Jan. 1, 2021, 12:13 a.m.