Creates publication-ready PCA plots with scientific color palettes, flexible aesthetic mapping, and multiple visualization options. Designed specifically for neural activity and omics datasets with support for complex experimental designs including treatments, genotypes, and timepoints.
pca_plots_enhanced(
pca_output = NULL,
plot_data = NULL,
pca_result = NULL,
output_dir = NULL,
processing_result = NULL,
experiment_name = NULL,
grouping_variables = NULL,
color_variable = "Treatment",
shape_variable = "Genotype",
secondary_shape_variable = "Timepoint",
pannels_var = NULL,
components = c(1, 2),
gray_color_value = NULL,
save_plots = FALSE,
plot_width = 12,
plot_height = 10,
dpi = 300,
verbose = TRUE
)A list containing:
Named list of ggplot objects for each plot type
Data.frame with plotting data and metadata
Numeric vector of variance explained by each component
Numeric vector of components used in plots
Named character vector of colors used
Named numeric vector of shapes used
List of configuration parameters used
Character vector of saved file paths (if save_plots = TRUE)
List. Complete PCA output object from pca_analysis_enhanced() (optional)
Data.frame. Data containing PC coordinates and metadata variables
List. PCA result object (e.g., from prcomp() or princomp())
Character. Directory path for saving plots (default: NULL, no files saved)
List. Result object from process_mea_flexible() (optional)
Character. Name for the experiment (used in titles and filenames)
Character vector. Available metadata variables for plotting (default: c("Treatment", "Genotype", "Timepoint"))
Character. Variable name for color aesthetic (default: "Treatment")
Character. Variable name for shape aesthetic (default: "Genotype")
Character. Alternative shape variable (default: "Timepoint")
Character. Variable for panel faceting (default: NULL)
Numeric vector. PC components to plot (default: c(1, 2))
Character. Specific value of color_variable to display in gray (default: NULL)
Logical. Whether to save plots to files (default: FALSE)
Numeric. Plot width in inches (default: 12)
Numeric. Plot height in inches (default: 10)
Numeric. Plot resolution (default: 300)
Logical. Whether to print progress messages (default: TRUE)
The function creates up to 5 different plot variants. Files are only saved when save_plots = TRUE AND output_dir is explicitly provided.
process_mea_flexible for MEA data processing,
discover_mea_structure for automatic data structure detection