Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlay paga-trajectory result on umap #28

Open
parkjooyoung99 opened this issue May 11, 2022 · 1 comment
Open

Overlay paga-trajectory result on umap #28

parkjooyoung99 opened this issue May 11, 2022 · 1 comment

Comments

@parkjooyoung99
Copy link

I know there is a function 'sc.pl.paga_compare' but i wonder if i can overlay paga-trajectory result on umap.

Thank you!

@shaln
Copy link

shaln commented Oct 5, 2023

@parkjooyoung99 This is the code I used to first re-orient the PAGA plot to mimic the UMAP.

# Compare UMAP and PAGA layouts
fig,axs=plt.subplots(1,2,figsize=(20,10), dpi=250)
sc.pl.umap(control_sce, color='subclusters', ax=axs[0], show=False, size=30, legend_loc='on data',
           legend_fontsize=15, legend_fontoutline=5, frameon=False, title='UMAP')
sc.pl.paga(control_sce,ax=axs[1], frameon=False, title='PAGA (Threshold = 0)', 
           node_size_scale=10, edge_width_scale=3, fontsize=15, fontoutline=5,
           threshold=0, save='_umap-compare_thr0.png')

Then I used this next chunk of code to overlap the PAGA onto the UMAP. Hope this helps :)

# Define PAGA positions based on the UMAP layout -
# for each cluster we use the mean of the UMAP positions from the cells in that cluster
pos=pd.DataFrame(control_sce.obsm['X_umap'],index=control_sce.obs_names)
pos['group']=control_sce.obs[control_sce.uns['paga']['groups']]
pos=pos.groupby('group').mean()

# Plot UMAP in the background
ax=sc.pl.umap(control_sce,show=False, size=30, legend_loc='bottom',
              legend_fontsize=15, legend_fontoutline=5, frameon=False, title='UMAP')
# Plot PAGA ontop of the UMAP
sc.pl.paga(control_sce, frameon=False, title='PAGA (Threshold = 0)', threshold=0, 
           node_size_scale=6, edge_width_scale=3, fontsize=12, fontoutline=5, 
           pos=pos.values, random_state=0, ax=ax, save='_umap-overlay_thr0.png')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants