-
Notifications
You must be signed in to change notification settings - Fork 41
Description
Dear Spateo Team,
Thank you very much for developing the Spateo package—it is really a great and useful tool! Its intuitive design for spatial transcriptomics analysis, especially 3D spatial mapping and developmental trajectory-related features, has been a huge help for my research on embryo development.
While following your official tutorial to test the st.tdr.cell_directions() function, I encountered two issues and wanted to share the details in case they help improve the package:
- First Issue: IndexError When Preprocessing Sample Data
I used the provided Drosophila sample data to prepare stage1_adata and stage2_adata, but hit an IndexError during gene filtering. Below is my test code and the full error log:
Test Code
Stage 1: E7-9h
stage1_adata = st.sample_data.drosophila(filename="E7-9h_cellbin_tdr_v2_midgut.h5ad")
stage1_adata = stage1_adata[:, np.sum(stage1_adata.layers["counts_X"], axis=0) != 0] # Filter non-expressed genes
stage1_adata.uns["pp"] = {}
stage1_adata.X = stage1_adata.layers["counts_X"].copy()
dyn.pp.normalize_cell_expr_by_size_factors(adata=stage1_adata, layers="X", X_total_layers=True)
Stage 2: E9-10h
stage2_adata = st.sample_data.drosophila(filename="E9-10h_cellbin_tdr_v2_midgut.h5ad")
stage2_adata = stage2_adata[:, np.sum(stage2_adata.layers["counts_X"], axis=0) != 0]
stage2_adata.uns["pp"] = {}
stage2_adata.X = stage2_adata.layers["counts_X"].copy()
dyn.pp.normalize_cell_expr_by_size_factors(adata=stage2_adata, layers="X", X_total_layers=True)
st.tdr.cell_directions(
adataA=stage1_adata,
adataB=stage2_adata,
numItermaxEmd=500000,
#layer="log1p_X",
spatial_key="3d_align_spatial",
key_added="cells_mapping",
alpha=0.0001,
device="0",
inplace=True
)
Error Log
plaintext
TypeError Traceback (most recent call last)
Cell In[7], line 1
----> 1 st.tdr.cell_directions(
2 adataA=stage1_adata,
3 adataB=stage2_adata,
4 numItermaxEmd=500000,
5 #layer="log1p_X",
6 spatial_key="3d_align_spatial",
7 key_added="cells_mapping",
8 alpha=0.0001,
9 device="0",
10 inplace=True
11 )
File D:\miniconda3\envs\spateo_ST3D\lib\site-packages\spateo\tdr\morphometrics\morphofield\sparsevfc.py:66, in cell_directions(adataA, adataB, layer, genes, spatial_key, key_added, alpha, numItermax, numItermaxEmd, dtype, device, keep_all, inplace, **kwargs)
34 """
35 Obtain the optimal mapping relationship and developmental direction between cells for samples between continuous developmental stages.
36
(...)
63 A pi metrix.
64 """
65 # Calculate and returns optimal alignment of two models.
---> 66 pi, _ = paste_pairwise_align(
67 sampleA=adataA.copy(),
68 sampleB=adataB.copy(),
69 spatial_key=spatial_key,
70 layer=layer,
71 genes=genes,
72 alpha=alpha,
73 numItermax=numItermax,
74 numItermaxEmd=numItermaxEmd,
75 dtype=dtype,
76 device=device,
77 **kwargs,
78 )
80 max_index, pi_value, _, _ = get_optimal_mapping_relationship(
81 X=adataA.obsm[spatial_key].copy(), Y=adataB.obsm[spatial_key].copy(), pi=pi, keep_all=keep_all
82 )
84 mapping_data = pd.DataFrame(
85 np.concatenate([max_index, pi_value], axis=1),
86 columns=["index_x", "index_y", "pi_value"],
(...)
92 }
93 )
File D:\miniconda3\envs\spateo_ST3D\lib\site-packages\spateo\alignment\methods\paste.py:73, in paste_pairwise_align(sampleA, sampleB, layer, genes, spatial_key, alpha, dissimilarity, G_init, a_distribution, b_distribution, norm, numItermax, numItermaxEmd, dtype, device, verbose)
44 """
45 Calculates and returns optimal alignment of two slices.
46
(...)
69 obj: Objective function output of FGW-OT.
70 """
72 # Preprocessing
---> 73 (nx, type_as, new_samples, exp_matrices, spatial_coords, normalize_scale, normalize_mean_list,) = align_preprocess(
74 samples=[sampleA, sampleB],
75 genes=genes,
76 spatial_key=spatial_key,
77 layer=layer,
78 normalize_c=False,
79 normalize_g=False,
80 select_high_exp_genes=False,
81 dtype=dtype,
82 device=device,
83 verbose=verbose,
84 )
86 # Calculate spatial distances
87 coordsA, coordsB = spatial_coords[0], spatial_coords[1]
TypeError: align_preprocess() got an unexpected keyword argument 'layer'
I hope these details help. Again, thank you for building such a powerful tool for spatial biology research—it has been instrumental in my work. Please let me know if you need more information to reproduce these issues.