Bridging Plates and Projects
NPX is relative to the run that produced it, so NPX values from two projects cannot go into one analysis as they stand. Bridging puts them on one scale through samples that both projects measured. This page runs Olink’s bridge normalization on the two example projects of OlinkAnalyze, reads the adjustment factor of each assay, and compares the result with intensity normalization. It runs in R only. Bridge normalization is a function of OlinkAnalyze, Olink’s R package, and the page calls that function rather than a rewrite of it in Python. The Experimental design page covers how to plan bridge samples before the first run.
The two projects
Section titled “The two projects”npx_data1 and npx_data2 are long NPX tables in the layout of an Olink export, with a
plate ID, a QC warning and an LOD on every row. The code counts what each one holds and
finds the samples that both contain.
suppressPackageStartupMessages({ library(OlinkAnalyze) library(dplyr) library(tidyr) library(ggplot2)})dir.create("outputs", showWarnings = FALSE)
#' Print the size of one NPX project.#'#' @param df An NPX table in long format.#' @param name The label to print for the project.#' @return NULL, invisibly. The function prints one line.DescribeProject <- function(df, name) { warned <- n_distinct(df$SampleID[df$QC_Warning != "Pass"]) cat(sprintf( "%s: %d rows, %d sample IDs, %d assays, %d plates, %d warned\n", name, nrow(df), n_distinct(df$SampleID), n_distinct(df$OlinkID), n_distinct(df$PlateID), warned )) invisible(NULL)}
DescribeProject(npx_data1, "npx_data1")DescribeProject(npx_data2, "npx_data2")cat(sprintf( "panels: %s\n", paste(unique(npx_data1$Panel), collapse = ", ")))cat(sprintf( "same OlinkIDs in both: %s\n", setequal(npx_data1$OlinkID, npx_data2$OlinkID)))
# Control samples repeat their names across runs but are not bridges.shared_ids <- intersect(npx_data1$SampleID, npx_data2$SampleID)bridge_ids <- shared_ids[!grepl("^CONTROL_SAMPLE", shared_ids)]cat(sprintf( "shared sample IDs: %d, bridge samples: %d\n", length(shared_ids), length(bridge_ids)))cat(sprintf("bridge samples: %s\n", paste(bridge_ids, collapse = ", ")))npx_data1 |> filter(SampleID %in% bridge_ids) |> distinct(SampleID, PlateID) |> count(PlateID, name = "bridge_samples") |> as.data.frame() |> print()npx_data1: 29440 rows, 158 sample IDs, 184 assays, 4 plates, 3 warnednpx_data2: 32384 rows, 174 sample IDs, 184 assays, 4 plates, 3 warnedpanels: Olink Cardiometabolic, Olink Inflammationsame OlinkIDs in both: TRUEshared sample IDs: 18, bridge samples: 16bridge samples: A13, A29, A30, A36, A45, A46, A52, A63, A71, A73, B3, B4, B37, B45, B63, B75 PlateID bridge_samples1 Example_Data_13_INFI.csv 102 Example_Data_14_INFI.csv 63 Example_Data_1_CAM.csv 104 Example_Data_2_CAM.csv 6Both projects measure the same 184 assays on two panels, each panel on two plates. Three
samples in each project carry a QC warning. Eighteen sample IDs appear in both, but two of
them are the control samples CONTROL_SAMPLE_AS 1 and CONTROL_SAMPLE_AS 2. Olink’s
bridging tutorial
warns that external controls can share a name across datasets and still be different
samples, from different reagent batches, so the code drops them. That leaves the 16
bridge samples that the help page of npx_data2 lists, ten on the first plate of each
panel and six on the second.
Why two projects need bridging
Section titled “Why two projects need bridging”Inside one project, Olink normalizes NPX against the plate controls or, for a project of several plates, by intensity normalization, so the samples of that project share a scale. A second project gets its own normalization, and nothing ties its scale to the first. The bridging tutorial asks for bridging when batches ran at different times, when plate control normalized data come from changed run conditions or reagent lots, and when intensity normalized data come from two different sample populations. The 16 bridge samples show the offset between the projects directly.
# The NPX of the same 16 samples in the two projects, paired by sample.paired <- npx_data1 |> filter(SampleID %in% bridge_ids) |> select(SampleID, OlinkID, npx_1 = NPX) |> inner_join( npx_data2 |> filter(SampleID %in% bridge_ids) |> select(SampleID, OlinkID, npx_2 = NPX), by = c("SampleID", "OlinkID") ) |> mutate(difference = npx_1 - npx_2)per_assay <- paired |> group_by(OlinkID) |> summarise( median_difference = median(difference), spread = sd(difference), .groups = "drop" )cat(sprintf("paired values: %d\n", nrow(paired)))quartiles <- quantile(per_assay$median_difference, c(0, 0.25, 0.5, 0.75, 1))cat(sprintf( "median difference per assay, min %.2f, Q1 %.2f, median %.2f, ", quartiles[1], quartiles[2], quartiles[3]))cat(sprintf("Q3 %.2f, max %.2f NPX\n", quartiles[4], quartiles[5]))cat(sprintf( "assays with a median difference of exactly 0: %d of %d\n", sum(per_assay$median_difference == 0), nrow(per_assay)))cat(sprintf( "largest SD of the 16 differences within one assay: %.1e NPX\n", max(per_assay$spread)))paired values: 2944median difference per assay, min -4.08, Q1 -0.34, median 0.00, Q3 0.48, max 3.65 NPXassays with a median difference of exactly 0: 45 of 184largest SD of the 16 differences within one assay: 2.2e-15 NPXThe median difference between the two copies of a bridge sample runs from -4.08 to 3.65 NPX across the 184 assays. An analysis that pooled the projects as they stand would read those offsets as biology.
The last two lines show that the data are synthetic. Within every assay, the 16
differences have a standard deviation of at most 2.2e-15 NPX, which is rounding error.
Each bridge sample in npx_data2 is its npx_data1 copy plus one constant per assay, and
that constant is 0 for 45 assays. Real bridge samples carry the measurement error of each
run, so their differences scatter around the offset and the median estimates it.
Run the bridge normalization
Section titled “Run the bridge normalization”olink_normalization_bridge() takes the median of the paired differences of each assay as
its adjustment factor and adds that factor to every NPX of the project that is not the
reference, as the bridging tutorial and the
OlinkAnalyze reference manual
describe. The reference project keeps its values. The code follows the example of the
manual and makes npx_data1 the reference, P1.
The data preparation and bridge call below adapt the olink_normalization_bridge example in the OlinkAnalyze 5.1.0 source manual. The lesson replaces the control filter, names intermediate objects differently, and adds diagnostics. Olink holds the package copyright, and its DESCRIPTION states AGPL version 3 or later. The compared manual source ships in that licensed archive. The source notice identifies its original files and the lesson changes. The complete AGPL version 3 text accompanies this credit.
# The documented example drops the controls and the Project column, and# adds the Normalization column that a real Explore export carries.project_1 <- npx_data1 |> filter(!grepl("^CONTROL_SAMPLE", SampleID)) |> select(-Project) |> mutate(Normalization = "Intensity")project_2 <- npx_data2 |> filter(!grepl("^CONTROL_SAMPLE", SampleID)) |> select(-Project) |> mutate(Normalization = "Intensity")
bridged <- olink_normalization_bridge( project_1_df = project_1, project_2_df = project_2, bridge_samples = list(DF1 = bridge_ids, DF2 = bridge_ids), project_1_name = "P1", project_2_name = "P2", project_ref_name = "P1")cat(sprintf("rows after bridging: %d\n", nrow(bridged)))cat(sprintf( "adjustment factors in P1: %s\n", paste(unique(bridged$Adj_factor[bridged$Project == "P1"]), collapse = ", ")))
factors <- bridged |> filter(Project == "P2") |> distinct(OlinkID, Assay, Panel, Adj_factor)matched <- inner_join(factors, per_assay, by = "OlinkID")cat(sprintf("assays with a P2 factor: %d\n", nrow(factors)))cat(sprintf( "factor equals the median paired difference: %s\n", isTRUE(all.equal(matched$Adj_factor, matched$median_difference))))size <- cut( abs(factors$Adj_factor), breaks = c(-Inf, 0, 0.5, 1, Inf), labels = c("exactly 0", "up to 0.5", "0.5 to 1", "above 1"))print(table(Panel = factors$Panel, `absolute factor` = size))largest <- factors |> arrange(desc(abs(Adj_factor))) |> head(5)print(as.data.frame(largest), digits = 3)
# After bridging, the P2 copy of each bridge sample matches its P1 copy.bridge_after <- bridged |> filter(SampleID %in% bridge_ids) |> select(SampleID, OlinkID, Project, NPX) |> pivot_wider(names_from = Project, values_from = NPX)cat(sprintf( "largest bridge difference after bridging: %.1e NPX\n", max(abs(bridge_after$P1 - bridge_after$P2))))rows after bridging: 60352adjustment factors in P1: 0assays with a P2 factor: 184factor equals the median paired difference: TRUE absolute factorPanel exactly 0 up to 0.5 0.5 to 1 above 1 Olink Cardiometabolic 19 32 18 23 Olink Inflammation 26 25 23 18 OlinkID Assay Panel Adj_factor1 OID00487 AXIN1 Olink Inflammation -4.082 OID00478 IL7 Olink Inflammation 3.653 OID01233 C2 Olink Cardiometabolic 3.324 OID00553 TNFRSF9 Olink Inflammation -2.875 OID01256 PAM Olink Cardiometabolic -2.41largest bridge difference after bridging: 7.1e-15 NPXP1 keeps a factor of 0, and each of the 184 assays gets one factor for P2 that equals the median paired difference computed by hand. The factor is exactly 0 for 45 assays, 19 on the Cardiometabolic panel and 26 on the Inflammation panel, because their bridge samples carry the same NPX in both datasets. The largest corrections are -4.08 NPX for AXIN1 and 3.65 NPX for IL7. After bridging, the two copies of every bridge sample differ by at most 7.1e-15 NPX. With real data the bridges would still disagree after bridging, by about their measurement error.
The output of 60,352 rows holds both copies of each bridge sample, and the message of the function recommends keeping only the reference copies for downstream analysis. Do that before any test, or each bridge counts twice.
Choosing bridge samples
Section titled “Choosing bridge samples”In a real study you choose the bridge samples from the first project before the second one
runs. olink_bridge_selector() drops the samples that carry a QC warning, that fall
outside the 3 SD lines of olink_qc_plot(), or that have too many assays below LOD. It
then ranks the rest by mean NPX and takes samples evenly spaced along that ranking, so the
bridges cover the range of the data. The bridging tutorial recommends 8 to 16 bridge
samples for Target 96 and for the Explore 384 Cardiometabolic, Inflammation, Neurology and
Oncology panels, and 40 to 64 between Explore 3072 and Explore HT.
# The selector returns its samples in random order, so sort them.selected <- olink_bridge_selector( project_1, sample_missing_freq = 0.1, n = 16L) |> arrange(desc(MeanNPX))print(as.data.frame(selected), digits = 3)cat(sprintf( "selected samples that are bridge samples in npx_data2: %d\n", sum(selected$SampleID %in% bridge_ids)))
# The bridgeability plot is made for bridging two Olink products.plot_attempt <- try(olink_bridgeability_plot(bridged), silent = TRUE)cat(paste0(conditionMessage(attr(plot_attempt, "condition")), "\n")) SampleID PercAssaysBelowLOD MeanNPX1 A20 0.0543 6.542 B20 0.0598 6.463 B65 0.0489 6.394 A67 0.0435 6.355 B13 0.0543 6.326 A53 0.0380 6.287 B55 0.0815 6.268 B35 0.0707 6.249 A77 0.0707 6.2210 B36 0.0707 6.2011 A47 0.0707 6.1512 B79 0.0598 6.1113 B62 0.0543 6.0814 A59 0.0326 6.0715 B9 0.0598 5.9916 B34 0.0543 5.87selected samples that are bridge samples in npx_data2: 0✖ Input dataset lacks a column matching to the key "count"!ℹ Please make sure that it contains a column named: "Count" or "count".The selector picks 16 samples with mean NPX from 5.87 to 6.54. None of them is a bridge
sample of npx_data2, so the example bridges were chosen another way.
olink_bridgeability_plot() does not apply to these projects. It plots bridging between
two Olink products, such as Explore 3072 and Explore HT, and it needs the read counts of
the sequencing readout, which the example data do not carry.
Before and after
Section titled “Before and after”The bridging tutorial checks a bridge with a PCA of both projects together. Before bridging, the projects typically separate along PC1, and after a good bridge they mix. A bridge sample enters the PCA twice, once from each project.
#' Compute the first two principal components of NPX samples.#'#' @param df NPX table in long format with SampleID, Project, OlinkID and#' NPX columns. A bridge sample appears once in each project.#' @param stage Label of the stage, such as "Before bridging".#' @return A list with the PC1 and PC2 scores of each sample and the share#' of the variance that PC1 explains.PcaScores <- function(df, stage) { wide <- df |> mutate(sample = paste(SampleID, Project)) |> select(sample, Project, OlinkID, NPX) |> pivot_wider(names_from = OlinkID, values_from = NPX) pca <- prcomp(as.matrix(select(wide, starts_with("OID"))), scale. = TRUE) list( scores = data.frame( Project = wide$Project, PC1 = pca$x[, 1], PC2 = pca$x[, 2], stage = stage ), pc1_share = pca$sdev[1]^2 / sum(pca$sdev^2) )}
unbridged <- bind_rows( project_1 |> mutate(Project = "P1"), project_2 |> mutate(Project = "P2"))stages <- list( PcaScores(unbridged, "Before bridging"), PcaScores(bridged, "After bridging"))for (stage in stages) { centers <- stage$scores |> group_by(Project) |> summarise(PC1 = mean(PC1)) cat(sprintf( "%s: PC1 explains %.3f, mean PC1 of P1 %.2f, of P2 %.2f\n", stage$scores$stage[1], stage$pc1_share, centers$PC1[1], centers$PC1[2] ))}
scores <- bind_rows(stages[[1]]$scores, stages[[2]]$scores) |> mutate(stage = factor(stage, levels = c("Before bridging", "After bridging")))pca_plot <- ggplot(scores, aes(PC1, PC2, colour = Project)) + geom_point(size = 1.8, alpha = 0.8) + scale_colour_manual(values = c(P1 = "#2a78d6", P2 = "#eb6834")) + facet_wrap(vars(stage), scales = "free") + labs( title = "OlinkAnalyze example projects, 184 assays: PCA of all samples", colour = "Project" ) + theme_minimal(base_size = 11) + theme(legend.position = "top", panel.grid.minor = element_blank())ggsave( "outputs/olink-bridging_pca_r.png", pca_plot, width = 9, height = 4.5, dpi = 120, bg = "white")Before bridging: PC1 explains 0.031, mean PC1 of P1 -2.20, of P2 1.99After bridging: PC1 explains 0.020, mean PC1 of P1 0.01, of P2 -0.01
Before bridging, PC1 explains a share of 0.031 of the variance and splits the projects, with mean scores of -2.20 for P1 and 1.99 for P2. After bridging, the mean scores are 0.01 and -0.01, and PC1 no longer sorts samples by project.
Intensity normalization, and when to use which
Section titled “Intensity normalization, and when to use which”Intensity normalization aligns two datasets without shared samples. It assumes that each assay has the same median in both, and shifts one dataset until the medians match. OlinkAnalyze runs it as subset normalization with every sample that passed QC, as its reference manual describes. Olink’s normalization white paper recommends intensity normalization when samples are randomized across plates and projects, and reference sample normalization, which is bridging, when they are not. The bridging tutorial adds that plate control normalization is the usual choice for a single plate or for Explore HT, and intensity normalization for a project of several plates. Running both methods on the same two projects shows what the median assumption costs.
#' List the samples of a project that passed QC on every assay.#'#' @param df An NPX table in long format with SampleID and QC_Warning.#' @return A character vector of SampleIDs.PassingSamples <- function(df) { df |> group_by(SampleID) |> filter(all(QC_Warning == "Pass")) |> pull(SampleID) |> unique()}
# Intensity normalization is subset normalization with every sample that# passed QC, so each factor is a difference between two project medians.passed_1 <- PassingSamples(project_1)passed_2 <- PassingSamples(project_2)intensity <- olink_normalization( df1 = project_1, df2 = project_2, overlapping_samples_df1 = passed_1, overlapping_samples_df2 = passed_2, df1_project_nr = "P1", df2_project_nr = "P2", reference_project = "P1")compared <- intensity |> filter(Project == "P2") |> distinct(OlinkID, intensity_factor = Adj_factor) |> inner_join(factors, by = "OlinkID")gap <- abs(compared$intensity_factor - compared$Adj_factor)cat(sprintf( "samples used: %d in P1, %d in P2\n", length(passed_1), length(passed_2)))cat(sprintf( "correlation of intensity and bridge factors: %.3f\n", cor(compared$intensity_factor, compared$Adj_factor)))cat(sprintf("median absolute gap: %.2f NPX\n", median(gap)))cat(sprintf( "assays with a gap above 0.5 NPX: %d of %d\n", sum(gap > 0.5), nrow(compared)))samples used: 153 in P1, 169 in P2correlation of intensity and bridge factors: 0.864median absolute gap: 0.29 NPXassays with a gap above 0.5 NPX: 58 of 184The two sets of factors correlate at 0.864, yet they differ by a median of 0.29 NPX, and by more than 0.5 NPX for 58 of the 184 assays. The bridge factors are exact for the 16 bridge samples, so the gap shows how far the median assumption lands when most of the 153 samples of P1 and the 169 of P2 are different people. With randomized samples from one population, that gap shrinks as the projects grow. With two different populations, intensity normalization removes part of the real difference between them.
Where this goes wrong
Section titled “Where this goes wrong”- A factor of exactly 0 in real data means the two datasets hold identical values for the bridges, which points to copied data rather than a second run.
- A bridge factor shifts each assay by one constant. It does not correct a difference in spread. Bridging between two Olink products can use quantile smoothing instead, which adjusts the whole distribution.
- Intensity normalization between two different populations treats a real difference in medians as a batch effect and removes it.
Next steps
Section titled “Next steps”NPX and QC reads a real Olink dataset and checks it,
and Differential abundance tests its proteins
between groups. The code for this page is in guides/proteomics/olink-bridging/ of the
companion repository.
Scientific references
Section titled “Scientific references”The OlinkAnalyze package by Nevola and colleagues supplies the functions for the analysis of Olink proteomic data.
Further reading
Section titled “Further reading”The Olink bridge normalization tutorial explains shared sample identities, assay adjustment medians, and selection of the reference project. Use it to check why the same biological samples must connect the projects and how the adjustment direction follows the chosen reference.