pyucell.get_rankings#
- pyucell.get_rankings(data, layer=None, max_rank=1500, ties_method='average', device='cpu')#
Compute per-cell ranks of genes for an AnnData object.
- Parameters:
data (AnnData | np.ndarray | sparse matrix) – Either an AnnData object (cells x genes) or directly a 2D matrix.
layer (str, optional) – Only used if input is AnnData. Which layer to use (None = adata.X).
max_rank (int, optional) – Cap ranks at this value (ranks > max_rank are dropped for sparsity).
ties_method (str, optional) – Passed to scipy.stats.rankdata on the CPU path. The torch backend (
device != None) only supports"min"and"ordinal".device (str | None, optional) –
"cpu"orNone(default): CPU path with joblib parallelism (avoids PyTorch)."cuda"/"mps"/"auto": PyTorch backend for hardware acceleration. Requires thepyucell[gpu]extra.
- Return type:
csr_matrix- Returns:
ranks : csr_matrix of shape (genes, cells) Sparse matrix of ranks.