Repository navigation
improvements on plotting functions that use 'groupby' - #1210
Conversation
…or'. Relative sizes had been adapted to work in most conditions
…dot plot. Added options to plot pvalues and logfoldchanges
…ws and columns. Fixed order of rows and columns to match the ouput of matrixplot.
…956). Now is possible to do sc.pl.dotplot(adata, ...).add_dendrogram(size=1).show()
…code as `sc.pl.DotPlot`.
…ly the indices were kept. Useful to sort categories by name
…gories by pandas index sorting (iloc -> loc).
…max, color_map etc). Added `color` parameter to `.add_totals()`.
…currently is only DotPlot.
…f `sc.pl.matrixplot` by MatrixPlot.
…s to better names.
… problem with dendrogram not showing when groupby was not a list
|
@gokceneraslan I just added the dynamic coloring of the circles when the color is on the background square. adata = sc.datasets.pbmc68k_reduced()
markers = {'T-cell': ['CD3D', 'CD3E', 'IL32'],
'B-cell': ['CD79A', 'CD79B', 'MS4A1'],
'myeloid': ['CST3', 'LYZ']}
sc.pl.dotplot(adata, markers, groupby='bulk_labels', return_fig=True)\
.style(color_on='square', cmap='binary').show() |
|
Looks phenomenal! Thanks so much. |
…. Added separate file for `_baseplot_class.py` containing the BasePlot parent class.
|
@fidelram Sorry, I completely missed your asking for a review! It does look good though. However, it looks like this is breaking the docs. Could you take a look into that? |
|
I think the issue that there are references to the Classes used for these plots:
.. autosummary::
:toctree: .
pl._dotplot.DotPlotto the doc-string of the plotting module. Once this exists, there might be some other errors that pop up. |
… some parts to make them more clear
* updated notebook after scverse/scanpy#661 * updated visualization tutorial after scverse/scanpy#1210 Also rewrote some parts to make them more clear * updated notebook after @falexwolf review * moved notebook to plotting folder
@fidelram The cool dynamic line coloring feature seems broken now, I wonder why :/ |
|
Is because we changed dot edge the defaults shortly before the release. Time to add a test for this. I will make a fix but meanwhile you can trigger the dynamic coloring by setting sc.pl.dotplot(adata, markers, groupby='bulk_labels', return_fig=True)\
.style(color_on='square', dot_edge_color=None, dot_edge_lw=None).show() |
|
I wonder why the default for Unless there’s a bias in human perception that suggests this, I’d say only a value of 2.0 makes sense (meaning area corresponds to value) |


This PR addresses issues from #979 and #1103 related to
sc.pl.dotplotand replaces PR #1127Furthermore, the current PR attempts to unify common code between
dotplot,matrixplotandstacked_violinplots while at the same time adding more flexibility to the plots.This PR also makes possible to plot fold changes, log fold changes and p-values from
sc.tl.rank_genes_groupsas suggested in #562To achieve this the
sc.pl.dotplot,sc.pl.matrixplotandsc.pl.stacked_violinmethod had been transformed into wrappers for the newDotPlot,MatrixPlotandStackedViolingclasses. Accessing the new classes directly allows further fine tuning of the plots.The use of the
sc.pl.dotplot,sc.pl.matrixplotandsc.pl.stacked_violindidn't change, only the new parameterreturn_figwas added.For clarity, the relevant code has been moved to
scanpy.plotting._groupby_plots.py.The new plot classes are all descendants of a
BasePlotclass that captures most of the common code shared between the plots. The design of the classes follows the method chaining (as found in Pandas or Altair). This allows the addition of independent features (via well documented methods) to the plot without increasing the number parameters of a single function. This was first suggested here #956.For example, for dotplot is now is possible to
add category totals, define the titles for the colorbar and size legend and modify the values for edge color and edge line with for dot plot and the size exponent used (among may other options). For example:All objects have consistent functions for
legend, to set up titles and width,style()to set visual parameters specific to each plot like colormap, edge color, linewidth.swap_axesto transpose the figure,add_dendrogramwith options to change the with of the dendrogran andadd_totaltho show a bar plot of the total number of cells per category. Also includes options to sort the categories.Here is description of changes:
all figures:
axewhere to plot the image.return_figthe plot object can be used to adjust the proportions to the legend and other visual aspects can be fine tuned.groupbycan be a list of categories.dotplot
colorbar_titleandsize_titlearguments. They also align at the bottom of the image and do not shrink if the dotplot image is smaller.sc.pl.rank_genes_groups_dotplotcan now plotpvalsandlog fold changesmatrixplot
sc.pl.rank_genes_groups_matrixplotcan now plotpvalsandlog fold changesstacked_violin
stylemethod they can be visualized.TODO: