-
Notifications
You must be signed in to change notification settings - Fork 29
Description
Hello,
I have a strange issue with running st.spatial.trajectory.pseudotimespace_global() on one particular dataset, which is a spatial subset of a full Visium HD sample. This is my code:
adata_gd75 = ad.read_h5ad("analysis_output/adata_subset.h5ad")
adata_gd75 = st.convert_scanpy(adata_gd75)
adata_gd75.obs['clusters'].value_counts()
clusters
7 490
16 383
6 325
14 271
22 269
0 260
4 249
15 241
10 226
2 224
21 215
8 212
5 176
1 169
17 153
20 111
12 100
9 82
13 74
23 63
27 48
3 42
29 38
28 35
11 28
19 23
25 18
30 7
24 7
32 7
18 5
sc.pp.pca(adata_gd75, n_comps=30, random_state=30)
sc.pp.neighbors(adata_gd75, n_neighbors=15, use_rep="X_pca")
sc.tl.umap(adata_gd75, random_state=30)
sc.pl.umap(adata_gd75, color="clusters")
adata_gd75.uns["iroot"] = st.spatial.trajectory.set_root(adata_gd75,use_label="clusters",cluster=21,use_raw=False)
st.spatial.trajectory.pseudotime(adata_gd75,eps=50,use_rep="X_pca",use_label="clusters") # runs indefinitely
At first, the pseudotime() call never finished running, and kept one of my CPU cores at 100% for three days straight. By analyzing the call stack, it kept recursing around those nx calls:
networkx/algorithms/simple_paths.py: all_simple_paths(...)
networkx/algorithms/simple_paths.py: all_simple_edge_paths(...)
networkx/algorithms/simple_paths.py: _all_simple_edge_paths(...)
The same code, on a subset of another sample, worked just fine and finished the computation in less than an hour. I then found out that by taking a wider subset of the adata_gd75 subset, the call finished running and returned some trajectories. Maybe it wasn't finding any trajectories at all?
However, afterwards, I run:
for lin in lineage:
lin = [str(c) for c in lin]
lineage_str = array_to_string(lin)
try:
st.spatial.trajectory.pseudotimespace_global(adata_gd75,use_label="clusters", list_clusters=lin)
st.pl.cluster_plot(adata_gd75,use_label="clusters",
list_clusters=lin,
show_trajectories=True,
show_subcluster=True,
figsize = [12,12],
cmap='cet_glasbey',
fname = f"./figures/all_samples/lineage_tracing/GD7.5_niches_subset/GD75_{lineage_str}_pseudotimespace_global.png")
except Exception as e:
print(f'{lineage_str}:{e}')
This yields:
...
Start to construct the trajectory: 28 -> 17 -> 15
28-17-15:Connectivity is undefined for the null graph.
Start to construct the trajectory: 28 -> 16 -> 1
28-1-16:Connectivity is undefined for the null graph.
Start to construct the trajectory: 2 -> 28 -> 16
28-2-16:Connectivity is undefined for the null graph.
Start to construct the trajectory: 28 -> 4 -> 16
28-4-16:Connectivity is undefined for the null graph.
Start to construct the trajectory: 28 -> 16 -> 7
28-7-16:too many indices for array: array is 1-dimensional, but 2 were indexed
Start to construct the trajectory: 28 -> 12 -> 16
28-12-16:Connectivity is undefined for the null graph.
Start to construct the trajectory: 28 -> 16 -> 15
28-15-16:Connectivity is undefined for the null graph.
...
So I'm going to ask: in stLearn, what causes it to yield this "Connectivity is undefined for the null graph." exception?
Any advice? Thanks.
Best,
Marco Uderzo