Communitygithub.com

deepspot-m

從H&E組織學生成全轉錄組虛擬空間轉錄組學資料,使用DeepSpot-M。需要在約20倍放大倍率下,針對224x224圖塊查詢log1p-CPM格式的蛋白質編碼基因空間表現時使用。

deepspot-m 是什麼?

DeepSpot-M 是一個多模態基礎模型,能將 224x224 像素的 H&E 組織學圖塊對應到 log1p-CPM 格式的空間基因表現,輸出虛擬空間轉錄組學資料。它採用 LoRA 適配的病理學基礎骨幹(Midnight)進行圖塊標記化,並透過交叉注意力基因解碼器,讓每個基因查詢可關注圖塊標記。獨特的基因路由器超網路能從冷凍生物嵌入(如 Evo 2、Orthrus、ProtT5、scGPT、Apertus)建立基因特定投影,支援約 19,000 個蛋白質編碼基因的查詢,包括訓練中未見過的基因。該模型支援 Python 3.10 至 3.13,需要透過 Hugging Face 門控存取權重,並可與 histolab 搭配進行全切片工作流程。主要適用於非商業研究,可建立空間表現圖譜、分析標記基因、或對無對應檢測的切片隊列進行全轉錄組預測。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/deepspot-m

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

deepspot-m 是做什麼的?

概述

DeepSpot-M 是一個多模態基礎模型,能將 224x224 的 H&E 組織學圖塊對應到 log1p-CPM 格式的空間基因表現。輸出為虛擬空間轉錄組學:每個查詢基因在每個圖塊上有一個值,並依圖塊來源的網格排列。

一個 LoRA 適配的病理學基礎骨幹(Midnight)將圖塊標記化。一個交叉注意力基因解碼器讓每個基因查詢關注圖塊標記,而一個基因路由器超網路則從冷凍生物嵌入(Evo 2、Orthrus、ProtT5、scGPT、Apertus)建立基因特定投影。基因以可查詢的嵌入形式而非固定輸出槽進入模型,因此釋出的模型涵蓋約 19,000 個蛋白質編碼基因面板,包括訓練中未見過的基因。該面板以 tokens.csv 形式隨權重提供,並透過 model.gene_names 公開;此版本無法查詢面板以外的基因。

應用於 TCGA 後,該模型產生了涵蓋 32 種癌症類型、共 28,664 張切片的虛擬空間轉錄組學圖譜。

授權

程式碼採用 PolyForm Noncommercial 1.0.0 授權,權重採用 CC-BY-NC-SA-4.0 授權。僅限非商業研究使用,並在重新發布輸出前檢查這兩個授權條款。

安裝

uv pip install deepspotm==1.0.0

1.0.0 版本支援 Python 3.10 至 3.13,並會拉取 PyTorch。如果需要 GPU 推理,請先安裝與您 CUDA 版本匹配的 PyTorch 建置版本。

模型存取

權重為門控存取:

  1. 開啟 https://huggingface.co/ratschlab/DeepSpotM 並請求存取權限。
  2. 獲得存取權後,驗證將下載權重的機器:
huggingface-cli login

from_pretrained 會讀取該快取令牌,因此每台機器只需登入一次。

快速開始

from deepspotm import DeepSpotM

model, image_processor = DeepSpotM.from_pretrained("ratschlab/DeepSpotM", source="scgpt")

vals = model.predict_genes(image_processor(pil_tile).unsqueeze(0), ["EPCAM", "CD3D"])

pil_tile 是一個精確 224x224 像素的 PIL 圖片。image_processor 將其轉換為張量,unsqueeze(0) 增加批次維度,predict_genes 接受批次和一個 HGNC 基因符號列表。回傳值為 log1p-CPM 格式,與您傳入的基因列表對齊,因此請將該列表與輸出一起保存,以保持欄位標記。基因符號必須在釋出的約 19,000 個基因面板(model.gene_names)中;未知的符號會引發 KeyError,並指出有問題的基因。

圖塊要求

圖塊必須是 224x224 RGB,放大倍率約為 20 倍(約每像素 0.5 微米)。在管線邊界處檢查尺寸,而不是傳遞未經檢查的裁切:

