theislab / ncem_benchmarks

BSD 3-Clause "New" or "Revised" License
8 stars 2 forks source link

Can not find image output after training NCEM interaction model #3

Open archanabhardwaj opened 2 years ago

archanabhardwaj commented 2 years ago

Hello

I would like to use this nice tool for my 10X visium samples. I followed most of the tutorials and prepared my custom data for the analysis in NCEM . Everything works fine. But I can not see any image output after training NCEM interaction model.

I followed code given in https://github.com/theislab/spatial_scog_workshop_2022/blob/main/ncem/ncem_training.ipynb and prepared my own dataset via ncem.data.customLoader function.

import ncem import ncem import matplotlib.pyplot as plt import pandas as pd import scanpy as sc sc.settings.set_figure_params(dpi=80)

import warnings warnings.filterwarnings("ignore")

adata_file = f"{run_name}/sp.h5ad" # sp_cluster

adata_vis2 = sc.read_h5ad(adata_file)

ad = an.read_h5ad(adata_file)

ncem = InterpreterInteraction()

adata_vis = ad

trainer.estimator.data = ncem.data.customLoader( adata=adata_vis, cluster='region_cluster', patient='sample', library_id='sample', radius=150 )

ncem.data.get_data_custom(interpreter=trainer.estimator)

trainer.estimator.init_model(n_eval_nodes_per_graph=10) trainer.estimator.model.training_model.summary() trainer.estimator.train(epochs=10)

Here is few lines of output after training model for 10 epochs. Epoch 9/10 1/1 - 4s - loss: 45320.5820 - custom_mae: 0.1439 - custom_mean_sd: 0.9993 - custom_mse: 4.2089 - custom_mse_scaled: 4.2034 - gaussian_reconstruction_loss: 45320.5820 - r_squared: -3.9104e-03 - r_squared_linreg: 2.7662e-05 - val_loss: 134967.0781 - val_custom_mae: 0.1796 - val_custom_mean_sd: 0.9993 - val_custom_mse: 16.1731 - val_custom_mse_scaled: 16.1507 - val_gaussian_reconstruction_loss: 134967.0781 - val_r_squared: -1.6471e-03 - val_r_squared_linreg: 2.2285e-05 - lr: 2.0000e-05 - 4s/epoch - 4s/step Epoch 10/10 1/1 - 4s - loss: 55272.2500 - custom_mae: 0.1449 - custom_mean_sd: 0.9993 - custom_mse: 5.5372 - custom_mse_scaled: 5.5297 - gaussian_reconstruction_loss: 55272.2500 - r_squared: -2.9951e-03 - r_squared_linreg: 3.3485e-05 - val_loss: 129156.8281 - val_custom_mae: 0.1713 - val_custom_mean_sd: 0.9993 - val_custom_mse: 15.3982 - val_custom_mse_scaled: 15.3764 - val_gaussian_reconstruction_loss: 129156.8281 - val_r_squared: -1.5578e-03 - val_r_squared_linreg: 1.9801e-05 - lr: 2.0000e-05 - 4s/epoch - 4s/step

In the tutorial, I can see output image file to find the model performance at specific resolution but its not working at my end. Please correct me if I am doing something wrong.

I would appreciate your suggestion.

Thanks in advance

AnnaChristina commented 2 years ago

Hi @archanabhardwaj,

thanks for your interest in using ncem. The image in the tutorial is a static example on results obtained with an ablation study. To generate these results you need to run ncem on multiple different resolutions and save the evaluation on a compute cluster.

We provide examples how to generate these plots for example here: https://github.com/theislab/ncem_benchmarks/blob/main/notebooks/model_benchmarks/model_benchmarks_mibitof_cancer.ipynb

In order to generate evaluations at multiple resolutions you need to run model specific train scripts, which can be found here: https://github.com/theislab/ncem_benchmarks/tree/main/scripts

We currently only provide example on how to implement these on our own compute cluster with the pre-selected dataset. If you want to use these scripts with your custom data we recommend adjusting the train scripts to use a custom AnnData object.

I hope this answers your questions!