rnalysis.enrichment.RankedSet.non_categorical_enrichmentļƒ

RankedSet.non_categorical_enrichment(background_genes: Set[str] | Filter | FeatureSet, attributes: List[str] | str | List[int] | int | Literal['all'], alpha: Fraction = 0.05, parametric_test: bool = False, attr_ref_path: str | Path | Literal['predefined'] = 'predefined', plot_log_scale: bool = True, plot_style: Literal['interleaved', 'overlap'] = 'overlap', n_bins: PositiveInt = 50, save_csv: bool = False, fname=None, return_fig: bool = False, gui_mode: bool = False) DataFrame | Tuple[DataFrame, List[Figure]]ļƒ

Calculates enrichment and depletion of the FeatureSet for user-defined non-categorical attributes against a background set using either a one-sample T-test or Sign test. The attributes are drawn from an Attribute Reference Table. The background set is determined by either the input variable ā€˜background_genesā€™, or by the input variable ā€˜biotypeā€™ and a Biotype Reference Table. P-values are corrected for multiple comparisons using the Benjaminiā€“Hochberg step-up procedure (original FDR method).

Parameters:
  • attributes (str, int, iterable (list, tuple, set, etc) of str/int, or 'all'.) ā€“ An iterable of attribute names or attribute numbers (according to their order in the Attribute Reference Table). If ā€˜allā€™, all of the attributes in the Attribute Reference Table will be used. If None, a manual input prompt will be raised.

  • alpha (float between 0 and 1 (default=0.05)) ā€“ Indicates the FDR threshold for significance.

  • parametric_test (bool (default=False)) ā€“ if True, performs a parametric statistical test (one-sample t-test). If False (default), performs a non-parametric statistical test (sign test).

  • background_genes (set of feature indices, filtering.Filter object, or enrichment.FeatureSet object) ā€“ a set of specific feature indices to be used as background genes.

  • attr_ref_path (str or pathlib.Path (default='predefined')) ā€“ the path of the Attribute Reference Table from which user-defined attributes will be drawn.

  • plot_log_scale (bool (default=True)) ā€“ if True (default), the Y-axis of the enrichment plot will be logarithmic. Otherwise, the Y-axis of the enrichment plot will be linear.

  • plot_style ('overlap' or 'interleaved' (default='overlap')) ā€“ ā€˜interleavedā€™ will plot an interleaved histogram. ā€˜overlapā€™ will plot a semi-transparent histogram where the obsreved and expected are overlapping.

  • n_bins (int larger than 0 (default=50)) ā€“ the number of bins to display in the enrichment plot histograms

  • save_csv (bool (default=False)) ā€“ If True, will save the results to a .csv file, under the name specified in ā€˜fnameā€™.

  • fname (str or pathlib.Path (default=None)) ā€“ The full path and name of the file to which to save the results. For example: ā€˜C:/dir/fileā€™. No ā€˜.csvā€™ suffix is required. If None (default), fname will be requested in a manual prompt.

  • return_fig (bool (default=False)) ā€“ if True, returns a matplotlib Figure object in addition to the results DataFrame.

Return type:

pl.DataFrame (default) or Tuple[pl.DataFrame, matplotlib.figure.Figure]

Returns:

a pandas DataFrame with the indicated attribute names as rows/index; and a matplotlib Figure, if ā€˜return_figureā€™ is set to True.

_images/hist_overlap.png

Example plot of non_categorical_enrichment(plot_style`=ā€™overlapā€™)ļƒ

_images/hist_interleaved.png

Example plot of non_categorical_enrichment(plot_style=ā€™interleavedā€™)ļƒ