TILE_PX = 224

def require_tile(tile):
    """回傳一個 RGB 224x224 圖塊,如果裁切尺寸錯誤則引發錯誤。"""
    if tile.size != (TILE_PX, TILE_PX):
        raise ValueError(
            f"DeepSpot-M 需要一個約 20 倍放大倍率(~0.5 微米/像素)的 {TILE_PX}x{TILE_PX} 圖塊;"
            f"收到 {tile.size[0]}x{tile.size[1]}。"
            "請在匹配的層級重新切割圖塊,或重新取樣裁切。"
        )
    return tile.convert("RGB")

在切片層級提取解析度最接近每像素 0.5 微米的圖塊,然後在該處裁切為 224x224。從較粗糙的層級重新取樣會改變骨幹讀取的紋理。

保持依賴為可選

deepspotm 及其權重是一個龐大且門控的依賴項。在需要它的函式內部進行匯入,以便周圍專案在沒有它的情況下仍能安裝、匯入和測試,並將 ImportError 轉換為一個說明每個步驟的訊息:

DEEPSPOTM_HELP = (
    "DeepSpot-M 不可用。請使用 `uv pip install deepspotm==1.0.0` 安裝,"
    "在 https://huggingface.co/ratschlab/DeepSpotM 請求門控權重的存取權限,"
    "然後使用 `huggingface-cli login` 進行驗證。"
)

def load_deepspotm(source="scgpt"):
    try:
        from deepspotm import DeepSpotM
    except ImportError as exc:
        raise RuntimeError(DEEPSPOTM_HELP) from exc
    return DeepSpotM.from_pretrained("ratschlab/DeepSpotM", source=source)

嵌入來源

source 選項選擇路由器從哪個冷凍基因嵌入建立投影。共有五個選項:

source基因嵌入
evo2基因組序列
orthrusRNA
prott5蛋白質序列
scgpt單細胞表現
apertus語言模型

每個嵌入提供不同的基因身份視角。每次執行選擇一個,並在選擇對分析重要時,使用多個來源對相同圖塊執行。請參閱 references/api.md 了解完整的呼叫介面、批次處理、設備放置、基因符號處理和輸出單位。

全切片工作流程

預測是按圖塊進行的,因此切片規模的執行是先切割圖塊,再進行批次推理:

  1. 使用 histolab 技能在網格上提取 224x224 圖塊,並記錄每個圖塊的座標。
  2. 使用 torch.stack 處理並將圖塊堆疊成批次。
  3. 對每個批次使用相同的基因列表呼叫 predict_genes。
  4. 將批次串聯成一個圖塊×基因的矩陣,並附加座標。

該矩陣即為該切片的虛擬空間轉錄組學地圖,可直接匯入 AnnData 進行後續空間分析。references/whole_slide.md 中提供了完整的迴圈、批次大小設定和 AnnData 組裝步驟。

常見使用案例

  • 腫瘤切片標記基因的空間表現地圖。
  • 對無匹配檢測的切片隊列進行全轉錄組預測。
  • 按符號查詢約 19,000 個基因面板中的任何基因,包括訓練中未見過的基因——遠超過典型空間檢測面板的數百個基因。
  • 為僅基於型態學的組織學管線添加表現通道。
  • 建立切片層級的隊列圖譜,如 TCGA 所做。

詳細參考資料

  • references/api.md:from_pretrained 和 predict_genes 的完整說明、五種嵌入來源及其選擇方式、批次處理、設備放置、基因符號處理,以及轉換 log1p-CPM 輸出。
  • references/whole_slide.md:使用 histolab 進行圖塊切割、切片規模的預測迴圈、組裝和儲存圖塊×基因矩陣,以及隊列規模的執行。

主要來源

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

adaptyv

How to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.

aeon

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

alphagenome

