library(SeroTrackR)
library(tidyverse)
your_raw_data <- c(
system.file("extdata", "example_MAGPIX_plate1.csv", package = "SeroTrackR"),
system.file("extdata", "example_MAGPIX_plate2.csv", package = "SeroTrackR"),
system.file("extdata", "example_MAGPIX_plate3.csv", package = "SeroTrackR")
)
your_plate_layout <- system.file("extdata", "example_platelayout_1.xlsx", package = "SeroTrackR")4 Pathogen-agnostic Data Analysis Tutorial
If you would like to run the {SeroTrackR} R package data processing pipeline for work not relating to the fit-for-purpose tool leveraging eight Plasmodium vivax serological exposure markers, then this is the tutorial for you!
4.1 Essential
Please ensure that you have read and prepared your raw Luminex files and plate layout files as per the instructions in the setup vignette.
4.2 Step 1: Read in Raw Data
For this tutorial, we will be using the built-in files within {SeroTrackR} that are extrapolated from Plasmodium vivax samples.
To run your OWN data, follow the code below and uncomment (i.e., remove the hashtags):
your_raw_data <- c(
"PATH/TO/YOUR/FILE/plate1.csv",
"PATH/TO/YOUR/FILE/plate2.csv",
"PATH/TO/YOUR/FILE/plate3.csv"
)
your_plate_layout <- "PATH/TO/YOUR/FILE/plate_layout.xlsx"You can read any Luminex serology data file using the readSeroData() function.
The Luminex platform can be specified using the platform argument, with either bioplex, magpix or intelliflex.
For the xPONENT software-based exported files (MAGPIX or INTELLIFLEX), the version of the software should be specified as either “4.2” or “4.3”, with the version “4.2” as the default.
sero_data <- readSeroData(
raw_data = your_raw_data,
platform = "magpix", # default
version = "4.2" # default
)
#> PASS: File example_magpix_plate1.csv successfully validated.
#> PASS: File example_magpix_plate2.csv successfully validated.
#> PASS: File example_magpix_plate3.csv successfully validated.This exports a list of data frames:
data_raw: The raw, unedited files: A check that the correct file/s were added.results: The processed serological data files: Antigen names compatible with the R package, clear columns for each antigen and their MFI results.counts: The bead counts detected from the Luminex instrument per antigen, per sample, for each plate.blanks: The MFI results for the blank wells.stds: The MFI results for the standard curve samples.run: The run information from the Luminex machine.
You can access each data frame, for example the results data frame, like this:
sero_data$results| Location | Sample | EBP | LF005 | LF010 | LF016 | MSP8 | RBP2b.P87 | PTEX150 | PvCSS | Plate |
|---|---|---|---|---|---|---|---|---|---|---|
| 1(1,A1) | Blank1 | 20.0 | 200 | 20.0 | 10.0 | 20 | 10.0 | 30 | 20.0 | plate1 |
| 2(1,A2) | Blank2 | 15.0 | 291 | 15.0 | 15.0 | 15 | 10.0 | 20 | 15.0 | plate1 |
| 3(1,A3) | S1 | 15710.5 | 11990 | 22583.0 | 21244.0 | 24306 | 7907.5 | 13207 | 12427.0 | plate1 |
| 4(1,A4) | S2 | 13545.0 | 8285 | 16947.5 | 16146.0 | 17172 | 7186.0 | 8550 | 8034.0 | plate1 |
| 5(1,A5) | S3 | 9767.0 | 4950 | 10865.0 | 10621.5 | 11358 | 4475.5 | 5329 | 4990.0 | plate1 |
| 6(1,A6) | S4 | 5648.5 | 2519 | 6060.0 | 5968.5 | 6237 | 3508.0 | 2671 | 2446.5 | plate1 |
Next, you need to read in the plate layout! This file will allow us to relabel the raw luminex data from “unknowns” to our study Sample ID’s.
plate_list <- readPlateLayout(
plate_layout = your_plate_layout,
sero_data = sero_data
)
#> Plate layouts correctly identified!Great! Now our serological data has been processed and our plate layouts are added into R-compatible data frames ready for analysis!
4.3 Step 2: Quality control checks
Quality control checks can also be run on any serological data file that has been processed using the readSeroData() and readPlateLayout() functions. The runQC() function will:
- Process bead count data (assigns a warning if bead counts are less than 15 or above 500 per antigen).
- Assign Sample ID’s to Luminex outputs.
qc_results <- runQC(
sero_data = sero_data, # load in your serological data variable
plate_list = plate_list # load your plate list variable
)This exports a list of data frames:
processCounts_output: The bead counts per antigen, per sample, for each plate. Intermediary file for downstream processing. Warning = 0 for pass and = 1 for fail.getCounts_output: The processed bead counts file for each sample, summarising whether a sample needs to be repeated. Intermediary file for downstream processing.sampleid_output: Aligning the Luminex anonymised data (SampleID) to the plate layout ID’s (Sample). Intermediary file for downstream processing.getAntigenCounts_output: The processed bead counts file per antigen per sample. Used forplotBeadCounts().getCountsQC_output: The bead counts and QC results per antigen. Key file.
You can access each data frame, for example the getCountsQC_output data frame, like this:
qc_results$getCountsQC_output| Location | SampleID | Plate | EBP_Count | EBP_QC | LF005_Count | LF005_QC | LF010_Count | LF010_QC | LF016_Count | LF016_QC | MSP8_Count | MSP8_QC | PTEX150_Count | PTEX150_QC | PvCSS_Count | PvCSS_QC | RBP2b.P87_Count | RBP2b.P87_QC | QC_total |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| A1 | Blank1 | plate1 | 150 | pass | 88 | pass | 184 | pass | 170 | pass | 105 | pass | 85 | pass | 119 | pass | 127 | pass | pass |
| A1 | Blank1 | plate2 | 142 | pass | 85 | pass | 218 | pass | 9 | fail | 116 | pass | 90 | pass | 117 | pass | 115 | pass | fail |
| A1 | Blank1 | plate3 | 150 | pass | 95 | pass | 184 | pass | 170 | pass | 105 | pass | 85 | pass | 119 | pass | 127 | pass | pass |
| A10 | S8 | plate1 | 50 | pass | 62 | pass | 52 | pass | 50 | pass | 50 | pass | 61 | pass | 65 | pass | 53 | pass | pass |
| A10 | S8 | plate2 | 50 | pass | 51 | pass | 78 | pass | 67 | pass | 51 | pass | 87 | pass | 76 | pass | 55 | pass | pass |
| A10 | S8 | plate3 | 52 | pass | 70 | pass | 51 | pass | 50 | pass | 59 | pass | 83 | pass | 67 | pass | 65 | pass | pass |
You can also visualise QC results using the sero_data and qc_results variables.
4.3.1 Standard Curve Plot
The plotStds() function plots the standard curve, generated from the antibody data from the standards you indicated in your plate layout (e.g. S1-S10) and Median Fluorescent Intensity (MFI) units are displayed in log10-adjusted scale. In general, the standard curves should look relativel linear (only when the y-axis is on log-adjusted scale).
For your standard curve, you will need to specify the location = "PNG".
Note: The argument was originally written to distinguish between PvSEM assays that used different pooled positive control plasma from highly immune adults, which the location = "ETH" argument requires a different processing pipeline - here this is irrelevant!
In this plot, there are grey dots in the background. This only appears because we are using the PvSEMs in the fit-for-purpose tool and it signifies the standard curve range observed at WEHI. In your dataset, you will not have these grey dots.
plotStds(sero_data, location = "PNG", experiment_name = "experiment1")
#> Warning: Removed 250 rows containing missing values or values outside the scale range
#> (`geom_point()`).
For more information on how to interrogate and visualise standard curves, see the Explore Standard Curves page.
4.3.2 Bead Counts QC Plot
The plotCounts() function provides a summary of the bead counts for each plate well are displayed, with blue indicating there are sufficient beads (≥15) or red when there are not enough. If any of the wells are red, they should be double-checked manually and re-run on a new plate if required.
plotCounts(qc_results, experiment_name = "experiment1")
getRepeats(qc_results, plate_list)
#> # A tibble: 2 × 4
#> Location SampleID Plate QC
#> <chr> <chr> <chr> <chr>
#> 1 A1 Blank1 plate2 fail
#> 2 A2 Blank2 plate2 failThe getRepeats() function will inform you whether there are “No repeats necessary” or provide a list of samples to be re-run. In the example data, the beads in plate 2 wells A1 and A2 will need to be repeated.
For more information on how to visualise these data, see the Bead Counts page.
4.3.3 Blanks QC Plot
The Median Fluorescent Intensity (MFI) units for each antigen is displayed for your blank samples. In general, each blank sample should have ≤50 MFI for each antigen, if they are higher they should be cross-checked manually.
plotBlanks(sero_data, experiment_name = "experiment1")
In the example data, blank samples recorded higher MFI values for LF005 on plate 1 and should be checked to confirm this is expected from the assay.
4.4 Step 3: MFI to RAU conversion
The automated data processing allows you to convert your Median Fluorescent Intensity (MFI) data into Relative Antibody Units (RAU) by fitting a 5-parameter logistic function to the standard curve on a per-antigen level using the MFItoRAU() function suite.
Key input variables:
sero_data,plate_list,qc_results: Previously defined variables from thereadSeroData(),readPlateLayout()andrunQC()functions.std_point: Standard Point Curve: 5 = 5-point curve, 10 = 10-point curve.
mfi_to_rau_output <- MFItoRAU(
sero_data = sero_data,
plate_list = plate_list,
qc_results = qc_results,
std_point = 10
)The mfi_to_rau_output variable contains the processed MFI and RAU data for each antigen per sample. There are three data frames output from this variable:
[[1]]: Contains correct SampleID’s, well number and letters, MFI and RAU values per antigen and QC results.[[2]]: Contains correct SampleID’s, MFI and RAU values per antigen and QC results. Cleaner data frame![[3]]: Raw MFI to RAU conversion data per antigen.
mfi_to_rau_output[[2]]| SampleID | Plate | PvEBP_MFI | PvEBP_Dilution | Pv-fam-a_MFI | Pv-fam-a_Dilution | PvMSP5_MFI | PvMSP5_Dilution | PvMSP1-19_MFI | PvMSP1-19_Dilution | PvMSP8_MFI | PvMSP8_Dilution | PvRBP2b_MFI | PvRBP2b_Dilution | PvPTEX150_MFI | PvPTEX150_Dilution | PvCSS_MFI | PvCSS_Dilution | Location.2 | QC_total |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ABC013 | plate1 | 2712 | 0.0008186 | 1569.0 | 0.0013988 | 673 | 0.0002178 | 327 | 0.0001306 | 182.0 | 5.44e-05 | 1068.0 | 0.0005770 | 936.0 | 0.0008127 | 223 | 0.0002842 | B1 | pass |
| ABC014 | plate1 | 134 | 0.0000506 | 378.0 | 0.0003779 | 117 | 0.0000420 | 197 | 0.0000830 | 58.0 | 1.95e-05 | 465.5 | 0.0002524 | 122.0 | 0.0001229 | 93 | 0.0001354 | B2 | pass |
| ABC015 | plate1 | 182 | 0.0000672 | 209.0 | 0.0002221 | 208 | 0.0000724 | 374 | 0.0001473 | 221.5 | 6.57e-05 | 463.0 | 0.0002511 | 293.0 | 0.0002780 | 868 | 0.0008856 | B3 | pass |
| ABC016 | plate1 | 152 | 0.0000569 | 229.5 | 0.0002418 | 101 | 0.0000364 | 89 | 0.0000400 | 48.0 | 1.95e-05 | 591.0 | 0.0003184 | 109.0 | 0.0001103 | 110 | 0.0001568 | B4 | pass |
| ABC017 | plate1 | 1135 | 0.0003415 | 236.0 | 0.0002480 | 299 | 0.0001016 | 507 | 0.0001933 | 209.5 | 6.23e-05 | 671.0 | 0.0003606 | 1665.5 | 0.0014240 | 266 | 0.0003288 | B5 | pass |
| ABC018 | plate1 | 174 | 0.0000645 | 395.0 | 0.0003930 | 175 | 0.0000615 | 78 | 0.0000353 | 70.0 | 2.13e-05 | 103.0 | 0.0000486 | 294.5 | 0.0002793 | 92 | 0.0001341 | B6 | pass |
The results from this log-log conversion should look relatively linear for each antigen and can be plotted using the plotModel() function suite.
plotModel(mfi_to_rau_output, sero_data)
#> $`1`
#>
#> $`2`

