thor.analy.get_pathway_score

thor.analy.get_pathway_score(adata: AnnData, layer: str | None = None, net_df: DataFrame | None = None, smooth_radius: float | None = 200) AnnData[source]

Calculate pathway score for each cell using over-representation analysis.

Parameters:
  • adata (anndata.AnnData) – Annotated data matrix

  • layer (str, optional) – Layer to use for the calculation

  • net_df (pandas.DataFrame, optional) – DataFrame with the network information. It should contain the following columns: - geneset: name of the geneset - genesymbol: name of the gene - weight: weight of the gene in the geneset (optional)

  • smooth_radius (float, optional) – Radius for the smoothing. Default is 200.

Returns:

Annotated data matrix with the pathway as the var_names and the pathway score as the X

Return type:

anndata.AnnData

Notes

This function calculates the pathway score for each cell using over-representation analysis. It uses the dc.run_ora function to perform the analysis and stores the results in the adata.obsm attribute. The pathway score is stored in the adata.X attribute and the pathway names are stored in the adata.var_names attribute.

Examples

>>> import pandas as pd
>>> import scanpy as sc
>>> import anndata as ad
>>> from thor.analysis import get_pathway_score
>>> adata = sc.datasets.pbmc3k_processed()
>>> net_df = pd.read_csv('path/to/network.csv')
>>> adata = get_pathway_score(adata, layer='counts', net_df=net_df)