question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Small multiple plots for clusters

See original GitHub issue
  • Additional function parameters / changed functionality / changed defaults?
  • New analysis tool: A simple analysis tool you have been using and are missing in sc.tools?
  • New plotting function: A kind of plot you would like to seein sc.pl?
  • External tools: Do you know an existing package that should go into sc.external.*?
  • Other?

Hey @fidelram !

I just wrote something to create small multiples to plot cells in a clustering category. Pretty simple and very useful if you have too many clusters. What do you think of this:

def cluster_small_multiples(adata, clust_key, size=60, frameon=False, legend_loc=None, **kwargs):
    tmp = adata.copy()

    for i,clust in enumerate(adata.obs[clust_key].cat.categories):
        tmp.obs[clust] = adata.obs[clust_key].isin([clust]).astype('category')
        tmp.uns[clust+'_colors'] = ['#d3d3d3', adata.uns[clust_key+'_colors'][i]]

    sc.pl.umap(tmp, groups=tmp.obs[clust].cat.categories[1:].values, color=adata.obs[clust_key].cat.categories.tolist(), size=size, frameon=frameon, legend_loc=legend_loc, **kwargs)

Example output from:

test = sc.datasets.pbmc68k_reduced()
sc.pp.pca(test)
sc.pp.neighbors(test)
sc.tl.umap(test)
cluster_small_multiples(test, 'bulk_labels')

umap_bulk_lab_sm

Could generalize this to different bases via sc.pl.scatter(). Or is this already implemented somewhere that I’m not aware of? Or maybe it’s too simple to have as a small helper function?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
VolkerBergencommented, Dec 17, 2019

Any keyword suggestion? groups='all' as @gokceneraslan suggested?

0reactions
wangjiawen2013commented, Sep 28, 2021

How are the things going now ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Small multiple plots for clusters · Issue #955 · scverse/scanpy
I just wrote something to create small multiples to plot cells in a clustering category. Pretty simple and very useful if you have...
Read more >
Clustering with Multiple Graphs - UT Computer Science
In this paper, we focus on the problem of clustering the vertices based on multiple graphs in both unsupervised and semi-supervised settings. As...
Read more >
Clusters in scatter plots (article) - Khan Academy
Sometimes the data points in a scatter plot form distinct groups. These groups are called clusters.
Read more >
What are Small Multiples? - Displayr
A small multiple is a data visualization that consists of multiple charts arranged in a grid. This makes it easy to compare the...
Read more >
Small multiple - Wikipedia
A small multiple (sometimes called trellis chart, lattice chart, grid chart, or panel chart) is a series of similar graphs or charts using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found