YangLabHKUST / STitch3D

Construction of a 3D whole organism spatial atlas by joint modeling of multiple slices
https://stitch3d-tutorial.readthedocs.io/en/latest/index.html#
MIT License
52 stars 2 forks source link

Cannot produce "results_human_heart_9PCW" and "results_human_heart_4.5-5PCW" #9

Closed cristalliao closed 1 year ago

cristalliao commented 1 year ago

Dear Professor, I want to know how can you get the results for "results_human_heart_9PCW" and "results_human_heart_4.5-5PCW" in the Example 2 human heart dataset. I encountered some problems when I change the "results_human_heart_6PCW" code.

For producing "results_human_heart_6PCW", I use the code you provided in the tutorial, which are

Screen Shot 2023-04-26 at 2 15 34 pm

It can work and produce the "results_human_heart" for 6PCW

However, when I change all the 6.5 numbers to 9, then there have some errors in my computer, it reports:

Screen Shot 2023-04-26 at 2 14 55 pm Screen Shot 2023-04-26 at 2 15 03 pm

Is there any other code change for me to produce "results_human_heart_9PCW" and "results_human_heart_4.5-5PCW"? Since I want to reproduce the code in "3D visualization of STitch3D’s spatiotemporal cell-type deconvolution results" and "Differentially expressed gene analysis for developing human hearts". They all need these two datasets.

Thanks in advance!

gefeiwang commented 1 year ago

Hi Cristal,

To run the code on other two datasets, you also need to modify the way to load the count matrices and meta information.

For example, to get results for the 9PCW human heart, the count matrices and meta information can be loaded like

for i in range(1, 7): count_i = count[[loc.split("x")[0]==str(i+13) for loc in count.index]] count_i.index = [(loc.split("x")[1]+"x"+loc.split("x")[2]) for loc in count_i.index] meta_i = meta[[loc.split("x")[0]==str(i+13) for loc in meta.index]] meta_i.index = [(loc.split("x")[1]+"x"+loc.split("x")[2]) for loc in meta_i.index]

Similarly for the 4.5-5 PCW human heart, try

for i in range(1, 5): count_i = count[[loc.split("x")[0]==str(i) for loc in count.index]] count_i.index = [(loc.split("x")[1]+"x"+loc.split("x")[2]) for loc in count_i.index] meta_i = meta[[loc.split("x")[0]==str(i) for loc in meta.index]] meta_i.index = [(loc.split("x")[1]+"x"+loc.split("x")[2]) for loc in meta_i.index]

cristalliao commented 1 year ago

Dear Geferi, Thanks for your reply! However, I still encountered some problems when I ran this code for the 9PCW human heart: # Selecting highly variable genes and building 3D spatial graph adata_st, adata_basis = STitch3D.utils.preprocess(adata_st_list, adata_ref, sample_col="experiment", rad_cutoff=1.1, c2c_dist=200., coor_key="loc_use", slice_dist_micron=[5., 115., 85., 160., 5., 160., 5., 155.,], n_hvg_group=500) The error is

Screen Shot 2023-05-02 at 10 31 06 am

It said, "ValueError: The length of 'slice_dist_micron' should be the number of adatas - 1 !", how to deal with this problem? Also, for 4.5-5 PCW human heart cases. Thanks a lot!

gefeiwang commented 1 year ago

Hi Cristal,

slice_dist_micron contains the distances between pairs of slices (in microns). For the 4.5-5 PCW data, slice_dist_micron=[5., 75., 5.,], as provided by the original publication. For the 9 PCW data, use slice_dist_micron=[5., 145., 5., 170., 5.,].

cristalliao commented 1 year ago

Dear Gefei, Thanks for your reply! By the way, I want to know how to get this setting by myself, is that number by default, or can we change this number for different PCW data? Best regards, Cristal

gefeiwang commented 1 year ago

Hi Cristal,

This information is usually given by the original datasets. If you do not have such information, you can also specify the distances between pairs of slices by yourself as long as in a reasonable range.

cristalliao commented 1 year ago

Dear Gefei, Got it! Thanks a lot, Geifei!! Best regards, Cristal