Skip to content

Commit 3b13108

Browse files
committed
feat: allow scale of ClonalCompositionPlot to be TRUE/"sample"/FALSE
1 parent d169c26 commit 3b13108

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

R/clonalstatplot.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,10 @@ ClonalResidencyPlot <- function(
870870
#' * For "homeostasis", "homeo", "rel" - Default is `list(Rare = 1e-04, Small = 0.001, Medium = 0.01, Large = 0.1, Hyperexpanded = 1)`.
871871
#' * For "top" - Default is `c(10, 100, 1000, 10000, 30000, 100000)`.
872872
#' * For "rare" - Default is `c(1, 3, 10, 30, 100)`.
873-
#' @param scale Whether to scale the number to 1 for each sample. Default is TRUE.
873+
#' @param scale Whether to scale the values on the y-axis. Default is TRUE.
874+
#' * TRUE: The values of each group (on the x-axis) will be scaled to 1.
875+
#' * FALSE: No scaling.
876+
#' * "sample"/"Sample": The values in each sample will be scaled to 1.
874877
#' @param facet_by The column name in the meta data to facet the plots. Default: NULL
875878
#' @param group_by The column name in the meta data to group the cells. Default: NULL
876879
#' @param split_by The column name in the meta data to split the plots. Default: NULL
@@ -1009,6 +1012,11 @@ ClonalCompositionPlot <- function(
10091012
group_name <- ifelse(method == "top", "Clonal Indices", "Clonal Sizes")
10101013

10111014
if (isTRUE(scale)) {
1015+
data <- data %>%
1016+
dplyr::group_by(!!!syms(c(group_by, facet_by, split_by))) %>%
1017+
mutate(.values = !!sym(".values") / sum(!!sym(".values")))
1018+
ylab <- ylab %||% "Relative Abundance"
1019+
} else if (identical(scale, "sample") || identical(scale, "Sample")) {
10121020
data <- data %>%
10131021
dplyr::group_by(!!!syms(c("Sample", group_by, facet_by, split_by))) %>%
10141022
mutate(.values = !!sym(".values") / sum(!!sym(".values")))

0 commit comments

Comments
 (0)