# Customizing the visualizations of CalibraCurve

# Introduction

    library("CalibraCurve")

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

    D <- readDataSE(file, concColName = "amount_fmol", substColName = "Substance")

    RES <- CalibraCurve(D)

# Handling multiple calibration curves

If multiple analytes are present in the data, `CalibraCurve` by default plots each calibration curve separately and saves them in separate files. There are, however, two possibilities to combine the calibration curves.

### Multiplot

The multiplot option allows to arrange the different curves in a grid. This functionality is based on the `facet_wrap` function from `ggplot2`.

    RES <- CalibraCurve(D, plot_type = "multiplot")
    RES$plot_CC_list
    #> Warning in ggplot2::scale_y_continuous(trans = "log10"): log-10 transformation introduced infinite values.

The single plots are arranged in a grid. The number of rows and columns is chosen automatically by default, but can be changed by using the `multiplot_nrow` and `multiplot_ncol` parameters:

    RES <- CalibraCurve(D, plot_type = "multiplot", multiplot_nrow = 3,
                        multiplot_ncol = 4)
    RES$plot_CC_list
    #> Warning in ggplot2::scale_y_continuous(trans = "log10"): log-10 transformation introduced infinite values.

By default, the x and y-axis ranges are individual per plot `multiplot_scales = "fixed"`. Sometimes it makes sense to fix both axis or only one of them for better comparability. For this, the `multiplot_scales` parameter can be set to `fixed`, `fixed_y` or `fixed_x`:

    RES <- CalibraCurve(D, plot_type = "multiplot", multiplot_scales = "fixed")
    RES$plot_CC_list
    #> Warning in ggplot2::scale_y_continuous(trans = "log10"): log-10 transformation introduced infinite values.

Now, the x- and y-axes are scaled the same for each plot, so the intensity values can be directly compared between plots.

### All-in-one plot

As a second option, the `"all_in_one"` option allows to plot all curves into the same graphic, so a more direct comparison is possible:

    RES <- CalibraCurve(D, plot_type = "all_in_one")
    RES$plot_CC_list

Each of the 9 calibration curves is presented in the same plot in different colours (see legend). Please note that for better visability, the linear ranges are not indicated by the grey background anymore. However, data points outside of the linear range are still plotted with a higher transparency (alpha-value).

# Changing colours

Different colours can be changed in the plots. For the calibration curves, the colour of the data points (`point_colour`), the colour of the curve (`curve_colour`) and of the linear range (`linear_range_colour`) can be customized. The colours can be given as the colour name or the hexadecimal colour code:

    RES <- CalibraCurve(D, point_colour = "blue", curve_colour = "black",
                        linear_range_colour = "red")
    RES$plot_CC_list[[1]]
    #> Warning in ggplot2::scale_y_continuous(trans = "log10"): log-10 transformation introduced infinite values.

For the response factor plots, the colour of data points and corresponding connection lines within and outside of the thresholds (`RF_colour_within` and `RF_colour_outside`) can be adapted. Furthermore, the colour of the threshold lines can be changed (`RF_colour_threshold`).

    RES <- CalibraCurve(D, RF_colour_threshold = "grey",
                        RF_colour_within = "purple",
                        RF_colour_outside = "darkgreen")
    RES$plot_RF_list[[1]]

# Other plot elements

The plotting of the data points can be omitted. This makes sense especially when multiple curves are plotted in the same plot. As a downside, information on the linear ranges is lost:

    RES <- CalibraCurve(D, plot_type = "all_in_one", show_data_points = FALSE)
    RES$plot_CC_list

It is also possible to remove the background that indicates the linear range. Also, it is possible to write the regression curve equation (upper left corner of the plot) and the R squared value into the plot, which is turned off by default:

    RES <- CalibraCurve(D, show_linear_range = FALSE, show_regression_info = TRUE)
    RES$plot_CC_list[[1]]
    #> Warning in ggplot2::scale_x_continuous(trans = "log10", labels = scales::label_comma(drop0trailing = TRUE)): log-10
    #> transformation introduced infinite values.

Furthermore, the axis labels can be changed, in this example we specify the labels to match the underlying data set:

    RES <- CalibraCurve(D, xlab = "Amount (fmol)", ylab = "Area")
    RES$plot_CC_list[[1]]
    #> Warning in ggplot2::scale_y_continuous(trans = "log10"): log-10 transformation introduced infinite values.

It has to be noted that the plots are returned as ggplot2 objects by the respective functions. Therefore, even more customizations can be done by using the ggplot2 functionality. For example, we can give the plot a title and use a different theme which does not contain a grid in the background:

    RES <- CalibraCurve(D)
    pl <- RES$plot_CC_list[[1]]

    library(ggplot2)
    pl <- pl + ggtitle("Calibration Curve") + theme_classic()
    pl
    #> Warning in ggplot2::scale_y_continuous(trans = "log10"): log-10 transformation introduced infinite values.

# R session information

