Skip to contents

Function to correct for run-order drifts within or across batches via a provided custom function #' @details The drift correction function needs to be provided by the user. See smooth_fun for details.

Usage

corr_drift_fun(
  data = NULL,
  smooth_fun,
  variable,
  reference_qc_types,
  within_batch,
  replace_previous = TRUE,
  log_transform_internal = TRUE,
  conditional_correction = FALSE,
  cv_ratio_threshold = 1,
  use_original_if_fail = TRUE,
  ignore_istd = TRUE,
  feature_list = NULL,
  recalc_trend_after = FALSE,
  show_progress = TRUE,
  ...
)

Arguments

data

MidarExperiment object

smooth_fun

Function that performs drift correction. Function need to have following parameter data (MidarExperiment), reference_qc_types (one or more strings), and span_width (numerical). Function needs to return a numerical vector with the length of number of rows in data. In case functions fails a vector with NA_real_ needs be returned

variable

The variable to be corrected for drift effects. Must be one of "intensity", "norm_intensity", or "conc"

reference_qc_types

QC types used for drift correction

within_batch

Apply to each batch separately if TRUE (the default)

replace_previous

Logical. Replace previous correction (TRUE), or adds on top of previous correction (FALSE). Default is TRUE.

log_transform_internal

Apply log transformation internally for smoothing if TRUE (default). This enhances robustness against outliers but does not affect the final data, which remains untransformed.

conditional_correction

Determines whether drift correction should be applied to all species unconditionally (TRUE) or only when the sample CV after smoothing is below the ratio threshold specified by cv_ratio_threshold.

cv_ratio_threshold

This parameter defines the maximum allowable change (ratio) in the coefficient of variation (CV) ratio of samples before and after smoothing for the correction to be applied. A value of 1 (the default) requires the CV to improve, while a value above 1 allows the CV to improve, or to degrade by a maximum of the indicated fold-difference times post-smoothing.

use_original_if_fail

Determines the action when smoothing fails for a feature. If TRUE (default), the original data is used; if FALSE, the result for each analysis is NA.

ignore_istd

Do not apply corrections to ISTDs

feature_list

Subset the features for correction whose names matches the specified text using regular expression. Default is NULL which means all features are selected.

recalc_trend_after

Recalculate trend post-drift correction for plot_qc_runscatter(). This will double calculation time.

show_progress

Show progress bar. Default = `TRUE.

...

Parameters specific for the smoothing function

Value

MidarExperiment object