get_neighborhood_preservation_scores: get_neighborhood_preservation_scores

View source: R/get_neighborhood_preservation_scores.R

get_neighborhood_preservation_scoresR Documentation

get_neighborhood_preservation_scores

Description

Calculates cell neighborhood preservation scores by comparing distances to the neighbors from True and Selection k-NN graphs.

Usage

get_neighborhood_preservation_scores(
  sce,
  neighs.all_stat = NULL,
  genes.all = rownames(sce),
  genes.selection,
  batch = NULL,
  n.neigh = 5,
  nPC.all = 50,
  nPC.selection = NULL,
  option = "exact",
  ...
)

Arguments

sce

SingleCellExperiment object containing gene counts matrix (stored in 'logcounts' assay).

neighs.all_stat

If not NULL, should be precomputed using function geneBasisR::get_neighs_all_stat. Useful to precompute if geneBasisR::get_neighborhood_preservation_scores is planned to be recycled multiple times for different selections.

genes.all

String specifying genes to be used for construction of True kNN-graph.

genes.selection

String specifying genes to be used for construction of Selection kNN-graph.

batch

Name of the field in colData(sce) specifying batch. Default batch=NULL if no batch is applied.

n.neigh

Positive integer > 1 specifying number of neighbors to use for kNN-graph. Default n.neigh=5.

nPC.all

Scalar specifying number of PCs to use for construction of True kNN-graph (or NULL, if no PCA to be applied). Default nPC.all=50.

nPC.selection

Scalar specifying number of PCs to use for construction of True kNN-graph (or NULL, if no PCA to be applied). Default nPC.selection=NULL (no PCA to be applied). We advise to set it to 50 if length(genes.selection) > 50.

option

String specifying how average distance for each cell should be calculated. If == 'exact', all other cells in the batch are taken into account. If == 'approx', the random subset of 10% of the cells will be used. 'exact' is default, but 'approx' is faster and is recommended for big data sets.

...

Additional arguments

Value

data.frame, each row corresponds to cell from counts matrix, contains field cell_score = cell neighborhood preservation score

Examples

require(SingleCellExperiment)
n_row = 1000
n_col = 100
sce = SingleCellExperiment(assays = list(logcounts = matrix(rnorm(n_row*n_col), ncol=n_col)))
rownames(sce) = as.factor(1:n_row)
colnames(sce) = c(1:n_col)
sce$cell = colnames(sce)
genes.selection = sample(rownames(sce) , 20)
out = get_neighborhood_preservation_scores(sce, genes.selection = genes.selection)


MarioniLab/geneBasisR documentation built on June 30, 2023, 2:04 p.m.