Look up precomputed AlphaGenome Atlas effects for any GRCh38 single-nucleotide variant (AVI score with Phred and 18 SHAP feature attributions, plus raw and quantile scores for RNA-seq, DNase, ATAC, ChIP-TF, ChIP-histone, CAGE, PRO-cap, splicing, polyadenylation and contact-map tracks), score variants or scan windows on demand with the AlphaGenome model for human and mouse (variant scoring, in silico mutagenesis, REF-versus-ALT track prediction), and build Atlas website deep links. Use when the user mentions AlphaGenome, AlphaGenome Atlas, AVI or AlphaGenome Variant Impact, DeepMind variant effect prediction, or wants to prioritise or mechanistically interpret non-coding, regulatory, splicing, enhancer, promoter, or chromatin-accessibility effects of SNVs from a VCF, credible set, or region. Research use only; not a clinical tool.

analytical-method-validation

Plan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include

anndata

Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.

arbor

Autonomously improve a real artifact (code, training recipe, agent harness, data pipeline, prompt) against an objective and an evaluator, using Hypothesis Tree Refinement (HTR) from the Arbor paper. Use this whenever someone wants to iteratively optimize something over many experiments without overfitting — e.g.

arboreto

Infer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.

astropy

Core Python library for astronomy and astrophysics workflows that need Astropy APIs, including units/quantities, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use when implementing or debugging astronomical data analysis code with Astropy.

autoskill

Observe the user

benchling-integration

Benchling Python SDK and REST API integration for registry entities, inventory, ELN entries, workflows, Benchling Apps, and Data Warehouse queries. Use when automating lab data with benchling-sdk or the v2 API.

bgpt-paper-search

Search scientific papers and retrieve structured experimental data extracted from full-text studies via the BGPT MCP server. Returns 25+ fields per paper including methods, results, sample sizes, quality scores, and conclusions. Use for literature reviews, evidence synthesis, and finding experimental details not available in abstracts alone.

bids

>

biopython

Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.

bioservices

Unified Python interface to 40+ bioinformatics services. Use when querying multiple databases (UniProt, KEGG, ChEMBL, Reactome) in a single workflow with consistent API. Best for cross-database analysis, ID mapping across services. For quick single-database lookups use gget; for sequence/file manipulation use biopython.

bulk-rnaseq

End-to-end bulk RNA-seq orchestrator — takes raw FASTQ reads through QC and trimming (FastQC, fastp/Trim Galore), alignment and quantification (STAR, Salmon, featureCounts), assembles a gene-level counts matrix, then hands off to differential expression (pydeseq2), pathway/GSEA enrichment (pathway-enrichment), and publication figures (scientific-visualization). Use whenever the user has bulk RNA-seq reads or quant output and wants a complete, reproducible differential-expression workflow — e.g.

cellxgene-census

Query the CZ CELLxGENE Census programmatically for versioned public single-cell and spatial transcriptomics data. Use when you need population-scale cell metadata, gene expression slices, Census summary counts, source H5AD URIs/downloads, embeddings, spatial Census data, or reference atlas comparisons across organisms, tissues, diseases, assays, and cell types. For analyzing your own local single-cell data use scanpy, anndata, or scvi-tools.

cirq

Google quantum computing framework. Use when targeting Google Quantum AI hardware, designing noise-aware circuits, or running quantum characterization experiments. Best for Google hardware, noise modeling, and low-level circuit design. For IBM hardware use qiskit; for quantum ML with autodiff use pennylane; for physics simulations use qutip.

citation-management

Comprehensive citation management for academic research. Search OpenAlex, PubMed, and Google Scholar for papers, extract accurate metadata, validate citations, and generate properly formatted BibTeX entries. This skill should be used when you need to find papers, verify citation information, convert DOIs to BibTeX, or ensure reference accuracy in scientific writing.

clinical-decision-support

Prepare and validate research-only clinical decision-support evaluation, evidence-profile, cohort, survival, biomarker/model, privacy, and governance artifacts. Use for aggregate or synthetic research documentation and traceability—not patient care or live clinical operation.

clinical-reports

Create safety-bounded draft structures and run local deterministic checks for clinical case, diagnostic, trial, safety, and aggregate research reports. Use only with synthetic, de-identified, or aggregate inputs and verified source-fact manifests; every output requires qualified review.

相關技能