`R` session information.

    #> ─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────
    #>  setting  value
    #>  version  R version 4.5.2 (2025-10-31)
    #>  os       Ubuntu 24.04.4 LTS
    #>  system   x86_64, linux-gnu
    #>  ui       X11
    #>  language (EN)
    #>  collate  C
    #>  ctype    en_US.UTF-8
    #>  tz       Etc/UTC
    #>  date     2026-03-12
    #>  pandoc   3.6.3 @ /usr/local/bin/ (via rmarkdown)
    #>  quarto   1.8.24 @ /usr/local/bin/quarto
    #>
    #> ─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────
    #>  package              * version date (UTC) lib source
    #>  abind                  1.4-8   2024-09-12 [2] RSPM (R 4.5.0)
    #>  backports              1.5.0   2024-05-23 [2] RSPM (R 4.5.0)
    #>  bibtex                 0.5.2   2026-02-03 [2] RSPM (R 4.5.0)
    #>  Biobase                2.71.0  2025-10-29 [2] https://bioc.r-universe.dev (R 4.5.2)
    #>  BiocGenerics           0.57.0  2025-10-29 [2] https://bioc.r-universe.dev (R 4.5.2)
    #>  BiocManager            1.30.27 2025-11-14 [2] RSPM (R 4.5.0)
    #>  BiocStyle            * 2.39.0  2025-10-29 [2] https://bioc.r-universe.dev (R 4.5.2)
    #>  bslib                  0.10.0  2026-01-26 [2] RSPM (R 4.5.0)
    #>  buildtools             1.0.0   2026-02-23 [3] local (/pkg)
    #>  cachem                 1.1.0   2024-05-16 [2] RSPM (R 4.5.0)
    #>  CalibraCurve         * 1.1.3   2026-03-11 [1] https://bioc.r-universe.dev (R 4.5.2)
    #>  checkmate              2.3.4   2026-02-03 [2] RSPM (R 4.5.0)
    #>  cli                    3.6.5   2025-04-23 [2] RSPM (R 4.5.0)
    #>  DelayedArray           0.37.0  2025-10-29 [2] https://bioc.r-universe.dev (R 4.5.2)
    #>  digest                 0.6.39  2025-11-19 [2] RSPM (R 4.5.0)
    #>  dplyr                  1.2.0   2026-02-03 [2] RSPM (R 4.5.0)
    #>  evaluate               1.0.5   2025-08-27 [2] RSPM (R 4.5.0)
    #>  farver                 2.1.2   2024-05-13 [2] RSPM (R 4.5.0)
    #>  fastmap                1.2.0   2024-05-15 [2] RSPM (R 4.5.0)
    #>  generics               0.1.4   2025-05-09 [2] RSPM (R 4.5.0)
    #>  GenomicRanges          1.63.1  2025-12-08 [2] https://bioc.r-universe.dev (R 4.5.2)
    #>  ggplot2              * 4.0.2   2026-02-03 [2] RSPM (R 4.5.0)
    #>  glue                   1.8.0   2024-09-30 [2] RSPM (R 4.5.0)
    #>  gtable                 0.3.6   2024-10-25 [2] RSPM (R 4.5.0)
    #>  htmltools              0.5.9   2025-12-04 [2] RSPM (R 4.5.0)
    #>  httr                   1.4.8   2026-02-13 [2] RSPM (R 4.5.0)
    #>  IRanges                2.45.0  2025-10-29 [2] https://bioc.r-universe.dev (R 4.5.2)
    #>  jquerylib              0.1.4   2021-04-26 [2] RSPM (R 4.5.0)
    #>  jsonlite               2.0.0   2025-03-27 [2] RSPM (R 4.5.0)
    #>  knitr                  1.51    2025-12-20 [2] RSPM (R 4.5.0)
    #>  labeling               0.4.3   2023-08-29 [2] RSPM (R 4.5.0)
    #>  lattice                0.22-9  2026-02-09 [2] RSPM (R 4.5.0)
    #>  lifecycle              1.0.5   2026-01-08 [2] RSPM (R 4.5.0)
    #>  lubridate              1.9.5   2026-02-04 [2] RSPM (R 4.5.0)
    #>  magrittr               2.0.4   2025-09-12 [2] RSPM (R 4.5.0)
    #>  maketools              1.3.2   2025-01-25 [3] RSPM (R 4.5.0)
    #>  Matrix                 1.7-4   2025-08-28 [2] RSPM (R 4.5.0)
    #>  MatrixGenerics         1.23.0  2025-10-29 [2] https://bioc.r-universe.dev (R 4.5.2)
    #>  matrixStats            1.5.0   2025-01-07 [2] RSPM (R 4.5.0)
    #>  openxlsx               4.2.8.1 2025-10-31 [2] RSPM (R 4.5.0)
    #>  pillar                 1.11.1  2025-09-17 [2] RSPM (R 4.5.0)
    #>  pkgconfig              2.0.3   2019-09-22 [2] RSPM (R 4.5.0)
    #>  plyr                   1.8.9   2023-10-02 [2] RSPM (R 4.5.0)
    #>  purrr                  1.2.1   2026-01-09 [2] RSPM (R 4.5.0)
    #>  R6                     2.6.1   2025-02-15 [2] RSPM (R 4.5.0)
    #>  RColorBrewer           1.1-3   2022-04-03 [2] RSPM (R 4.5.0)
    #>  Rcpp                   1.1.1   2026-01-10 [2] RSPM (R 4.5.0)
    #>  RefManageR           * 1.4.0   2022-09-30 [2] RSPM (R 4.5.0)
    #>  rlang                  1.1.7   2026-01-09 [2] RSPM (R 4.5.0)
    #>  rmarkdown              2.30    2025-09-28 [2] RSPM (R 4.5.0)
    #>  S4Arrays               1.11.1  2025-11-25 [2] https://bioc.r-universe.dev (R 4.5.2)
    #>  S4Vectors              0.49.0  2025-10-29 [2] https://bioc.r-universe.dev (R 4.5.2)
    #>  S7                     0.2.1   2025-11-14 [2] RSPM (R 4.5.0)
    #>  sass                   0.4.10  2025-04-11 [2] RSPM (R 4.5.0)
    #>  scales                 1.4.0   2025-04-24 [2] RSPM (R 4.5.0)
    #>  Seqinfo                1.1.0   2025-10-29 [2] https://bioc.r-universe.dev (R 4.5.2)
    #>  sessioninfo          * 1.2.3   2025-02-05 [2] RSPM (R 4.5.0)
    #>  SparseArray            1.11.10 2025-12-16 [2] https://bioc.r-universe.dev (R 4.5.2)
    #>  stringi                1.8.7   2025-03-27 [2] RSPM (R 4.5.0)
    #>  stringr                1.6.0   2025-11-04 [2] RSPM (R 4.5.0)
    #>  SummarizedExperiment   1.41.1  2026-02-05 [2] https://bioc.r-universe.dev (R 4.5.2)
    #>  sys                    3.4.3   2024-10-04 [2] RSPM (R 4.5.0)
    #>  tibble                 3.3.1   2026-01-11 [2] RSPM (R 4.5.0)
    #>  tidyr                  1.3.2   2025-12-19 [2] RSPM (R 4.5.0)
    #>  tidyselect             1.2.1   2024-03-11 [2] RSPM (R 4.5.0)
    #>  timechange             0.4.0   2026-01-29 [2] RSPM (R 4.5.0)
    #>  vctrs                  0.7.1   2026-01-23 [2] RSPM (R 4.5.0)
    #>  withr                  3.0.2   2024-10-28 [2] RSPM (R 4.5.0)
    #>  xfun                   0.56    2026-01-18 [2] RSPM (R 4.5.0)
    #>  xml2                   1.5.2   2026-01-17 [2] RSPM (R 4.5.0)
    #>  XVector                0.51.0  2025-10-29 [2] https://bioc.r-universe.dev (R 4.5.2)
    #>  yaml                   2.3.12  2025-12-10 [2] RSPM (R 4.5.0)
    #>  zip                    2.3.3   2025-05-13 [2] RSPM (R 4.5.0)
    #>
    #>  [1] /tmp/RtmpWyvrpO/Rinst11724a86a7f3
    #>  [2] /github/workspace/pkglib
    #>  [3] /usr/local/lib/R/site-library
    #>  [4] /usr/lib/R/site-library
    #>  [5] /usr/lib/R/library
    #>  * ── Packages attached to the search path.
    #>
    #> ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

