Skip to content

Tahoe-x1-Tutorial perturbation bug #374

Description

@jameswallacew8

Hello, thank you very much for your work integrating the Tahoe-x1 model into Helical.

I believe there's an issue in the tutorial code at this commented out line which performs a gene-level perturbation on its embedding:
transformer_embs[0][5, :] += np.random.randn(transformer_embs[0].shape[1]) * 0.1

which is then passed to the decoder as follows:

expr_predictions = tahoe.decode_embeddings(transformer_embs, gene_ids)

In my experiments this will only change the resulting predicted expression value of the gene which was perturbed (as opposed to influencing the overall state of gene expression in the cell). I believe this is because tahoe.get_transformer_embeddings(dataloader) has been executed first, hence the gene context has already been 'baked in' and so perturbing the embedding after the fact will not affect the global cell context.

Instead, a gene should be perturbed upstream of the dataset before passing into the dataloader. Something like:

ann_data_single = ann_data[0:1].copy()

ann_data_single.X[0, 5] = 0.0

dataloader = tahoe.process_data(ann_data_single, gene_names="gene_name", use_raw_counts=True)
transformer_embs, gene_ids = tahoe.get_transformer_embeddings(dataloader)
expr = tahoe.decode_embeddings(transformer_embs, gene_ids)

Activity

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