StoreRankings_UCell: Calculate and store gene rankings for a single-cell dataset

View source: R/StoreRankings_UCell.R

StoreRankings_UCellR Documentation

Calculate and store gene rankings for a single-cell dataset

Description

Given a gene vs. cell matrix, calculates the rankings of expression for all genes in each cell.

Usage

StoreRankings_UCell(
  matrix,
  maxRank = 1500,
  chunk.size = 100,
  BPPARAM = NULL,
  ncores = 1,
  assay = "counts",
  ties.method = "average",
  force.gc = FALSE
)

Arguments

matrix

Input matrix, either stored in a SingleCellExperiment object or as a raw matrix. dgCMatrix format supported.

maxRank

Maximum number of genes to rank per cell; above this rank, a given gene is considered as not expressed

chunk.size

Number of cells to be processed simultaneously (lower size requires slightly more computation but reduces memory demands)

BPPARAM

A BiocParallel::bpparam() object that tells UCell how to parallelize. If provided, it overrides the ncores parameter.

ncores

Number of processors to parallelize computation. If BPPARAM = NULL, the function uses BiocParallel::MulticoreParam(workers=ncores)

assay

Assay where the data is to be found (for input in 'sce' format)

ties.method

How ranking ties should be resolved - passed on to data.table::frank

force.gc

Explicitly call garbage collector to reduce memory footprint

Details

While ScoreSignatures_UCell can be used 'on the fly' to evaluate signatures in a query dataset, it requires recalculating gene ranks at every execution. If you have a large dataset and plan to experiment with multiple signatures, evaluating the same dataset multiple times, this function allows you to store pre-calculated ranks so they do not have to be recomputed every time. Pre-calculated ranks can then be applied to the function ScoreSignatures_UCell to evaluate gene signatures in a significantly faster way on successive iterations.

Value

Returns a sparse matrix of pre-calculated ranks that can be used multiple times to evaluate different signatures

Examples

library(UCell)
data(sample.matrix)
ranks <- StoreRankings_UCell(sample.matrix)
ranks[1:5,1:5]
gene.sets <- list( Tcell_signature = c("CD2","CD3E","CD3D"),
                 Myeloid_signature = c("SPI1","FCER1G","CSF1R"))
scores <- ScoreSignatures_UCell(features=gene.sets, precalc.ranks=ranks)
head(scores)

carmonalab/UCell documentation built on April 26, 2024, 11:51 p.m.