Skip to content

No arrows displayed when running the Spatial trajectory inference analysis #317

@SA-coder-netizen

Description

@SA-coder-netizen

st.spatial.trajectory.pseudotimespace_global and using st.pl.cluster_plot to visualize the trajectories.

Description: I followed the tutorial and successfully completed the following steps:

Ran PCA on the data:
st.em.run_pca(data, n_comps=900, random_state=0)
Tiled the image:

st.pp.tiling(data, out_path="tiling", crop_size=40)
Used deep learning to extract features:

st.pp.extract_feature(data)
Applied the spatial-PCA adjustment using stSME:

st.spatial.morphology.adjust(data, use_data="X_pca", radius=200, method="median")
Calculated neighbors:
st.pp.neighbors(data, n_neighbors=15, use_rep='X_pca_morphology', random_state=0)
Performed Louvain clustering:
st.tl.clustering.louvain(data, random_state=0)
Afterward, I ran the following for trajectory inference:

data.uns["iroot"] = st.spatial.trajectory.set_root(data, use_label="louvain", cluster=4, use_raw=True)
st.spatial.trajectory.pseudotime(data, eps=101, use_rep="X_pca", use_label="louvain")
The output showed that available trajectory paths are stored in adata.uns['available_paths']:
{0: [4, 3], 1: [4, 3, 2], 3: [4, 2, 1], 2: [4, 3, 0], 5: [4, 3, 1]}
Then, I ran the global pseudotime-space trajectory method:

st.spatial.trajectory.pseudotimespace_global(data, use_label="louvain", list_clusters=["4", "2"])
Output: Start to construct the trajectory: 4 -> 2

Finally, I attempted to visualize the trajectory using st.pl.cluster_plot:

st.pl.cluster_plot(data, use_label="louvain", show_trajectories=True, list_clusters=["4", "2"],
show_subcluster=True, trajectory_edge_color="black", trajectory_arrowsize=12,
trajectory_width=12, size=20)
The plot shows the clusters and subclusters, but there are no arrows indicating the trajectory from cluster 4 to cluster 2. As a troubleshooting step, I increased the arrow width to 1000, and I could see some black area emerging from the corner of the plot, but still no clear arrows.

What I’ve tried:

Increased the arrow width to a large value, but it only produced a black patch in the corner of the plot.
Ensured that adata.uns['available_paths'] contains the expected trajectory paths.
Can someone help me understand why the arrows aren’t showing up in the plot? What other steps can I take to debug this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions