dynamo-release
                                
                                 dynamo-release copied to clipboard
                                
                                    dynamo-release copied to clipboard
                            
                            
                            
                        How to use pearson_transition_matrix to compute vector field pseudotime?
Hello Dynamo,
I can get pearson_transition_matrix by running dyn.tl.cell_velocities(adata, basis='umap', n_neighbors = 10, method='pearson', other_kernels_dict={'transform': 'sqrt'}).
Your amazing tutorial has already shown the way to compute vector field pseudotime based on cosine_transition_matrix as below.
g = build_graph(adata.obsp["cosine_transition_matrix"])
ddhodge_div = div(g)
potential_cosine = potential(g, -ddhodge_div)
adata.obs["cosine_potential"] = potential_cosine
dyn.pl.umap(adata, color='cosine_potential', cmap='gnuplot', pointsize=0.1, save_show_or_return='return', frontier=False, alpha=1)
df["cosine"] = potential_cosine[valid_indices]
sns.displot(data=df, x="cosine", hue="cell_type", kind="ecdf", stat="count", palette=adata.uns['cell_type_colors'], height=3, aspect=3/2)
plt.xlim(0, 0.008)
plt.ylim(0, 12) 
plt.xlabel("vector field pseudotime")
Do I need to do any further parameter changing for computing vector field pseudotime by pearson_transition_matrix? I just use the same coding by change cosine_transition_matrix to pearson_transition_matrix. Is it right?
g = build_graph(adata.obsp["pearson_transition_matrix"])
ddhodge_div = div(g)
potential_pearson = potential(g, -ddhodge_div)
adata.obs["pearson_potential"] = potential_pearson
dyn.pl.umap(adata, color='pearson_potential', cmap='gnuplot', pointsize=0.1, save_show_or_return='return', frontier=False, alpha=1)
df["pearson"] = potential_pearson[valid_indices]
sns.displot(data=df, x="pearson", hue="cell_type", kind="ecdf", stat="count", palette=adata.uns['cell_type_colors'], height=3, aspect=3/2)
plt.xlim(0, 0.008)
plt.ylim(0, 12) 
plt.xlabel("vector field pseudotime")
Thanks! Best, YJ
that is right! you can simply replace cosine kernel with the pearson kernel to get the corresponding vector field based pseudotime. You may also find the dyn.ext.ddhodge(adata) helpful and feel free to check its documentations ?dyn.ext.ddhodge.