-
Notifications
You must be signed in to change notification settings - Fork 584
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
editing output of scanpy dotplot and other figures #979
Labels
Comments
Just opened a PR to fix this. Quoting from the PR (#1069):
|
2 tasks
fidelram
added a commit
that referenced
this issue
Jun 29, 2020
* Unifies common code between `dotplot`, `matrixplot` and `stacked_violin` plots while adding flexibility to the plots. sc.pl.dotplot`, `sc.pl.matrixplot` and `sc.pl.stacked_violin` methods had been transformed into wrappers for the new `DotPlot`, `MatrixPlot` and `StackedVioling` classes. Accessing the new classes directly allows further fine tuning of the plots. * The new plot classes are all descendants of `BasePlot` class that captures the common code. 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. 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_axes` to transpose the figure, `add_dendrogram` with options to change the with of the dendrogran and `add_total` tho show a bar plot of the total number of cells per category. Also includes options to sort the categories. * Previous functionality is maintained but plots will look slightly different. * This commit addresses issues from #979 and #1103 related to `sc.pl.dotplot` * Now is possible to plot fold changes, log fold changes and p-values from `sc.tl.rank_genes_groups` as suggested in #562 Specific changes: **all figures**: * Set a title to the image. * Pass an `axe` where to plot the image. * Return a dictionary of axes for further manipulation * using `return_fig` the plot object can be used to adjust the proportions to the legend and other visual aspects can be fine tuned. * a bar plot with the totals per category can be added. This will align at the left of the image if the categories are plotted in rows or at the top if they are plotted in columns. * legend can be removed * `groupby` can be a list of categories. **dotplot** * Improved the colorbar and size legend for dotplots. Now the colorbar and size have titles, which can be modified using the `colorbar_title` and `size_title` arguments. They also align at the bottom of the image and do not shrink if the dotplot image is smaller. * Plot genes in rows and categories in columns (swap_axes). * Using the DotPlot object the dot_edge_color and line width can be set up, a grid added as well as several other features * `sc.pl.rank_genes_groups_dotplot` can now plot `pvals` and `log fold changes` **matrixplot** * added title for colorbar and positioned as in dotplot * `sc.pl.rank_genes_groups_matrixplot` can now plot `pvals` and `log fold changes` **stacked_violin** * violin colors can be colored based on average gene expression as in dotplots * made the linewidth of the violin plots smaller. * removed the tics for the y axis as they tend to overlap with each other. Using the `style` method they can be visualized. **other** * `sc.pl.heatmap` and `sc.pl.trackplots` now return a dictionary of axes when `show=False` as for the other plots. * now 'interpolation' can be passed as parameter for `sc.pl.heatmap`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the scanpy documentation for sc.pl.dotplot, it indicates that it returns a list of matplotlib.axes.Axes
However, this is not true, it returns a gridspec object instead.
I noticed this because I wanted to make some subtle edits to the results to enhance the figure such as changing axis labels, adding overlapping lines to delineate the marker genes for each cell type, etc. But I am struggling to do so.
I am wondering how the API intends for us to interact with the gridspec object returned to modify the figure. If I edit the code to return the figure object as well as the gridspec, I can access the axis like so
but I can't seem to overwrite the default axis labels or add new lines as commands like
Don't change the figure at all.
This is all Scanpy 1.4.5.post1 but it was the same for 1.4.4.post1
Thanks!
Versions:
scanpy==1.4.5.post1 anndata==0.6.22.post1 umap==0.4.0 numpy==1.17.2 scipy==1.3.1 pandas==0.25.1 scikit-learn==0.21.3 statsmodels==0.10.1 python-igraph==0.7.1 louvain==0.6.1
but the same things happened with scanpy==1.4.4.post1
The text was updated successfully, but these errors were encountered: