pycallingcards.tools.rank_peak_groups#

pycallingcards.tools.rank_peak_groups(adata_cc, groupby, groups='all', reference=None, n_peaks=None, key_added=None, copy=False, rankby='pvalues_adj', method='fisher_exact', alternative='None', by='None')[source]#

Rank peaks for characterizing groups.

Parameters:
  • adata_cc (AnnData) – Annotated data matrix.

  • groupby (str) – The key of the groups.

  • 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. The 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_adj')) – 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 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')) – 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. It’s 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
>>> adata_cc = cc.datasets.mousecortex_data(data="CC")
>>> cc.tl.rank_peak_groups(adata_cc,'cluster',method = 'binomtest',key_added = 'binomtest')