sccomp_remove_unwanted_variation: sccomp_remove_unwanted_variation

View source: R/methods.R

sccomp_remove_unwanted_variationR Documentation

sccomp_remove_unwanted_variation

Description

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.

Usage

sccomp_remove_unwanted_variation(
  .data,
  formula_composition_keep = NULL,
  formula_composition = NULL,
  formula_variability = NULL,
  cores = detectCores()
)

Arguments

.data

A tibble. The result of sccomp_estimate.

formula_composition_keep

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.

formula_composition

DEPRECATED. Use formula_composition_keep instead.

formula_variability

DEPRECATED. Use formula_variability_keep instead.

cores

Integer, the number of cores to be used for parallel calculations.

Value

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.

Examples


message("Use the following example after having installed cmdstanr with install.packages(\"cmdstanr\", repos = c(\"https://stan-dev.r-universe.dev/\", getOption(\"repos\")))")


  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()
  }



stemangiola/sccomp documentation built on Dec. 20, 2024, 8:38 a.m.