Option to plot separate umaps for concatenated datasets

Is there an option/argument that can be passed to sc.pl.umap to plot separate UMAPs based on a categorical variable i.e. batch,sample etc.

Something like the “split.by” argument in Seurat.

Thank you,
Ishwar

1 Like

Hello Ishwar, this is how I plot my umaps of 4 samples:
sc.pl.umap(adata, color = [‘leiden’, ‘Sample’], frameon = false, legend_loc = ‘on data’)

Thank you for your reply. I am not sure if this does what I am looking for. AFAIK, this just plots 2 plots which contain cells from all 4 of your samples.

Correct me if I am wrong, but does this split your merged object into 4 plots each with its leiden clusters and sample name?

Ishwar, you are right, the code I shared doesn’t do your request. I think I stumbled upon a code that does what you want in one of the tutorials by sambomics GitHub - mousepixels/sanbomics_scripts: scripts and notebooks from sanbomics
I just can’t find it. Maybe you can check it out?

Hii

I don’t think it can be done directly. Here is what I do:

fig,ax = plt.subplots(nrows=1,ncols=4) ## Assuming 4 samples 

for i,j in zip(adata.obs["sample"].unique().tolist(),ax.ravel()):
	sc.pl.umap(adata[adata.obs["sample"].isin([i])],color=["CD8A"],size=20,show=False,ax=j)

plt.tight_layout()
plt.show()

You may need to play around a bit with size parameter. You can choose the colormaps or other specifications as you wish.