combat_harm function

ComBatFamily Harmonization

ComBatFamily Harmonization

Conduct harmonization using four types of methods: 1) Original ComBat, 2) Longitudinal ComBat, 3) ComBat-GAM, and 4) CovBat.

combat_harm( eb_check = FALSE, result = NULL, features = NULL, batch = NULL, covariates = NULL, df = NULL, type = "lm", random = NULL, smooth = NULL, interaction = NULL, smooth_int_type = NULL, family = "comfam", eb = TRUE, ref.batch = NULL, predict = FALSE, object = NULL, reference = NULL, out_ref_include = TRUE, ... )

Arguments

  • eb_check: A boolean variable indicating whether the user wants to run the EB assumption test before harmonization.
  • result: A list derived from visual_prep() that contains dataset and batch effect diagnostic information for Shiny visualization. Can be skipped if features, batch, covariates and df are provided.
  • features: The name of the features to be harmonized. This can be skipped if result is provided.
  • batch: The name of the batch variable. Can be skipped if result is provided.
  • covariates: The names of covariates supplied to model. This can be be skipped if result is provided.
  • df: Dataset to be harmonized. This can be be skipped if result is provided.
  • type: The name of a regression model to be used: "lmer", "lm", "gam".
  • random: The variable name of a random effect in linear mixed effect model.
  • smooth: The name of the covariates that require a smooth function.
  • interaction: Expression of interaction terms supplied to model (eg: "age,diagnosis").
  • smooth_int_type: A vector that indicates the types of interaction in gam models. By default, smooth_int_type is set to be NULL, "linear" represents linear interaction terms. "categorical-continuous", "factor-smooth" both represent categorical-continuous interactions ("factor-smooth" includes categorical variable as part of the smooth), "tensor" represents interactions with different scales, and "smooth-smooth" represents interaction between smoothed variables.
  • family: The type of combat family to use, comfam or covfam.
  • eb: If TRUE, uses ComBat model with empirical Bayes for mean and variance harmonization
  • ref.batch: The name of the reference batch.
  • predict: A boolean variable indicating whether to run ComBat from scratch or apply existing model to new dataset (currently only work for original ComBat and ComBat-GAM).
  • object: Existing ComBat model.
  • reference: Dataset to be considered as the reference group.
  • out_ref_include: A boolean variable indicating whether the reference data should be included in the harmonized data output.
  • ...: Additional arguments to comfam or covfam models.

Returns

If the eb_check is set to be FALSE, then combat_harm returns a list containing the following components: - com_family: ComBat family to be considered: comfam, covfam

  • harmonized_df: Harmonized dataset

  • combat.object: Saved ComBat model and relevant information, such as the batch variable name and whether the EB method is used

If eb_check is set to be TRUE, then combat_harm will return a dataframe with the EB assumption test result.

Examples

combat_harm(features = colnames(adni)[43:53], batch = "manufac", covariates = c("AGE", "SEX", "DIAGNOSIS"), df = head(adni,100), type = "lm")