olink_boxplot: Function which plots boxplots of selected variables

View source: R/olink_boxplot.R

olink_boxplotR Documentation

Description

Generates faceted boxplots of NPX vs. grouping variable(s) for a given list of proteins (OlinkIDs) using ggplot2::ggplot and ggplot2::geom_boxplot.

Usage

olink_boxplot(
  df,
  variable,
  olinkid_list,
  verbose = FALSE,
  number_of_proteins_per_plot = 6,
  posthoc_results = NULL,
  ttest_results = NULL,
  check_log = NULL,
  ...
)

Arguments

df

NPX data frame in long format with at least protein name (Assay), OlinkID (unique), UniProt and at least one grouping variable.

variable

A character vector or character value indicating which column to use as the x-axis and fill grouping variable. The first or single value is used as x-axis, the second as fill. Further values in a vector are not plotted.

olinkid_list

Character vector indicating which proteins (OlinkIDs) to plot.

verbose

Boolean. If the plots are shown as well as returned in the list (default is false).

number_of_proteins_per_plot

Number of boxplots to include in the facet plot (default 6).

posthoc_results

Data frame from ANOVA posthoc analysis using olink_anova_posthoc() function.

ttest_results

Data frame from ttest analysis using olink_ttest() function.

check_log

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

...

coloroption passed to specify color order.

Value

A list of objects of class “ggplot” (the actual ggplot object is entry 1 in the list). Box and whisker plot of NPX (y-axis) by variable (x-axis) for each Assay.

Examples



if (rlang::is_installed(pkg = c("broom", "car"))) {
  npx_df <- npx_data1 |>
    dplyr::filter(
      !grepl(pattern = "control|ctrl",
             x = .data[["SampleID"]],
             ignore.case = TRUE)
    )
  anova_results <- OlinkAnalyze::olink_anova(
    df = npx_df,
    variable = "Site"
  )
  significant_assays <- anova_results |>
    dplyr::filter(
      .data[["Threshold"]] == "Significant"
    ) |>
    dplyr::pull(
      .data[["OlinkID"]]
    )
  OlinkAnalyze::olink_boxplot(
    df = npx_df,
    variable = "Site",
    olinkid_list = significant_assays,
    verbose = TRUE,
    number_of_proteins_per_plot = 3L
  )
}



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