Function to correct for run-order drifts within or across batches using loess smoothing
Usage
correct_drift_loess(
data = NULL,
variable,
reference_qc_types,
within_batch = TRUE,
replace_previous = TRUE,
span = 0.75,
conditional_correction = FALSE,
log_transform_internal = TRUE,
feature_list = NULL,
ignore_istd = TRUE,
cv_ratio_threshold = 1,
use_original_if_fail = TRUE,
extrapolate = FALSE
)
Arguments
- data
MidarExperiment object
- 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), or across all batches ifFALSE
.- replace_previous
Logical. Replace previous correction (
TRUE
), or adds on top of previous correction (FALSE
). Default isTRUE
.- span
Loess span width (default is 0.75)
- 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 bycv_ratio_threshold
.- log_transform_internal
Log transform the data for correction when
TRUE
(the default). Note: log transformation is solely applied internally for smoothing, results will not be be log-transformed. Log transformation may result in more robust smoothing that is less sensitive to outlier.- 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.- ignore_istd
Do not apply corrections to ISTDs
- 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.
- extrapolate
Extrapolate loess smoothing. WARNING: It is generally not recommended to extrapolate outside of the range spanned by the QCs used for smoothing. See details below.
Details
Note that using extrapolation for loess smoothing is generally not recommended. Use this only if you must include samples or QCs that are outside of the range spanned by the QCs used for smoothing. Cases where this may be necessary are when specific drifts occur in analysis sequence segments that are not spanned by QC, e.g. when the instrument broke down or suddenly changed its sensitivity. Only use for samples adjacent to the first or last QC and consult runscatter plots.