| license: cc-by-nc-sa-4.0 | |
| pretty_name: Pathomics | |
| # task_categories: | |
| # - feature-extraction | |
| # - image-classification | |
| # tags: | |
| # - pathology | |
| # - computational-pathology | |
| # - spatial-transcriptomics | |
| # - whole-slide-images | |
| # - multimodal | |
| # - foundation-model | |
| # language: | |
| # - en | |
| # size_categories: | |
| # - 1K<n<10K | |
| # --- | |
| # # Pathomics | |
| # Pathomics is a large-scale multimodal pathology dataset integrating: | |
| # - Whole-slide pathology images (WSIs) | |
| # - Spatial transcriptomics (ST) | |
| # - Tissue metadata | |
| # - Visualization assets | |
| # - Foundation-model-ready preprocessing outputs | |
| # The dataset extends the original HEST dataset with: | |
| # - CellViT-based nuclei segmentation | |
| # - Additional curated spatial transcriptomics datasets from literature | |
| # - Standardized multimodal organization | |
| # - Unified metadata schema for downstream AI applications | |
| # Pathomics is designed for: | |
| # - Computational pathology | |
| # - Spatial transcriptomics research | |
| # - Vision-language foundation models | |
| # - Cell-level representation learning | |
| # - Multimodal biomedical AI | |
| # --- | |
| # # Relationship with HEST | |
| # Pathomics contains two types of samples: | |
| # | source | Description | | |
| # |---|---| | |
| # | `hest` | Samples originating from the original HEST dataset | | |
| # | `literature` | Additional curated samples processed independently | | |
| # For samples with: | |
| # ```text | |
| # source = hest | |
| # ```` | |
| # the corresponding base HEST data can optionally be downloaded automatically. | |
| # Pathomics stores: | |
| # * Cell segmentation results | |
| # * Additional metadata | |
| # * Standardized file organization | |
| # * Derived multimodal assets | |
| # while HEST provides: | |
| # * Original WSI/ST assets | |
| # * Base preprocessing outputs | |
| # --- | |
| # # Dataset Structure | |
| # The repository is organized by modality/type instead of per-sample folders. | |
| # ```text | |
| # pathomics/ | |
| # ├── metadata/ | |
| # │ └── NCBI689.json | |
| # │ | |
| # ├── st/ | |
| # │ └── NCBI689.h5ad | |
| # │ | |
| # ├── wsis/ | |
| # │ └── NCBI689.tif | |
| # │ | |
| # ├── thumbnails/ | |
| # │ └── NCBI689_downscaled_fullres.jpeg | |
| # │ | |
| # ├── spatial_plots/ | |
| # │ └── NCBI689_spatial_plots.png | |
| # │ | |
| # ├── cellvit_seg_for_superfocus/ | |
| # │ └── NCBI689/ | |
| # │ └── ... | |
| # │ | |
| # ├── PATHOMICS_v3_0_0.csv | |
| # │ | |
| # └── README.md | |
| # ``` | |
| # --- | |
| # # File Descriptions | |
| # | Directory | Description | | |
| # | ----------------------------- | ---------------------------------------------- | | |
| # | `metadata/` | JSON metadata for each sample | | |
| # | `st/` | Spatial transcriptomics AnnData (`.h5ad`) | | |
| # | `wsis/` | Whole-slide pathology images | | |
| # | `thumbnails/` | Downscaled JPEG tissue thumbnails | | |
| # | `spatial_plots/` | Visualization of spatial transcriptomics spots | | |
| # | `cellvit_seg_for_superfocus/` | CellViT segmentation outputs | | |
| # | `PATHOMICS_v3_0_0.csv` | Master metadata table | | |
| # --- | |
| # # Metadata Table | |
| # The file: | |
| # ```text | |
| # PATHOMICS_v3_0_0.csv | |
| # ``` | |
| # contains the master metadata table for all samples. | |
| # Important fields include: | |
| # | Field | Description | | |
| # | ------------------------- | --------------------------------------- | | |
| # | `id` | Unique sample identifier | | |
| # | `source` | `hest` or `literature` | | |
| # | `hest_id` | Original HEST sample ID (if applicable) | | |
| # | `organ` | Tissue/organ source | | |
| # | `species` | Species information | | |
| # | `platform` | Spatial transcriptomics platform | | |
| # | `nb_genes` | Number of genes | | |
| # | `spots_under_tissue` | Number of tissue-covered spots | | |
| # | `pixel_size_um_estimated` | Estimated pixel resolution | | |
| # | `cellvit_seg` | Number of segmented cells | | |
| # | `has_superfocus_seg` | Whether CellViT segmentation exists | | |
| # --- | |
| # # Access Requirements | |
| # To use this dataset, you need access to: | |
| # 1. Pathomics | |
| # 2. HEST (optional but recommended for HEST-derived samples) | |
| # --- | |
| # # Step 1 — Request Access | |
| # ## Pathomics | |
| # Click: | |
| # ```text | |
| # Request Access | |
| # ``` | |
| # at the top of this page. | |
| # --- | |
| # ## HEST | |
| # Request access at: | |
| # [https://huggingface.co/datasets/MahmoodLab/hest](https://huggingface.co/datasets/MahmoodLab/hest) | |
| # Access is automatically granted. | |
| # --- | |
| # # Step 2 — Create a Hugging Face Token | |
| # Create a Hugging Face token at: | |
| # [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) | |
| # Recommended permission: | |
| # * `Write` | |
| # Step 3 — Install Dependencies | |
| ```bash | |
| pip install huggingface-hub pandas | |
| ``` | |
| --- | |
| # Step 4 — Login | |
| ```python | |
| from huggingface_hub import login | |
| login(token="YOUR_HF_TOKEN") | |
| ``` | |
| --- | |
| <!-- # Download API | |
| The following helper script provides a unified interface for downloading: | |
| * Individual samples | |
| * Multiple samples | |
| * Entire dataset | |
| * Specific modalities only | |
| * Optional HEST base data | |
| --> | |
| --- | |
| # Download Script | |
| ```python | |
| from huggingface_hub import snapshot_download | |
| import pandas as pd | |
| import os | |
| def download_pathomics( | |
| ids=None, | |
| pathomics_dir="pathomics_data", | |
| hest_dir="pathomics_data", | |
| ): | |
| # ----------------------------- | |
| # load metadata index | |
| # ----------------------------- | |
| meta = None | |
| csv_files = [f for f in os.listdir(pathomics_dir) | |
| if f.startswith("PATHOMICS_v")] | |
| # print(csv_files) | |
| if len(csv_files) > 0: | |
| csv_path = os.path.join(pathomics_dir, sorted(csv_files)[-1]) | |
| meta = pd.read_csv(csv_path) | |
| if ids is None: | |
| snapshot_download( | |
| repo_id="Boyoungc/pathomics", | |
| allow_patterns="*", | |
| repo_type="dataset", | |
| local_dir=pathomics_dir, | |
| ) | |
| return | |
| # ----------------------------- | |
| # split ids | |
| # ----------------------------- | |
| hest_ids = [] | |
| local_ids = [] | |
| if meta is not None and "source" in meta.columns: | |
| sub = meta[meta["id"].isin(ids)] | |
| hest_ids = sub[sub["source"] == "hest"]["id"].tolist() | |
| local_ids = sub[sub["source"] != "hest"]["id"].tolist() | |
| else: | |
| local_ids = ids | |
| # ========================================================= | |
| # 1. HEST DOWNLOAD (STRICT MODALITY FILTER) | |
| # ========================================================= | |
| if len(hest_ids) > 0: | |
| hest_patterns = [] | |
| for hid in hest_ids: | |
| hest_patterns.extend([ | |
| f"metadata/{hid}.json", | |
| f"st/{hid}.h5ad", | |
| f"wsis/{hid}.tif", | |
| f"thumbnails/{hid}_*", | |
| f"spatial_plots/{hid}_*", | |
| ]) | |
| snapshot_download( | |
| repo_id="MahmoodLab/hest", | |
| allow_patterns=hest_patterns, | |
| repo_type="dataset", | |
| local_dir=hest_dir, | |
| ) | |
| print(f"[HEST] downloaded {len(hest_ids)} samples") | |
| # ========================================================= | |
| # 2. PATHOMICS SEG ONLY for HEST | |
| # ========================================================= | |
| if len(hest_ids) > 0: | |
| seg_patterns = [ | |
| f"cellvit_seg_for_superfocus/{hid}/**" | |
| for hid in hest_ids | |
| ] | |
| snapshot_download( | |
| repo_id="Boyoungc/pathomics", | |
| allow_patterns=seg_patterns, | |
| repo_type="dataset", | |
| local_dir=pathomics_dir, | |
| ) | |
| print(f"[SEG] downloaded HEST segmentations") | |
| # ========================================================= | |
| # 3. PATHOMICS FULL for literature | |
| # ========================================================= | |
| if len(local_ids) > 0: | |
| patterns = [] | |
| for sid in local_ids: | |
| patterns.extend([ | |
| f"metadata/{sid}.json", | |
| f"st/{sid}.h5ad", | |
| f"wsis/{sid}.tif", | |
| f"thumbnails/{sid}_*", | |
| f"spatial_plots/{sid}_*", | |
| f"cellvit_seg_for_superfocus/{sid}/**", | |
| ]) | |
| snapshot_download( | |
| repo_id="Boyoungc/pathomics", | |
| allow_patterns=patterns, | |
| repo_type="dataset", | |
| local_dir=pathomics_dir, | |
| ) | |
| print(f"[PATHOMICS] downloaded literature samples") | |
| ``` | |
| --- | |
| # Usage Examples | |
| ## Download One Sample | |
| ```python | |
| download_pathomics( | |
| ids=["NCBI689"] | |
| ) | |
| ``` | |
| --- | |
| ## Download Multiple Samples | |
| ```python | |
| download_pathomics( | |
| ids=["NCBI689", "MEND62"] | |
| ) | |
| ``` | |
| --- | |
| ## Download Entire Dataset | |
| ```python | |
| download_pathomics() | |
| ``` | |
| --- | |
| ## Download Only ST Data | |
| ```python | |
| download_pathomics( | |
| ids=["NCBI689"], | |
| modalities=["st"] | |
| ) | |
| ``` | |
| --- | |
| <!-- # Acknowledgements | |
| * HEST | |
| * CellViT | |
| * Hugging Face | |
| * Spatial transcriptomics community | |
| * Original data contributors --> | |
| ``` | |
| ``` | |