Stacked barplot
- [ X] Closes # (New Feature)
- [ X] Tests included or not required because:
- [X ] Release notes not necessary because:
I thought I would give a shot at contributing to this awesome tool! I added a function to Scanpy's plotting API that I use in my own research for creating stacked barplots for visualizing compositions of cell groups. An example is depicted below:
Specifically, this function enables one to plot the fraction of each cell group (e.g., cluster) that are labelled with a specific categorical variable. For example, if the cell groups are clusters, then one might be interested in examining the fraction of each cluster that originates from each "batch" of cells or each patient sample.
This function also enables ordering of the groups according to a specific value (e.g., a patient number or batch ID) or by agglomerative clustering. An example of ordering the groups based on agglomerative clustering is shown below:
The function supplies an argument to specify whether the dendrogram should or should not be plotted.
Please let me know if this feature is of interest and if so, what else needs to be adjusted or fixed prior to merging. Thanks!
Matt
Codecov Report
Attention: Patch coverage is 85.71429% with 12 lines in your changes are missing coverage. Please review.
Project coverage is 74.76%. Comparing base (
14555ba) to head (626d389).
Additional details and impacted files
@@ Coverage Diff @@
## main #2873 +/- ##
==========================================
- Coverage 74.82% 74.76% -0.07%
==========================================
Files 116 117 +1
Lines 12809 12893 +84
==========================================
+ Hits 9584 9639 +55
- Misses 3225 3254 +29
| Files | Coverage Δ | |
|---|---|---|
| scanpy/plotting/__init__.py | 100.00% <100.00%> (ø) |
|
| scanpy/plotting/_stacked_barplot.py | 85.54% <85.54%> (ø) |