# Bibliography

This vignette was generated using BiocStyle (Oleś, 2025) with knitr (Xie, 2025) and rmarkdown (Allaire Xie et al., 2025) running behind the scenes.

Citations made with RefManageR (McLean, 2017).

Allaire, J., Y. Xie, et al. (2025). rmarkdown: Dynamic Documents for R. R package version 2.30. URL: https://github.com/rstudio/rmarkdown.

Kohl, M., M. Stepath, et al. (2020). “CalibraCurve: A Tool for Calibration of Targeted MS-Based Measurements”. In: Proteomics, p. 1900143. DOI: https://doi.org/10.1002/pmic.201900143. URL: https://analyticalsciencejournals.onlinelibrary.wiley.com/doi/10.1002/pmic.201900143.

McLean, M. W. (2017). “RefManageR: Import and Manage BibTeX and BibLaTeX References in R”. In: The Journal of Open Source Software. DOI: 10.21105/joss.00338.

Oleś, A. (2025). BiocStyle: Standard styles for vignettes and other Bioconductor documents. R package version 2.39.0. URL: https://github.com/Bioconductor/BiocStyle.

Xie, Y. (2025). knitr: A General-Purpose Package for Dynamic Report Generation in R. R package version 1.51. URL: https://yihui.org/knitr/.