#>
#> $`3`

For more information on how to visualise MFI and RAU data, see the MFI and RAU plots page.
4.5 Alternative Pipeline Function
A separate function called runPvSeroPipeline() was introduced to simplify writing all of these functions. For the pathogen-agnostic case, please ensure that classify = "No" so that the PvSEM classification algorithm is not applied.
no_classification_final_analysis <- runPvSeroPipeline(
raw_data = your_raw_data,
plate_layout = your_plate_layout,
platform = "magpix",
location = "ETH",
experiment_name = "experiment1",
classify = "No", ########################## key if you do NOT want any classification performed i.e., you do not have PvSEM antigens
algorithm_type = "antibody_model",
sens_spec = "balanced"
)You can then access the datasets and visualisations using the following functions:
# MFI and RAU data
no_classification_final_analysis[[1]]
# QC plots
#### Standard Curve Plot
no_classification_final_analysis[[2]]
#### Bead Counts QC Plot
no_classification_final_analysis[[3]] # Plot
no_classification_final_analysis[[4]] # Samples to repeat
#### Blanks QC Plot
no_classification_final_analysis[[5]]
#### Model Output Plot
no_classification_final_analysis[[6]]4.6 Final Code
library(SeroTrackR)
library(tidyverse)
your_raw_data <- c(
system.file("extdata", "example_MAGPIX_plate1.csv", package = "SeroTrackR"),
system.file("extdata", "example_MAGPIX_plate2.csv", package = "SeroTrackR"),
system.file("extdata", "example_MAGPIX_plate3.csv", package = "SeroTrackR")
)
your_plate_layout <- system.file("extdata", "example_platelayout_1.xlsx", package = "SeroTrackR")
# read serology data
sero_data <- readSeroData(raw_data = your_raw_data, platform = "magpix", version = "4.2")
# read plate data
plate_list <- readPlateLayout(plate_layout = your_plate_layout, sero_data = sero_data)
# run quality control checks
qc_results <- runQC(sero_data = sero_data, plate_list = plate_list)
# visualise quality control
plotStds(sero_data, location = "PNG", experiment_name = "experiment1")
# bead counts plot
plotCounts(qc_results, experiment_name = "experiment1")
# get repeats
getRepeats(qc_results, plate_list)
# blank well plot
plotBlanks(sero_data, experiment_name = "experiment1")
# perform MFI to RAU conversion
mfi_to_rau_output <- MFItoRAU(
sero_data = sero_data,
plate_list = plate_list,
qc_results = qc_results,
std_point = 10
)
# visualise MFI to RAU conversion
plotModel(mfi_to_rau_output, sero_data)