pycallingcards.tools.rank_peak_groups_mu#
- pycallingcards.tools.rank_peak_groups_mu(mdata, groupby, adata_cc='CC', groups='all', reference=None, n_peaks=None, key_added=None, copy=False, rankby='pvalues', method='fisher_exact', alternative='None')[source]#
Rank peaks for characterizing groups. Designed for mudata object.
- Parameters:
mdata (
MuData
) – mdata for both RNA and CC data.groupby (
str
) – The key of the groups.adata_cc (
str
(default:'CC'
)) – Name for Anndata of CC. Anndata is mdata[adata_cc].groups (
Union
[Literal
['all'
],Iterable
[str
]] (default:'all'
)) – Subset of groups (list), e.g. [‘g1’, ‘g2’, ‘g3’], to which comparison shall be restricted, or all (default), for all groups.reference (
Optional
[str
] (default:None
)) – 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_peaks (
Optional
[int
] (default:None
)) – The number of peaks that appear in the returned tables. Default includes all peaks.key_added (
Optional
[str
] (default:None
)) – The key in adata.uns information is saved to.rankby (
Optional
[Literal
['pvalues'
,'logfoldchanges'
,'pvalues_adj'
]] (default:'pvalues'
)) – [‘pvalues’, ‘logfoldchanges’]. The list we rank by.copy (
bool
(default:False
)) – If copy, it will return a copy of the AnnData object and leave the passed adata unchanged.method (
Optional
[Literal
['binomtest'
,'binomtest2'
,'fisher_exact'
]] (default:'fisher_exact'
)) – [“binomtest”, “binomtest2”,”fisher_exact”]. binomtest uses binomial test, binomtest2 uses binomial test but stands on a different hypothesis of binomtest, fisher_exact uses fisher exact test.alternative (
Optional
[Literal
['two-sided'
,'greater'
,'None'
]] (default:'None'
)) – [‘two-sided’, ‘greater’,’None’]. If it has two samples/cluster, ‘two-sided’ is recommended. Otherwise, please use ‘greater’. For default (‘None’), if groupby == “Index”, it will be ‘two-sided’. Otherwise, please use ‘greater’.
- Returns:
- names - structured np.ndarray (.uns[‘rank_peaks_groups’]). Structured array is to be indexed by the group ID storing the peak names. Ordered according to scores.return pvalues - structured np.ndarray (.uns[‘rank_peaks_groups’])return logfoldchanges - structured np.ndarray (.uns[‘rank_peaks_groups’])number - pandas.DataFrame (.uns[‘rank_peaks_groups’]). The number of peaks or the number of cells that contain peaks (depending on the method).number_rest - pandas.DataFrame (.uns[‘rank_peaks_groups’]). The number of peaks or the number of cells that contain peaks (depending on the method).
- Return type:
Optional
[AnnData
] | total - pandas.DataFrame (.uns[‘rank_peaks_groups’]). The total number of cells that contain peaks. | total_rest - pandas.DataFrame (.uns[‘rank_peaks_groups’]). The total number of cells that contain peaks.- Example:
>>> import pycallingcards as cc >>> mdata = cc.datasets.mousecortex_data(data="Mudata") >>> cc.tl.rank_peak_groups_mu(mdata,"RNA:cluster",method = 'binomtest',key_added = 'binomtest')