Package 'CalibraCurve'

Title: Calibration curves for targeted proteomics, lipidomics and metabolomics data
Description: CalibraCurve is a computational tool designed to generate calibration curves for targeted mass spectrometry-based quantitative data. It is applicable to various omics disciplines, including proteomics, lipidomics, and metabolomics. The package also offers functionalities for data and calibration curve visualization and concentration prediction from new datasets based on the established curves.
Authors: Karin Schork [aut, cre] (ORCID: <https://orcid.org/0000-0003-3756-4347>), Robin Grugel [aut], Michael Kohl [aut], Markus Stepath [aut], Martin Eisenacher [aut, fnd]
Maintainer: Karin Schork <[email protected]>
License: BSD 3-clause License + file LICENSE
Version: 1.3.2
Built: 2026-11-04 20:27:28 UTC
Source: https://github.com/bioc/CalibraCurve

Help Index


Main function for calculation of calibration curves

Description

Main function for calculation of calibration curves

Usage

CalibraCurve(
  D_list,
  output_path = NULL,
  substance = "substance",
  minReplicates = 3,
  cvThres = 20,
  calcContinuousPrelimRanges = FALSE,
  weightingMethod = "1/x^2",
  centralTendencyMeasure = "mean",
  perBiasThres = 20,
  considerPerBiasCV = TRUE,
  perBiasDistThres = 10,
  RfThresL = 80,
  RfThresU = 120,
  plot_type = "single_plots",
  RF_colour_threshold = "orange",
  RF_colour_within = "#00BFC4",
  RF_colour_outside = "#F8766D",
  device = "png",
  CC_plot_width = 15,
  CC_plot_height = 10,
  RF_plot_width = 15,
  RF_plot_height = 10,
  base_size = 11,
  RF_legend = TRUE,
  RF_plot_type = plot_type,
  plot_dpi = 300,
  verbose = TRUE,
  ...
)

Arguments

D_list

data.frame/list
Data.frame or list of data.frames (one for one specific substance, each must contain two columns: Concentration and Measurement)

output_path

character(1)
Folder to save results (table and plots). If NULL (default), results are not saved.

substance

character(1)
Name of the substance (default is "substance1"). Will be added to the result files and will be used as labels in the plots.

minReplicates

integer(1)
Minimal number of replicates/data points per concentration level. Concentration levels with too few data points will be removed.

cvThres

numeric(1)
Threshold for CV per concentration level in percent (default is 20).

calcContinuousPrelimRanges

logical(1)
If TRUE, the longest continuous range is selected (default is TRUE). If FALSE, gaps with CVs larger than the threshold may be included.

weightingMethod

character(1)
Method for weighting (currently "1/x", "1/x^2" and "None" are supported, default is 1/x^2).

centralTendencyMeasure

character(1)
Method for calculating average percent bias, "mean" (default) or "median".

perBiasThres

numeric(1)
Threshold for average percent bias in percent, default is 20.

considerPerBiasCV

logical(1)
If TRUE, CV is considered for the elimination of the concentration level (default). CV will only be considered if the difference in percent bias values is lower than perBiasDistThres.

perBiasDistThres

numeric(1)
Threshold for the difference in average percent bias in percent (for lower differences, CV will be considered), default is 10.

RfThresL

numeric(1)
Lower threshold for response factor in percent (default is 80).

RfThresU

numeric(1)
Upper threshold for response factor in percent (default is 120).

plot_type

character(1)
Type of plot for calibration curves: "single_plots" (default, generate a separate plot for each substance), "multiplot" (generate a graphic with subplots for each substance) or "all_in_one" (generate a single plot with all substances).

RF_colour_threshold

character(1)
Response factor plot: Colour for horizontal threshold lines, default is "orange".

RF_colour_within

character(1)
Response factor plot: Colour for points and lines within the final linear range, default is "#00BFC4" (default ggplot colour).

RF_colour_outside

character(1)
Response factor plot: Colour for horizontal outside of the final linear range, default is "#F8766D" (default ggplot colour).

device

character(1)
Device for saving the plot (default is "png"). Other options include "pdf", "jpeg", "tiff", "svg" etc. For details see ggsave.

CC_plot_width

numeric(1)
Plot width in cm (default is 10).

CC_plot_height

numeric(1)
Plot height in cm (default is 10).

RF_plot_width

numeric(1)
Plot width in cm (default is 10).

RF_plot_height

numeric(1)
Plot height in cm (default is 10).

base_size

numeric(1)
Base size for the plot theme, default is 11.

RF_legend

logical(1)
If TRUE, a legend will be added to the response factor plots.

RF_plot_type

character(1)
Type of response factor plot: "single_plots" (one response-factor plot per substance), "multiplot" (facetted response-factor plot for multiple substances) or "all_in_one" (all substances in one response-factor panel). By default, this follows plot_type.

plot_dpi

numeric(1)
Plot resolution in dpi (default is 300).

verbose

logical(1)
If FALSE, no messages will be printed.

...

additional parameters for plotCalibraCurve. If log10_x_axis is provided, the same setting is also used for plotResponseFactors.

Value

List with the following elements:

  • RES: List of CalibraCurve results (one item per substance, output from calc_single_curve).

  • summary_tab: Data.frame with summary information about the calibration curves, one row per substance.

  • plot_CC_list: List of ggplot2 objects of the calibration curves (one per substance for "single_plots", otherwise only one item).

  • plot_RF_list: List of ggplot2 objects of the response factor plots (one item).

Examples

### NOTE: as output_path is not specified here, no files will be saved.
### Set output_path to a folder of your choice to save the results.

### single xlsx file:
data_path <- system.file("extdata", "MSQC1_xlsx", "GGPFSDSYR_QTRAP_y5.xlsx",
    package = "CalibraCurve")
D <- readDataTable(dataPath = data_path, concCol = 16, measCol = 12,
    fileType = "xlsx")
RES <- CalibraCurve(D_list = D)
RES$plot_CC_list
RES$plot_RF_list

### multiple xlsx files (in a folder) as multiplot:
data_folder <- system.file("extdata", "MSQC1_xlsx", package = "CalibraCurve")
D_list <- readMultipleTables(dataFolder = data_folder, fileType = "xlsx",
    concCol = 16, measCol = 12)
RES <- CalibraCurve(D_list = D_list, plot_type = "multiplot")
RES$plot_CC_list

### single rds file (SummarizedExperiment) as an all-in-one plot:
file <- system.file("extdata", "MSQC1", "msqc1_dil_GGPFSDSYR.rds",
    package = "CalibraCurve")
D_list <- readDataSE(dataPath = file, concColName = "amount_fmol",
        substColName = "Substance", assayNumber = 1)
RES <- CalibraCurve(D_list, plot_type = "all_in_one")
RES$plot_CC_list

Plot the calibration curve

Description

Plot the calibration curve

Usage

plotCalibraCurve(
  CC_RES,
  ylab = "Intensity",
  xlab = "Concentration",
  log10_x_axis = TRUE,
  log_tick_label_style = "auto",
  show_regression_info = FALSE,
  show_linear_range = TRUE,
  show_data_points = TRUE,
  plot_zeros = FALSE,
  blank_panel_ratio = 0.1,
  blank_panel_width_factor = 0.12,
  plot_type = "multiplot",
  point_colour = "black",
  curve_colour = "red",
  linear_range_colour = "black",
  multiplot_nrow = NULL,
  multiplot_ncol = NULL,
  multiplot_scales = "free",
  regression_info_size = 3,
  base_size = 11
)

Arguments

CC_RES

list
Results of CalibraCurve. Each list element is the result of calc_single_curve

ylab

character(1)
y-axis label.

xlab

character(1)
x-axis label.

log10_x_axis

logical(1)
If TRUE (default), use a log10 transformation for the x-axis. If FALSE, keep original concentration values on a linear x-axis.

log_tick_label_style

character(1)
Label style for log-scale axes. One of "auto" (default), "math", "plain". "math" uses labels like 10−510^{-5}. "plain" uses numeric labels (for example, 0.00001). "auto" uses "math" for very small/large ranges and "plain" otherwise. For "math", tick positions are restricted to powers of 10.

show_regression_info

logical(1)
If TRUE, show regression information (R2, slope, intercept) on the plot.

show_linear_range

logical(1)
If TRUE, show the linear range of the calibration curve as a rectangle in the plot.

show_data_points

logical(1)
If TRUE, show the data points on the plot.

plot_zeros

logical(1)
If TRUE, show concentration 0 values in a separate "Blank" side panel for single-plot and all-in-one calibration curves.

blank_panel_ratio

numeric(1)
Target width ratio of Blank panel relative to Calibration panel in linear x-axis mode when plot_zeros = TRUE. For example, 0.3 means the Blank panel is about 30% as wide as the Calibration panel when measured on the rendered plot (default is 0.1). Set to NULL to use automatic panel widths.

blank_panel_width_factor

numeric(1)
Relative width of the Blank panel for linear x-axis plots when plot_zeros = TRUE. Interpreted as fraction of the positive calibration concentration range used to build the Blank panel x-span (default is 0.12).

plot_type

character(1)
Type of plot for calibration curves: "single_plot" (generate one plot for one substance), "multiplot" (generate a graphic with subplots for each substance) or "all_in_one" (generate a single plot with all substances).

point_colour

character(1)
Colour of the data points, default is "black".

curve_colour

character(1)
Colour of the calibration curve, default is "red".

linear_range_colour

character(1)
Colour of the linear range background, default is "black" (colour is weakened by alpha = 0.1).

multiplot_nrow

integer(1)
Number of rows for the multiplot layout (default is NULL, which means that there is only one row).

multiplot_ncol

integer(1)
Number of columns for the multiplot layout (default is NULL, which means that the number of columns is determined automatically based on the number of curves).

multiplot_scales

character(1)
Scales for the multiplot layout, default is "free" (which means that each plot has its own scales). Other options are "fixed", "free_x", "free_y".

regression_info_size

numeric(1)
Size of the regression information text on the plot, default is 3.

base_size

numeric(1)
Base size for the plot theme, default is 11.

Details

Can be used also on pre-calculated curves, if you import the .rds file using readRDS(). Does not save the plot, this can be done using ggplot2::ggsave.

Value

List of a ggplot2 object containing the calibration curve plot (CC_plot) and a data.frame containing summary data for annotations (annotation_dat).

Examples

file <- system.file("extdata", "MSQC1", "msqc1_dil_GGPFSDSYR.rds",
    package = "CalibraCurve"
)
D_list <- readDataSE(file,
    concColName = "amount_fmol",
    substColName = "Substance", assayNumber = 1
)
CC_RES <- calc_single_curve(D_list[[1]], calcContinuousPrelimRanges = FALSE)

plotCalibraCurve(list(substance = CC_RES))

Plot response factors

Description

Plot response factors

Usage

plotResponseFactors(
  RES,
  RfThresL = 80,
  RfThresU = 120,
  ylab = "Response Factor",
  xlab = "Concentration",
  log10_x_axis = TRUE,
  colour_threshold = "orange",
  colour_within = "#00BFC4",
  colour_outside = "#F8766D",
  legend = TRUE,
  base_size = 11,
  plot_type = "single_plot",
  multiplot_nrow = NULL,
  multiplot_ncol = NULL,
  multiplot_scales = "free",
  substance = NULL
)

Arguments

RES

list
Results of calc_single_curve.

RfThresL

numeric(1)
Lower threshold for response factor in percent (default is 80).

RfThresU

numeric(1)
Upper threshold for response factor in percent (default is 120).

ylab

character(1)
y-axis label.

xlab

character(1)
x-axis label.

log10_x_axis

logical(1)
If TRUE (default), use a log10 transformation for the x-axis. If FALSE, keep original concentration values on a linear x-axis.

colour_threshold

character(1)
Colour for horizontal threshold lines, default is "orange".

colour_within

character(1)
Colour for points and lines within the threshold, default is "#00BFC4" (default ggplot colour).

colour_outside

character(1)
Colour for horizontal outside of the threshold, default is "#F8766D" (default ggplot colour).

legend

logical(1)
If TRUE, a legend is added to the plot, default is FALSE.

base_size

numeric(1)
Base size for the plot theme, default is 11.

plot_type

character(1)
Type of response factor plot: "single_plot" (default, one plot for one substance), "multiplot" (facetted plot for multiple substances) or "all_in_one" (all substances in one panel).

multiplot_nrow

integer(1)
Number of rows for the multiplot layout (default is NULL, determined automatically).

multiplot_ncol

integer(1)
Number of columns for the multiplot layout (default is NULL, determined automatically).

multiplot_scales

character(1)
Scales for the multiplot layout, default is "free". Other options are "fixed", "free_x", "free_y".

substance

character(1)
Name of the substance (default is "substance1"). Will be added to the result files and will be used as labels in the plots.

Value

A ggplot2 object containing the response factor plot.

Examples

file <- system.file("extdata", "MSQC1", "msqc1_dil_GGPFSDSYR.rds",
    package = "CalibraCurve"
)
D_list <- readDataSE(file,
    concColName = "amount_fmol",
    substColName = "Substance", assayNumber = 1
)
CC_RES <- calc_single_curve(D_list[[1]], calcContinuousPrelimRanges = FALSE)

plotResponseFactors(RES = CC_RES)

Predict concentrations from intensity values based on a given calibration curve

Description

Predict concentrations from intensity values based on a given calibration curve

Usage

predictConcentration(CC_res, newdata, verbose = TRUE)

Arguments

CC_res

list
Results of CalibraCurve.

newdata

numeric
A vector of intensity values for which to predict concentrations.

verbose

logical(1)
If TRUE, a warning message is given if estimated concentrations are outside of the linear range.

Details

The function will give a warning if any of the predicted concentrations are outside the final linear range. This is important to ensure that the predictions are reliable and within the linear range of the calibration curve.

Value

A data frame with the following columns:

  • intensity: The input intensity values.

  • predicted_concentrations: The predicted concentrations based on the calibration curve.

  • linear_range: A logical vector indicating whether the predicted concentrations are within the final linear range.

Examples

file <- system.file("extdata", "MSQC1", "msqc1_dil_GGPFSDSYR.rds",
        package = "CalibraCurve")
D <- readDataSE(file, concColName = "amount_fmol",
        substColName = "Substance")
RES <- CalibraCurve(D)
newdata <- c(1000000, 10000000, 100000000) # 1e6, 1e7, 1e8
predictConcentration(RES$RES[[4]], newdata = newdata)

Read data stored as an SummarizedExperiment object (directly or stored in an .rds file). Extracts the two relevant columns (concentration and measurement) and orders the data by increasing concentration level.

Description

Read data stored as an SummarizedExperiment object (directly or stored in an .rds file). Extracts the two relevant columns (concentration and measurement) and orders the data by increasing concentration level.

Usage

readDataSE(
  dataPath = NULL,
  rawDataSE = NULL,
  concColName,
  substColName,
  assayNumber = 1,
  rowNumbers = NULL
)

Arguments

dataPath

character(1)
Path to the data file (.rds file)

rawDataSE

SummarizedExperiment
SummarizedExperiment object

concColName

character(1)
Name of the column in the colData() containing the concentration levels.

substColName

character(1)
column name of rowData() containing the substance name (must be a unique value in each row)

assayNumber

integer(1)
Number of assay to be extracted from the SummarizedExperiment object

rowNumbers

integer
Row numbers to extract from the SummarizedExperiment object. Default is NULL, which means that all rows in the object will be used.

Details

The SummarizedExperiments object may contain quantitative values from targeted proteomics, lipidomics or metabolomics experiments. The colData has to contain a column with the concentration levels (concColName). The rowData has to contain a column with the substance names (e.g. peptide sequence, name of lipid or metabolite etc).

Value

List of data.frame, each with two numeric columns: Concentration and Measurement

Examples

file <- system.file("extdata", "MSQC1", "msqc1_dil_GGPFSDSYR.rds",
    package = "CalibraCurve")

D_list <- readDataSE(file,
    concColName = "amount_fmol",
    substColName = "Substance", assayNumber = 1)

# Alternative: import SummarizedExperiment object directly
rawDataSE <- readRDS(file)

D_list2 <- readDataSE(rawDataSE = rawDataSE,
    concColName = "amount_fmol",
    substColName = "Substance", assayNumber = 1
)

Read data in different table input formats (xlsx, csv or txt). Extracts the two relevant columns (concentration and measurement) and orders the data by increasing concentration.

Description

Read data in different table input formats (xlsx, csv or txt). Extracts the two relevant columns (concentration and measurement) and orders the data by increasing concentration.

Usage

readDataTable(
  dataPath,
  fileType,
  concCol,
  measCol,
  substCol = NULL,
  sep = ",",
  dec = ".",
  header = TRUE,
  naStrings = c("NA", "NaN", "Filtered", "#NV"),
  sheet = 1
)

Arguments

dataPath

character(1)
Path to the data file (.csv, .txt or .xlsx file).

fileType

character(1)
Type of file: "csv", "txt" or "xlsx".

concCol

integer(1) or character(1)
Column number or column name of the concentration values.

measCol

integer(1) or character(1)
Column number or column name of the measurement values.

substCol

integer(1) or character(1)
Column number or column name of the substance names (optional). If not set, all rows will be interpreted as belonging to the same substance.

sep

character(1)
The field separator, default is ",".

dec

character(1)
Decimal separator, default is ".".

header

logical(1)
If TRUE, first line is counted as column names. The default is TRUE.

naStrings

character
Vector of strings which are to be interpreted as NA. The default is c("NA", "NaN", "Filtered", "#NV").

sheet

integer(1)
Sheet number (only needed for xlsx files, default is to use the first sheet).

Value

Data.frame with two numeric columns: Concentration and Measurement

Examples

### xlsx file:
file <- system.file("extdata", "MSQC1_xlsx", "GGPFSDSYR_QTRAP_y5.xlsx",
    package = "CalibraCurve"
)
D <- readDataTable(file, fileType = "xlsx", concCol = 16, measCol = 12)

Read folder of files in different table input formats (xlsx, csv or txt).

Description

Read folder of files in different table input formats (xlsx, csv or txt).

Usage

readMultipleTables(dataFolder, fileType, concCol, measCol, ...)

Arguments

dataFolder

character(1)
Folder containing either xlsx, csv or txt files

fileType

character(1)
Type of file: "csv", "txt" or "xlsx".

concCol

integer(1) or character(1)
Column number or column name of the concentration values.

measCol

integer(1) or character(1)
Column number or column name of the measurement values.

...

additional parameters to readDataTable

Value

List of data.frame, each with two numeric columns: Concentration and Measurement

Examples

data_folder <- system.file("extdata", "MSQC1_xlsx",
    package = "CalibraCurve")
D_list <- readMultipleTables(
    dataFolder = data_folder, fileType = "xlsx",
    concCol = 16, measCol = 12
)