Skip to content

Commit

Permalink
optimized plotProportionPie
Browse files Browse the repository at this point in the history
  • Loading branch information
mvfki committed Sep 2, 2024
1 parent 8deb5ea commit 287d7ac
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Added `plotBarcodeRank()` for basic QC visualization
- Added `plotPairwiseDEGHeatmap()` for visualizing pairwise DEG results
- Added `plotGODot()` for visualizing GO enrichment results
- Optimized `plotProportionPie()` by adding argument `circleColors`
- Optimized `plotVolcano()` text annotation positioning
- Optimized visualization function additional argument documentation
- Added `calcNMI()` for evaluating clustering results against ground truth
Expand Down
11 changes: 11 additions & 0 deletions R/visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,17 @@ plotClusterProportions <- function(
}

#' @rdname plotProportion
#' @param circleColors Character vector of colors. \code{plotProportionPie}
#' parameter for setting the colors of circles, i.e. categorical variable
#' controlled by \code{class2}. Default \code{NULL} uses ggplot default hues.
#' @export
plotProportionPie <- function(
object,
class1 = NULL,
class2 = "dataset",
labelSize = 4,
labelColor = "white",
circleColors = NULL,
...
) {
class1 <- class1 %||% object@uns$defaultCluster
Expand Down Expand Up @@ -570,6 +574,13 @@ plotProportionPie <- function(
colour = .data[[class2]]),
linewidth = 2
)
if (!is.null(circleColors)) {
if (length(circleColors) < length(class2Uniq)) {
cli::cli_alert_warning("Less {.field circleColors} ({.val {length(circleColors)}}) specified than required from {.val {class2}} ({.val {length(class2Uniq)}}). Using default.")
} else {
p <- p + ggplot2::scale_color_manual(values = circleColors)
}
}

if (!requireNamespace("ggrepel", quietly = TRUE)) {
p <- p + ggplot2::geom_text(
Expand Down
5 changes: 5 additions & 0 deletions man/plotProportion.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 287d7ac

Please sign in to comment.