getSimScores: Get Similarity Scoring for a Gene Expression Vector

Description Usage Arguments Value Examples

View source: R/getSimScores.R

Description

This function computes the similarity score of a gene expression vector returned by getExternalVector or a trimmed data set returned by getTrimmedExternalSet, compared to a subset of AIBSARNA, obtained by getRelevantGenes.

Usage

1
getSimScores(data, relevantGenes = NULL, similarity_method = "cosine")

Arguments

data

a named vector of gene expression values returned by getExternalVector, a SummarizedExperiment returned by getTrimmedExternalSet, or a CellScabbard object.

relevantGenes

a SummarizedExperiment object created using the getRelevantGenes() function

similarity_method

currently supported similarity methods are "cosine" and "euclidean", defaults to "cosine"

Value

If data is a vector, returns a vector of similarity scores for each sample in relevantGenes. If data is a SummarizedExperiment, returns a data frame, with columns containing the similarity scores for and named after each sample in data, and rows named after each sample in relevantGenes. If data is a CellScabbard, the results will be stored in its similarityScores slot.

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
AIBSARNA <- buildAIBSARNA(mini = TRUE)
# Example 1 - using CellScabbard class
# get a random sample of 3 genes
totalGenes <- nrow(AIBSARNA)
gene_idx <- sample.int(totalGenes, 3)
sample_idx <- c(1,3,5)
# Subset AIBSARNA
exprs <- assay(AIBSARNA)[gene_idx, sample_idx]
fd <- rowData(AIBSARNA)[gene_idx, ]
pd <- colData(AIBSARNA)[sample_idx, ]
# build a trimmed data set
myGenes <- CellScabbard(exprsData = exprs, phenoData = pd, featureData = fd,
                        AIBSARNA = AIBSARNA, autoTrim = TRUE)
similarityScores(myGenes) <- getSimScores(data = myGenes,
                                          similarity_method = "cosine")
similarityScores(myGenes)
similarityScores(myGenes) <- getSimScores(data = myGenes,
                                          similarity_method = "euclidean")
similarityScores(myGenes)

# Example 2 - manual gene selection and relevant gene extraction
myGenes <- c(4.484885, 0.121902, 0.510035)
names(myGenes) <- c("TSPAN6", "DPM1", "C1orf112")
myGeneSet <- getRelevantGenes(myGenes, AIBSARNA = AIBSARNA,
    AIBSARNAid = "gene_symbol")
CosScores <- getSimScores(myGenes, myGeneSet,
    similarity_method = "cosine")
EucScores <- getSimScores(myGenes, myGeneSet,
    similarity_method = "euclidean")

BrainSABER documentation built on Nov. 8, 2020, 7:28 p.m.