|
39 | 39 | #' If NULL, all the subgroups in `subgroup_by` will be included. |
40 | 40 | #' If a vector, the subgroups will be included in the order of the vector for all `groups`. |
41 | 41 | #' If a list, the subgroups will be used for each `groups`, with `groups` as the names. |
| 42 | +#' @param within_subgroup Whether to select the clones within each subgroup. |
42 | 43 | #' @param subgroups The subgroups to include in the plot. Default is NULL. |
43 | 44 | #' @param facet_by The column name in the meta data to facet the plots. Default: NULL. |
44 | 45 | #' This argument is not supported and will raise an error if provided. |
|
47 | 48 | #' Note that the clones will be ordered by the value of this expression in descending order. |
48 | 49 | #' @param y The y-axis variable to use for the plot. Default is NULL. |
49 | 50 | #' * For `bar` plot, Either "TotalSize" or "Count" can be used, representing the total size (# cells) of the selected clones or the number of selected clones, respectively. |
| 51 | +#' @param xlab The x-axis label. Default is NULL. |
| 52 | +#' @param ylab The y-axis label. Default is NULL. |
50 | 53 | #' @param ... Other arguments passed to the specific plot function. |
51 | 54 | #' * For `bar` plot, see [plotthis::BarPlot()]. |
52 | 55 | #' * For `trend` plot, see [plotthis::TrendPlot()]. |
@@ -219,7 +222,7 @@ ClonalStatPlot <- function( |
219 | 222 | if (length(clones_expr) == 1 && grepl("(", clones_expr, fixed = TRUE) && grepl(")", clones_expr, fixed = TRUE)) { |
220 | 223 | selected <- eval(parse(text = clones_expr)) |
221 | 224 | } else { |
222 | | - selected <- filter(data, CloneID %in% clones_expr) |
| 225 | + selected <- filter(data, !!sym("CloneID") %in% clones_expr) |
223 | 226 | } |
224 | 227 | if (!is.null(topn)) { |
225 | 228 | selected <- slice_head(selected, n = topn) |
@@ -278,7 +281,7 @@ ClonalStatPlot <- function( |
278 | 281 | pivot_longer(cols = groups, names_to = group_by, values_to = "Size") %>% |
279 | 282 | dplyr::filter(!!sym("Size") > 0) %>% |
280 | 283 | dplyr::group_by(!!!syms(unique(c("CloneGroups", group_by, subgroup_by, facet_by, split_by)))) %>% |
281 | | - summarise(TotalSize = sum(Size), Count = n(), .groups = "drop") |
| 284 | + summarise(TotalSize = sum(!!sym("Size")), Count = n(), .groups = "drop") |
282 | 285 |
|
283 | 286 | BarPlot(data, x = group_by, y = y %||% "TotalSize", group_by = "CloneGroups", group_name = clone_groups_name, |
284 | 287 | facet_by = facet_by, split_by = split_by, xlab = xlab, ylab = ylab, ...) |
@@ -322,7 +325,7 @@ ClonalStatPlot <- function( |
322 | 325 | data <- data %>% pivot_longer(cols = groups, names_to = group_by, values_to = "Size") %>% |
323 | 326 | dplyr::filter(!!sym("Size") > 0) %>% |
324 | 327 | dplyr::group_by(!!!syms(unique(c("CloneGroups", group_by, subgroup_by, facet_by, split_by)))) %>% |
325 | | - summarise(TotalSize = sum(Size), .groups = "drop") |
| 328 | + summarise(TotalSize = sum(!!sym("Size")), .groups = "drop") |
326 | 329 | TrendPlot(data, x = group_by, y = "TotalSize", group_by = "CloneGroups", group_name = clone_groups_name, |
327 | 330 | facet_by = facet_by, split_by = split_by, xlab = xlab, ylab = ylab, ...) |
328 | 331 | } |
|
0 commit comments