HelloWorldLTY / scELMo

Codes for paper: scELMo: Embeddings from Language Models are Good Learners for Single-cell Data Analysis
11 stars 2 forks source link

in-silico treatment.ipynb is not working #1

Closed mHagiw closed 1 month ago

mHagiw commented 2 months ago

Hello,

The in-silico notebook is not working properly. There are some missing code segments throughout the notebook, some of which I was able to resolve on my own.

However, in the section where

adata_test.obsm['X_pca'] = genePT_w_emebed_test

is used, genePT_w_emebed_test appears without being defined in this notebook.

How should this be defined in this notebook? It appears in other notebooks, but I need guidance on defining it specifically for this in-silico heart disease analysis.

Thank you for your assistance and support.

HelloWorldLTY commented 1 month ago

Hi, thanks for your question. Would you please try our updated codes? Basically it is used to compute the space before perturbation. To compute the embeddings after perturabtion, we have the code below:

for i in sampled_adata.uns['rank_genes_groups']['names'][disease][0:10]:
    adata_test_new = adata_test.copy()
    adata_test_new[:,i].X = 0

    _,genePT_w_emebed_test = model_output(net, torch.FloatTensor(adata_test_new.X.toarray()))
    adata_test_new.obsm['X_genept'] = genePT_w_emebed_test
    meanv = np.mean(adata_test_new[adata_test_new.obs['disease'] == control].obsm['X_genept'],axis=0)
    meanv_ascend = np.mean(adata_test_new[adata_test_new.obs['disease'] == disease].obsm['X_genept'],axis=0)
#     print(i)
    print(1 - scipy.spatial.distance.cosine(meanv, meanv_ascend) - raw_cs)
HelloWorldLTY commented 1 month ago

Since there are no further questions, I will close this issue. Thanks.