tirank.Imageprocessing.GetPathoClass

tirank.Imageprocessing.GetPathoClass(adata, pretrain_path, n_components=50, n_clusters=6, plot_classes=True, image_save_path=None)[source]

Orchestrates the full image processing pipeline.

Crops tiles, generates embeddings using CTransPath, performs PCA and K-means, and adds the results to the AnnData object.

Parameters:
  • adata (anndata.AnnData) – The AnnData object for an ST sample.

  • pretrain_path (str) – Path to the CTransPath model’s .pth weights file.

  • n_components (int, optional) – Number of PCA components. Defaults to 50.

  • n_clusters (int, optional) – Number of K-means clusters. Defaults to 6.

  • plot_classes (bool, optional) – Whether to generate and save the spatial heatmap. Defaults to True.

  • image_save_path (str, optional) – File path to save the heatmap. Required if plot_classes is True. Defaults to None.

Returns:

The AnnData object, modified in place with:
  • adata.obs[“patho_class”]: Cluster labels for each spot.

  • adata.obsm[“patho_emd”]: PCA embeddings for each spot.

Return type:

anndata.AnnData