Skip to content

Conversation

@dkcoxie
Copy link

@dkcoxie dkcoxie commented Apr 10, 2025

Clarifies documentation to specify that figure legends are currently not displayed when fast=TRUE but added titles with PC numbers to ggplot outputs so that both PC number and figure legends can be displayed on the same plot, plus option to move position of shared patchwork legend when combine=TRUE to resolve Issue #9810

Clarifies documentation to specify that figure legends are currently not displayed when `fast=TRUE` but added titles with PC numbers to ggplot outputs so that both PC number and figure legends can be displayed on the same plot, plus option to move position of shared patchwork legend when `combine=TRUE` to resolve Issue [satijalab#9810](satijalab#9810)
@dkcoxie
Copy link
Author

dkcoxie commented Apr 10, 2025

In preparing teaching materials geared toward beginners, we found that the default behavior of DimHeatmap() either displays no figure legend but includes the PC number as panel titles (default fast=TRUE) OR allows the figure legend to be shown for the ggplot2 output doesn't display the PC number for each panel (when fast=FALSE).

The Proposed changes to theDimHeatmap() function clarify the documentation regarding when a figure legend will be displayed, add PC labels as individual figure titles for the ggplot2 outputs, and allow for the position of the figure legend to be moved when the ggplots are combined into a single patchwork output.

@dkcoxie
Copy link
Author

dkcoxie commented Jul 10, 2025

The related issue was closed so I wanted to check if this improvement to make the output plots more consistent for DimHeatmap() when fast=TRUE and when fast=FALSE in still being considered for the next CRAN release. Thank you!

@anashen
Copy link
Member

anashen commented Sep 11, 2025

Thanks @dkcoxie for your PR & for the follow-up :) Yes, we have added this to the list of PRs to review.

@anashen anashen self-requested a review September 11, 2025 16:44
@anashen anashen changed the base branch from develop to main September 23, 2025 18:16
Copy link
Member

@anashen anashen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @dkcoxie for opening this PR! These changes will definitely be helpful to add. I made a couple of suggestions & would appreciate it if you could take a look.

Comment on lines +39 to 40
#' @param combine Combine plots into a single \code{\link[patchwork]{patchwork}ed} with single shared figure legend when \code{fast=FALSE}
#' ggplot object. If \code{FALSE}, return a list of ggplot objects
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#' @param combine Combine plots into a single \code{\link[patchwork]{patchwork}ed} with single shared figure legend when \code{fast=FALSE}
#' ggplot object. If \code{FALSE}, return a list of ggplot objects
#' @param combine Combine plots into a single \code{\link[patchwork]{patchwork}ed} ggplot object with
#' single shared figure legend when \code{fast=FALSE}. If \code{FALSE}, return a list of ggplot objects

#' @param combine Combine plots into a single \code{\link[patchwork]{patchwork}ed}
#' @param combine Combine plots into a single \code{\link[patchwork]{patchwork}ed} with single shared figure legend when \code{fast=FALSE}
#' ggplot object. If \code{FALSE}, return a list of ggplot objects
#' @param leg.pos When \code{combine=TRUE}, allows legend position to be adjusted for \code{\link[patchwork]{patchwork}ed} output; defaults as \code{"right"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#' @param leg.pos When \code{combine=TRUE}, allows legend position to be adjusted for \code{\link[patchwork]{patchwork}ed} output; defaults as \code{"right"}
#' @param legend.position When \code{combine=TRUE}, allows legend position to be adjusted for \code{\link[patchwork]{patchwork}ed} output; defaults as \code{"right"}

Renaming this parameter to legend.position would make its purpose a bit more clear to users.

slot = 'scale.data',
assays = NULL,
combine = TRUE,
leg.pos = "right"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
leg.pos = "right"
legend.position = "right"

plots <- wrap_plots(plots, ncol = ncol, guides = "collect")
plots <- wrap_plots(plots, ncol = ncol, guides = "collect") +
plot_layout(guides = "collect") &
theme(legend.position = leg.pos)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
theme(legend.position = leg.pos)
theme(legend.position = legend.position)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function documentation will need to be updated to also import plot_layout (line 47):

#' @importFrom patchwork wrap_plots plot_layout

Otherwise, users will receive an error running DimHeatmap when the patchwork package isn't loaded (Error in plot_layout(guides = "collect") : could not find function "plot_layout").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Improve DimHeatmap documentation and add PC number title for ggplot2 output

2 participants