Skip to contents

Generates a Principal Component Analysis (PCA) plot for visualizing QC samples, with options for filtering, transformations, and customizable visual elements.

Usage

plot_pca(
  data = NULL,
  variable,
  filter_data,
  pca_dim = c(1, 2),
  qc_types = c("SPL", "BQC", "TQC", "NIST", "LTR"),
  label_mad_threshold = 3,
  log_transform = TRUE,
  exclude_istds = TRUE,
  min_median_signal = NA,
  point_size = 2,
  point_alpha = 0.7,
  ellipse_alpha = 0.8,
  font_base_size = 8,
  hide_text_from_labels = NA
)

Arguments

data

MidarExperiment object containing the QC data

variable

Variable to use for PCA analysis. Must be one of: "area", "height", "intensity", "response", "conc", "conc_raw", "rt", "fwhm"

filter_data

Use all (default) or qc-filtered data

pca_dim

PCA dimensions to plot as a vector of length 2. Default is c(1,2)

qc_types

QC types to include in the plot. Default is c("SPL", "BQC", "TQC", "NIST", "LTR")

label_mad_threshold

Show analysis_id label for points outside k * MAD of the selected PCA dimensions. Default is 3. Set NULL to suppress labels

log_transform

Whether to log-transform data before PCA. Default is TRUE

exclude_istds

Whether to exclude internal standards. Default is TRUE

min_median_signal

Minimum median signal across all samples from selected QC types. NA (default) will not filter any features

point_size

Size of plot points. Default is 2

point_alpha

Transparency of plot points (0-1). Default is 0.7

ellipse_alpha

Transparency of ellipse fill (0-1). Default is 0.8

font_base_size

Base font size for plot text elements. Default is 8

hide_text_from_labels

Hide shared text (case-sensitive) in labels. If resulting in non-unique analysis_id's, an error will be raised

Value

A ggplot2 object