plot_BeforeAfter.RdCreates comprehensive visualizations comparing data distributions and patterns before and after preprocessing steps. Generates density plots and box plots from either sample or feature perspectives to assess preprocessing effectiveness. Supports both PCA and PLS scaled data visualization with intelligent random sampling for large datasets.
plot_BeforeAfter(
data,
scaled = "PLS",
group_by = "Sample",
n_random_samples = 30L,
n_random_features = 30L,
seed = 123L
)List. A preprocessing results object from perform_PreprocessingPeakData
function containing original data, transformed data, and metadata.
Character. Specifies which preprocessed data to visualize:
"PCA": Uses PCA-scaled preprocessed data
"PLS": Uses PLS-scaled preprocessed data
Default: "PLS"
Character. Visualization perspective:
"Sample": Visualizes sample-wise distributions
"Feature": Visualizes feature-wise distributions
Default: "Sample"
Integer. Number of random samples to display in box plots.
If NULL, uses all samples. If specified number exceeds total samples,
uses all available samples. Default: 30
Integer. Number of random features to display in box plots.
If NULL, uses all features. If specified number exceeds total features,
uses all available features. Default: 30
Integer. Random seed for reproducible sample/feature selection.
Default: 123
List containing:
FunctionOrigin: Character indicating function source
data_before: Matrix of original data (non-QC samples)
data_after: Matrix of transformed data (non-QC samples)
plot_density_before: ggplot2 density plot of original data
plot_density_after: ggplot2 density plot of transformed data
plot_box_before: ggplot2 box plot of original data
plot_box_after: ggplot2 box plot of transformed data
plot_combined: Combined 2x2 grid plot
processing_info: List with processing metadata
if (FALSE) { # \dontrun{
# Basic usage with PLS scaling
plots <- plot_BeforeAfter(
data = preprocessing_results,
scaled = "PLS",
group_by = "Sample"
)
# Feature perspective with PCA scaling
feature_plots <- plot_BeforeAfter(
data = preprocessing_results,
scaled = "PCA",
group_by = "Feature",
n_random_features = 20
)
# Display combined plot
print(plots$plot_combined)
} # }