scviva.tools.vision.rank_genes_groups#
- scviva.tools.vision.rank_genes_groups(adata, groupby, use_raw=True, groups='all', reference='rest', n_genes=None, rankby_abs=False, pts=False, key_added=None, copy=False, method='wilcoxon', corr_method='benjamini-hochberg', tie_correct=False, layer=None, **kwds)[source]#
Rank genes for characterizing groups.
Expects logarithmized data.
- Parameters:
- adata
AnnData Annotated data matrix.
- groupby
str The key of the observations grouping to consider.
- use_raw
bool Use
rawattribute ofadataif present.- layer
str|None Key from
adata.layerswhose value will be used to perform tests on.- groups
Union[Literal['all'],Iterable[str]] Subset of groups, e.g. [
'g1','g2','g3'], to which comparison shall be restricted, or'all'(default), for all groups.- reference
str If
'rest', compare each group to the union of the rest of the group. If a group identifier, compare with respect to this group.- n_genes
int|None The number of genes that appear in the returned tables. Defaults to all genes.
- method
Optional[Literal['wilcoxon']] Statistical test. Only
'wilcoxon'(Wilcoxon rank-sum) is supported;Nonealso selects it. Any other value raises aValueError.- corr_method
Literal['benjamini-hochberg','bonferroni'] p-value correction method.
- tie_correct
bool Use tie correction for
'wilcoxon'scores. Used only for'wilcoxon'.- rankby_abs
bool Rank genes by the absolute value of the score, not by the score. The returned scores are never the absolute values.
- pts
bool Compute the fraction of cells expressing the genes.
- key_added
str|None The key in
adata.unsinformation is saved to.- copy
bool If
True, operate on and return a copy ofadata; otherwise modifyadatain place and returnNone.- **kwds
Accepted for compatibility with scanpy’s signature. The legacy
only_positivekey is honoured (as the inverse ofrankby_abs); other keys are ignored by the Wilcoxon test. For instance, you can passpenalty='l1'to try to come up with a minimal set of genes that are good predictors (sparse solution meaning few non-zero fitted coefficients).
- adata
- Return type:
- Returns:
- namesstructured
np.ndarray(.uns['rank_genes_groups']) Structured array to be indexed by group id storing the gene names. Ordered according to scores.
- scoresstructured
np.ndarray(.uns['rank_genes_groups']) Structured array to be indexed by group id storing the z-score underlying the computation of a p-value for each gene for each group. Ordered according to scores.
- logfoldchangesstructured
np.ndarray(.uns['rank_genes_groups']) Structured array to be indexed by group id storing the log2 fold change for each gene for each group. Ordered according to scores. Only provided if method is ‘t-test’ like. Note: this is an approximation calculated from mean-log values.
- pvalsstructured
np.ndarray(.uns['rank_genes_groups']) p-values.
- pvals_adjstructured
np.ndarray(.uns['rank_genes_groups']) Corrected p-values.
- pts
pandas.DataFrame(.uns['rank_genes_groups']) Fraction of cells expressing the genes for each group.
- pts_rest
pandas.DataFrame(.uns['rank_genes_groups']) Only if
referenceis set to'rest'. Fraction of cells from the union of the rest of each group expressing the genes.
- namesstructured
Notes
There are slight inconsistencies depending on whether sparse or dense data are passed. See here.