evaluate_rule: Evaluate rule to obtain positive / negative cells

View source: R/neighbor_pooling.R

evaluate_ruleR Documentation

Evaluate rule to obtain positive / negative cells

Description

The rule is defined by feature, operator and threshold.

Usage

evaluate_rule(obj, feature, operator, threshold, overdispersion = 0.01)

Arguments

obj

A cellpypes object, see section cellpypes Objects below.

feature

Character scalar naming the gene you'd like to threshold.

operator

One of c(">","<"). Use ">" for positive (CD3E+) and "<" for negative markers (MS4A1-).

threshold

Numeric scalar with the expression threshold separating positive from negative cells. Evaluate_rule expects a plain fraction, not CP10K (while rule has the use_CP10K argument).

overdispersion

Defaults to 0.01, only change it if you know what you are doing. If set to 0, the NB simplifies to the Poisson distribution, and larger values give more variance. The 0.01 default value follows the recommendation by Lause, Berens and Kobak (Genome Biology 2021) to use size=100 in pnbinom for typical data sets.

Value

logical vector stating for each cell whether the rule is true.

cellpypes Objects

A cellpypes object is a list with four slots:

raw

(sparse) matrix with genes in rows, cells in columns

totalUMI

the colSums of obj$raw

embed

two-dimensional embedding of the cells, provided as data.frame or tibble with two columns and one row per cell.

neighbors

index matrix with one row per cell and k columns, where k is the number of nearest neighbors (we recommend 15<k<100, e.g. k=50). Here are two ways to get the neighbors index matrix:

  • Use find_knn(featureMatrix)$idx, where featureMatrix could be principal components, latent variables or normalized genes (features in rows, cells in columns).

  • use as(seurat@graphs[["RNA_nn"]], "dgCMatrix")> .1 to extract the kNN graph computed on RNA. The > .1 ensures this also works with RNA_snn, wknn/wsnn or any other available graph – check with names(seurat@graphs).


cellpypes documentation built on May 29, 2024, 1:24 a.m.