theislab / ncem

Learning cell communication from spatial graphs of cells
https://ncem.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
103 stars 13 forks source link

Naive Question #147

Open Chuang1118 opened 1 year ago

Chuang1118 commented 1 year ago

Hello ncem team,

Thanks to develop NCEM. I'm trying out NCEM tool for downstream analysis(the receiver/sender analysis) of 10X visium with cell2location.

following this tutorial: https://github.com/theislab/ncem_tutorials/blob/main/tutorials/type_coupling_visium.ipynb

e.g. adata

AnnData object with n_obs × n_vars = 79849 × 2000
    obs: 'index', 'target_cell'
    var: 'highly_variable', 'means', 'dispersions', 'dispersions_norm'
    uns: 'hvg', 'log1p', 'node_type_names'
    obsm: 'node_types', 'proportions', 'spatial'

get_data_custom(interpreter=ncem_ip, deconvolution=True)

Mean of mean node degree per images across images: 6.000000
Using split method: node. 
 Train-test-validation split is based on total number of nodes per patients over all images.

Excluded 0 cells with the following unannotated cell type: [None] 

Whole dataset: 79849 cells out of 2 images from 1 patients.
Test dataset: 7985 cells out of 2 images from 1 patients.
Training dataset: 65008 cells out of 2 images from 1 patients.
Validation dataset: 7187 cells out of 2 images from 1 patients.

1/ for now I can plot the figures of type coupling analysis (e.g. Fig2 b, c, d, f in your paper). How about the part of Training the ncem model for deconvoluted Visium, what's the output from this part ? This part is Independent ?

2/ when I running the code below: trainer.estimator.train(epochs=5) I got the error messages:

Node: 'StatefulPartitionedCall'
RET_CHECK failure (tensorflow/compiler/xla/service/gpu/gpu_compiler.cc:618) dnn != nullptr 
     [[{{node StatefulPartitionedCall}}]] [Op:__inference_train_function_1382]

I have checked Memory GPU is mostly full. 23178MiB / 24564MiB

Fri Mar 24 10:42:34 2023       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.78.01    Driver Version: 525.78.01    CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA RTX A5000    Off  | 00000000:3B:00.0 Off |                  Off |
| 30%   38C    P2    59W / 230W |  23178MiB / 24564MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

Do you have any idea about GPU memory required for running NCEM with n_obs × n_vars = 79849 × 2000 ?

I have also followed the tutorial from https://github.com/theislab/spatial_scog_workshop_2022/blob/main/ncem/tutorial_ncem.ipynb

3/ For the part of Cell heterogeneity attributed to niche composition. the code below doesn't work to me.

adata_img, adata, log_pval, fold_change = ncem.data.compute_cluster_enrichment(
    image_key=['point16', 'point23', 'point8'],
    target_cell_type='Tcell_CD8',
    clip_pvalues=-5,
    n_neighbors=22,
    n_pcs=None,
)
    828 adata_list = list(self.img_celldata.values())
    829 adata = adata_list[0].concatenate(adata_list[1:], uns_merge="same")
--> 831 cluster_col = self.celldata.uns["metadata"]["cluster_col_preprocessed"]
    832 image_col = self.celldata.uns["metadata"]["image_col"]
    833 if undefined_type:

KeyError: 'cluster_col_preprocessed'

How to built cluster_col_preprocessed metadata ? This part is also for 10x visium?

4/ In general, I have misunderstood your tutorial. Could you tell to me step by step how to analysis 10x visium dataset from anndata with metadata ( obsm: 'node_types', 'proportions', 'spatial' ) using NCEM, especially downstream analysis from Training the ncem model for deconvoluted Visium.

Best, Chuang