mechanochat.preprocessing.filter_db#

mechanochat.preprocessing.filter_db(df: DataFrame, adata: AnnData, filter_criteria: Literal['min_cell_pct', 'min_cell'] = 'min_cell_pct', min_cell: int = 100, min_cell_pct: float = 0.05, alias_col: str | None = None) → DataFrame[source]#

Filter the MechanoChat database by gene detection in the data.

Parameters:
  • df (pandas.DataFrame) – A database whose first column holds gene symbols, e.g. df_stiffness or df_IonTF returned by load_mechano_db. For ligand-receptor tables use filter_lr_database instead.

  • adata (Anndata) – The AnnData object of gene expression. Unscaled data (minimum being zero) is expected.

  • filter_criteria (str) – Use either cell percentage (‘min_cell_pct’) or cell numbers (min_cell) to filter genes.

  • min_cell (int) – If filter_criteria is ‘min_cell’, the genes detected in greater than or equal to min_cell cells are kept.

  • min_cell_pct (float) – If filter_criteria is ‘min_cell_pct’, the genes detected in greater than or equal to min_cell_pct percentage of cells are kepts.

  • alias_col (str, optional) – column name for alias in df. Use “Alias” for df_IonTF. df_stiffness does not have alias column.

Returns:

df_filtered (pd.DataFrame) – A DataFrame of the filtered genes, with the index reset.

Columns: ‘Symbol’, ‘Type’, ‘Evidence’