sccomp_boxplot | R Documentation |
Creates a boxplot visualization of the model results from sccomp
. This function plots the estimated cell proportions across samples, highlighting significant changes in cell composition according to a specified factor.
sccomp_boxplot(
.data,
factor,
significance_threshold = 0.05,
test_composition_above_logit_fold_change = attr(.data,
"test_composition_above_logit_fold_change"),
remove_unwanted_effects = FALSE
)
.data |
A tibble containing the results from |
factor |
A character string specifying the factor of interest included in the model for stratifying the boxplot. |
significance_threshold |
A numeric value indicating the False Discovery Rate (FDR) threshold for labeling significant cell-groups. Defaults to 0.05. |
test_composition_above_logit_fold_change |
A positive numeric value representing the effect size threshold used in the hypothesis test. A value of 0.2 corresponds to a change in cell proportion of approximately 10% for a cell type with a baseline proportion of 50% (e.g., from 45% to 55%). This threshold is consistent on the logit-unconstrained scale, even when the baseline proportion is close to 0 or 1. |
remove_unwanted_effects |
A logical value indicating whether to remove unwanted variation from the data before plotting. Defaults to |
A ggplot
object representing the boxplot of cell proportions across samples, stratified by the specified factor.
# Note: Before running the example, ensure that the 'cmdstanr' package is installed:
# install.packages("cmdstanr", repos = c("https://stan-dev.r-universe.dev/", getOption("repos")))
if (instantiate::stan_cmdstan_exists()) {
data("counts_obj")
estimate <- sccomp_estimate(
counts_obj,
formula_composition = ~ type,
formula_variability = ~ 1,
.sample = sample,
.cell_group = cell_group,
.count = count,
cores = 1
) %>%
sccomp_test()
# Plot the boxplot of estimated cell proportions
sccomp_boxplot(
.data = estimate,
factor = "type",
significance_threshold = 0.05
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.