dynamo-release icon indicating copy to clipboard operation
dynamo-release copied to clipboard

Bugs when I do not intend to use PCA to infer in-silico perturbation

Open HelloWorldLTY opened this issue 1 year ago • 3 comments

Hi, I intend to use umap or other dimension reduction tools to compute the in-silico perturbation.

My code is:

dyn.vf.VectorField(adata, basis='umap')

gene = "Gata1"
dyn.pd.perturbation(adata, gene, [-100], emb_basis="umap")
dyn.pl.streamline_plot(adata, color=["Class", gene], basis="umap_perturbation")

However, even if I run vectorfield based on other coordinates, I still received this error:

tils.py:288, in get_vf_dict(adata, basis, vf_key)
    285         vf_key = "%s_%s" % (vf_key, basis)
    287 if vf_key not in adata.uns.keys():
--> 288     raise ValueError(
    289         f"Vector field function {vf_key} is not included in the adata object! "
    290         f"Try firstly running dyn.vf.VectorField(adata, basis='{basis}')"
    291     )
    293 vf_dict = adata.uns[vf_key]
    294 return vf_dict

ValueError: Vector field function VecFld_pca is not included in the adata object! Try firstly running dyn.vf.VectorField(adata, basis='pca')

I also tried:

dyn.pd.perturbation(adata, gene, [-100], emb_basis="umap", basis='umap')

Received the same problem.

Could you please share your ideas about how to address this problem? Thanks.

HelloWorldLTY avatar Jan 09 '24 23:01 HelloWorldLTY

Thanks for you using our tool! Under the hook, the in silico perturbation requires a vector field learned in the pca space. Therefore you will need to first run as suggested from the error message.

dyn.vf.VectorField(adata, basis='pca')

Once you did that you can visualize your perturbation prediction on any embedding.

Xiaojieqiu avatar Jan 10 '24 02:01 Xiaojieqiu

I see, thanks.

HelloWorldLTY avatar Jan 10 '24 03:01 HelloWorldLTY

Hi, sorry to disturb you again. I further intend to check my understanding of your implementation of in silico perturbation.

I think the code here is used to compute the delta_x_i (where i represents the gene),

dyn.pd.perturbation(adata_labeling, gene, [-100], emb_basis="umap")

And in the explaniation of the code, it said:

delta X = [0, 0, 0, delta x_i = 10, 0, 0, .., x_j = -10, 0, 0, 0])

Therefore, this approach can only generate the change of gene expression for one gene, while assuming the rest of the genes remain their expression levels. However, I think the change of tf (like gata1) will affect the gene expressions of other genes (like triggering the delta_x of other genes to change). Is it correct? Thanks.

HelloWorldLTY avatar Jan 12 '24 00:01 HelloWorldLTY

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 14 days

github-actions[bot] avatar Apr 12 '24 00:04 github-actions[bot]