Skip to content

Commit f45812a

Browse files
committed
chore(CellStatPlot): default 'ident' of to the active.ident of given object
1 parent c2c4644 commit f45812a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

R/cellstatplot.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#' @description Plot the statistics of the cells.
44
#'
55
#' @param object A Seurat object
6-
#' @param ident The column with the cell identities. i.e. clusters. Default: seurat_clusters
6+
#' @param ident The column with the cell identities. i.e. clusters. Default: NULL
7+
#' If NULL, the active identity of the Seurat object and the name "Identity" will be used.
78
#' For 'pies', this will be used as the `pie_group_by`.
89
#' For 'heatmap' plot, this will be used as the rows of the heatmap.
910
#' @param group_by The column name in the meta data to group the cells. Default: NULL
@@ -66,6 +67,7 @@
6667
#'
6768
#' @return A ggplot object or a list if `combine` is FALSE
6869
#' @importFrom rlang sym syms
70+
#' @importFrom SeuratObject Idents
6971
#' @importFrom dplyr %>% summarise mutate ungroup n
7072
#' @importFrom tidyr drop_na pivot_wider pivot_longer
7173
#' @importFrom plotthis BarPlot CircosPlot PieChart RingPlot TrendPlot AreaPlot SankeyPlot Heatmap RadarPlot SpiderPlot ViolinPlot BoxPlot
@@ -152,13 +154,17 @@
152154
#' x_text_angle = 60, comparisons = TRUE, aspect.ratio = 0.8)
153155
#' }
154156
CellStatPlot <- function(
155-
object, ident = "seurat_clusters", group_by = NULL, group_by_sep = "_",
157+
object, ident = NULL, group_by = NULL, group_by_sep = "_",
156158
split_by = NULL, split_by_sep = "_", facet_by = NULL, rows = NULL, columns_split_by = NULL,
157159
frac = c("none", "group", "ident", "cluster", "all"), rows_name = NULL, name = NULL,
158160
plot_type = c("bar", "circos", "pie", "pies", "ring", "donut", "trend", "area", "sankey", "alluvial", "heatmap", "radar", "spider", "violin", "box"),
159161
swap = FALSE, ylab = NULL, ...
160162
) {
161163
data <- object@meta.data
164+
if (is.null(ident)) {
165+
ident <- "Identity"
166+
data[[ident]] <- Idents(object)
167+
}
162168

163169
plot_type <- match.arg(plot_type)
164170
if (plot_type == "donut") plot_type <- "ring"

man/CellStatPlot.Rd

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy