CosineSimScore: Cosine similarity score

Description Usage Arguments Value See Also Examples

View source: R/CosineSimScore.R

Description

This function calculates the cosine similarity for cell transitions.

Usage

1
CosineSimScore(eset, cell.change, iqr.cutoff = 0.1)

Arguments

eset

an ExpressionSet containing data matrices of normalized expression data, present/absent calls, a gene annotation data frame and a phenotype data frame.

cell.change

a data frame containing three columns, one for the start (donor) test and target cell type. Each row of the data frame describes one transition from the start to a target cell type.

iqr.cutoff

set the threshold for top most variable genes which should be included for the cosine similarity calculation. Default is the top 10 genes, expressed as a fraction. All samples that are annotated as standards will be used for the iqr calculation.

Value

This function returns a list of five objects, as follows:

pdataSub

the phenotype data frame describing the standard samples

esetSub.IQR

the expression value matrix, as filtered by IQR threshold

cosine.general.groups

a numeric matrix of cosine similarity between the centroids of all groups defined by eset@general_cell_types

cosine.subgroups

a numeric matrix of cosine similarity between the centroids of all gsubroups defined by eset@sub_cell_types1

cosine.samples

a numeric matrix of cosine similarity between general groups, subgroups and individual samples.

See Also

hgu133plus2CellScore for details on the specific ExpressionSet object that shoud be provided as an input.

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
## Load the expression set for the standard cell types
library(Biobase)
library(hgu133plus2CellScore) # eset.std

## Locate the external data files in the CellScore package
rdata.path <- system.file("extdata", "eset48.RData", package = "CellScore")
tsvdata.path <- system.file("extdata", "cell_change_test.tsv",
                            package = "CellScore")

if (file.exists(rdata.path) && file.exists(tsvdata.path)) {

   ## Load the expression set with normalized expressions of 48 test samples
   load(rdata.path)

   ## Import the cell change info for the loaded test samples
   cell.change <- read.delim(file= tsvdata.path, sep="\t",
                             header=TRUE, stringsAsFactors=FALSE)

   ## Combine the standards and the test data
   eset <- combine(eset.std, eset48)

   ## Generate cosine similarity for the combined data
   ## NOTE: May take 1-2 minutes on the full eset object
   ## so we subset it for 4 cell types
   pdata <- pData(eset)
   sel.samples <- pdata$general_cell_type %in% c("ESC", "EC", "FIB", "KER")
   eset.sub <- eset[, sel.samples]
   cs <- CosineSimScore(eset.sub, cell.change, iqr.cutoff=0.1)
}

nmah/CellScore documentation built on May 28, 2019, 3:12 p.m.