This function uses the model to remove unwanted variation from a dataset using the estimates of the model. For example, if you fit your data with the formula ~ factor_1 + factor_2
and use the formula ~ factor_1
to remove unwanted variation, the factor_2
effect will be factored out.
sccomp_remove_unwanted_variation(
.data,
formula_composition_keep = NULL,
formula_composition = NULL,
formula_variability = NULL,
cores = detectCores()
)
A tibble. The result of sccomp_estimate
.
A formula. The formula describing the model for differential abundance, for example ~type
. In this case, only the effect of the type
factor will be preserved, while all other factors will be factored out.
DEPRECATED. Use formula_composition_keep
instead.
DEPRECATED. Use formula_variability_keep
instead.
Integer, the number of cores to be used for parallel calculations.
A tibble (tbl
) with the following columns:
sample - A character column representing the sample name for which data was adjusted.
cell_group - A character column representing the cell group being tested.
adjusted_proportion - A numeric column representing the adjusted proportion after removing unwanted variation.
adjusted_counts - A numeric column representing the adjusted counts after removing unwanted variation.
logit_residuals - A numeric column representing the logit residuals calculated after adjustment.
message("Use the following example after having installed cmdstanr with install.packages(\"cmdstanr\", repos = c(\"https://stan-dev.r-universe.dev/\", getOption(\"repos\")))")
#> Use the following example after having installed cmdstanr with install.packages("cmdstanr", repos = c("https://stan-dev.r-universe.dev/", getOption("repos")))
# \donttest{
if (instantiate::stan_cmdstan_exists()) {
data("counts_obj")
estimates = sccomp_estimate(
counts_obj,
~ type, ~1, sample, cell_group, count,
cores = 1
) |>
sccomp_remove_unwanted_variation()
}
# }