olink_qc_plot: Function to plot an overview of a sample cohort per Panel.

View source: R/olink_qc_plot.R

olink_qc_plotR Documentation

Description

Generates a facet plot per Panel using ggplot2::ggplot and ggplot2::geom_point and stats::IQR plotting IQR vs. median for all samples. Horizontal dashed lines indicate \pmIQR_outlierDef standard deviations from the mean IQR (default 3). Vertical dashed lines indicate \pmmedian_outlierDef standard deviations from the mean sample median (default 3).

Usage

olink_qc_plot(
  df,
  check_log = NULL,
  color_g = "QC_Warning",
  plot_index = FALSE,
  label_outliers = FALSE,
  IQR_outlierDef = 3L,
  median_outlierDef = 3L,
  outlierLines = TRUE,
  facetNrow = NULL,
  facetNcol = NULL,
  ...
)

Arguments

df

NPX data frame in long format. Must have columns SampleID, NPX and Panel.

check_log

A named list returned by check_npx(). If NULL, check_npx() will be run internally using df.

color_g

Character value indicating which column to use as fill color (default QC_Warning). Continuous color scale for Olink(R) Sample Index (OSI) columns OSITimeToCentrifugation, OSIPreparationTemperature and OSISummary is also supported.

plot_index

Boolean. If FALSE (default), a point will be plotted for a sample. If TRUE, a sample's unique index number is displayed.

label_outliers

Boolean. If TRUE, an outlier sample will be labelled with its SampleID. (default FALSE)

IQR_outlierDef

The number of standard deviations from the mean IQR that defines an outlier. (default 3)

median_outlierDef

The number of standard deviations from the mean sample median that defines an outlier. (default 3)

outlierLines

Draw dashed lines at \pmIQR_outlierDef and \pmmedian_outlierDef standard deviations from the mean IQR and sample median respectively. (default TRUE)

facetNrow

The number of rows that the panels are arranged on.

facetNcol

The number of columns that the panels are arranged on.

...

coloroption passed to specify color order.

Value

An object of class "ggplot". Scatterplot shows IQR vs median for all samples per panel

Examples


if (rlang::is_installed(pkg = c("ggrepel"))) {

  # standard plot
  OlinkAnalyze::olink_qc_plot(
    df = npx_data1,
    color_g = "QC_Warning",
    label_outliers = TRUE
  )

  # Change the outlier threshold to +/-4SD
  OlinkAnalyze::olink_qc_plot(
    df = npx_data1,
    color_g = "QC_Warning",
    IQR_outlierDef = 4L,
    median_outlierDef = 4L,
    label_outliers = TRUE
  )

  # Identify the outliers
  qc <- OlinkAnalyze::olink_qc_plot(
    df = npx_data1,
    color_g = "QC_Warning",
    IQR_outlierDef = 4L,
    median_outlierDef = 4L,
    label_outliers = TRUE
  )

  outliers <- qc$data |>
    dplyr::filter(
      .data[["Outlier"]] == 1L
    )
}



OlinkAnalyze documentation built on June 24, 2026, 1:06 a.m.