Skip to content

Inference #1

Open
Open

Description

@raphaelmourad

Thanks for the work!

How can I use your model finetuned on tahoe for instance to predict the gene expression matrix of cells perturbed by a drug given my own gene expression matrix of control cells? That would a very useful notebook to have :).
Raf

Activity

  1. KatarinaYuan commented on Mar 16, 2026

    @KatarinaYuan
    Collaborator

    Hi,
    Thanks for the great suggestion! We haven't tested this "one data to another data" finetuning transfer before.
    One naive way is to directly load the pretrained tahoe ckpt via model.ckpt_path=/path/to/ckpt, but it might require some minor fixed if the metadata vocabulary (e.g., drugs, cell lines) of your data does not match that of Tahoe100M.

    Another important thing is that diffusion framework needs early stopping even for training from scratch on one dataset. Finetuning might face similar issues.

    Which dataset (if it's public) you use? I can try to create some small demo for it.

  2. raphaelmourad commented on Mar 19, 2026

    @raphaelmourad
    Author

    Hi Katarina,
    I do believe if you implement this predictions it would be very valuable as Stack did (they predicted all perturbed data from unperturbed data from tabula sapiens). At the end they got all drug induced perturbed data for all cells from tabula sapiens. What would be awesome would be to make a script to predict any perturbation in tahoe (a given drug at a given perturbation) on unperturbed data from tabula sapiens. For instance, you can take skin data such as : https://datasets.cellxgene.cziscience.com/88930108-9c98-43a7-826d-ce454dd0c930.h5ad
    Here the idea is to not make any finetuning. Just take your a model trained on tahoe and take as input an unperturbed data and predict a perturbed data as state and stack do.
    I can assure you that many people would want to use this script !!
    Raf

  3. KatarinaYuan commented on Apr 7, 2026

    @KatarinaYuan
    Collaborator

    Hi,
    Sorry for the late response (too busy last few weeks). Let me look into this.

  4. KatarinaYuan commented on Aug 23, 2026

    @KatarinaYuan
    Collaborator

    Thanks for the suggestion! We have added an experimental inference-only API and a Colab-style notebook for this use case.

    The new notebook is here:

    examples/inference_only_tahoe_issue1_demo.ipynb

    It demonstrates how to use the Tahoe-finetuned checkpoint to take control cells from an .h5ad file, align them to the Tahoe checkpoint gene space,
    specify a supported Tahoe drug condition, and write the predicted expression matrix as a new .h5ad.

    The corresponding CLI is:

    python ./src/apps/run/predict_h5ad.py \
      --checkpoint finetuned_tahoe100m.ckpt \
      --selected-gene-file tahoe100m_real_selected_genes.pkl \
      --input-h5ad control_cells.h5ad \
      --output-h5ad predicted_cells.h5ad \
      --perturbation "[('Dexamethasone', 0.5, 'uM')]" \
      --cell-type oocyte \
      --gene-column feature_name \
      --batch-size 128 \
      --start-time 100

    A few important caveats:

    • the Tahoe checkpoint is a drug-perturbation checkpoint, so the requested perturbation must exist in the Tahoe drug-condition vocabulary;
    • the input .h5ad genes are aligned to the checkpoint selected-gene file;
    • the cell type must exist in the checkpoint cell-type vocabulary;
    • this is inference-only and does not require paired perturbed cells;
    • for novel .h5ad inputs, the result should be treated as out-of-distribution inference rather than a validated benchmark setting.

    The notebook also includes a small sanity-metric section. Since the public demo .h5ad does not include true perturbed ground truth, that section uses the input control cells as a placeholder target only to show how the metrics code works. If users have a real perturbed ground-truth .h5ad, they can replace the placeholder truth matrix with the aligned ground-truth matrix to compute pred-vs-truth R², MSE, MAE, Pearson correlation, and MMD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions