opendvp.tl.scimap_phenotype

opendvp.tl.scimap_phenotype#

scimap_phenotype(adata, phenotype, gate=0.5, label='phenotype', imageid='imageid', pheno_threshold_percent=None, pheno_threshold_abs=None, verbose=True)#

Annotate each cell with a phenotype based on scaled data and a phenotype workflow.

Parameters:
  • adata (anndata.AnnData) – The input AnnData object containing single-cell data for phenotyping.

  • phenotype (pandas.DataFrame) – A DataFrame specifying the gating strategy for cell phenotyping. It should outline the workflow for phenotype classification based on marker expression levels. See an example workflow.

  • gate (float, default 0.5) – The threshold value for determining positive cell classification based on scaled data. By convention, values above this threshold indicate positive cells.

  • label (str, default 'phenotype') – The name of the column in adata.obs where the final phenotype classifications will be stored.

  • imageid (str, default 'imageid') – The name of the column in adata.obs that contains unique image identifiers. This is crucial for analyses that require differentiation of data based on the source image, especially when using pheno_threshold_percent or pheno_threshold_abs.

  • pheno_threshold_percent (float, optional) – A threshold value (between 0 and 100) specifying the minimum percentage of cells that must exhibit a particular phenotype for it to be considered valid. Phenotypes not meeting this threshold are reclassified as ‘unknown’. Useful for minimizing the impact of low-frequency false positives.

  • pheno_threshold_abs (int, optional) – Similar to pheno_threshold_percent, but uses an absolute cell count instead of a percentage. Phenotypes with cell counts below this threshold are reclassified as ‘unknown’. This can help address rare phenotype classifications that may not be meaningful.

  • verbose (bool, default True) – If True, print detailed messages about progress and the steps being executed.

Returns:

The input AnnData object, updated to include the phenotype classifications for each cell. The phenotyping results can be found in adata.obs[label], where label is the name specified by the user for the phenotype column.

Return type:

anndata.AnnData

Examples

# Load the phenotype workflow CSV file
phenotype = pd.read_csv("path/to/csv/file/")

# Apply phenotyping to cells based on the specified workflow
adata = dvp.tl.scimap_phenotype(adata, phenotype=phenotype, gate=0.5, label="phenotype")