From 5675be03f95a76b74c2956b3be08897c040db1f7 Mon Sep 17 00:00:00 2001 From: "Win Cowger, PhD" Date: Mon, 2 Oct 2023 11:11:39 -0700 Subject: [PATCH] Various bug fixes (#147) * Add `showlegend` option * Add dots option for `plotly_spec()` * Fix bug with `match_spec()` * Improve syntax * Fix NA as top by removing NA, also faster logic. * Force col_id to equal names of the spectra * Add contributors * Prepare CRAN submission --------- Co-authored-by: Zacharias Steinmetz --- CRAN-SUBMISSION | 6 +- DESCRIPTION | 16 +- NEWS.md | 13 ++ R/OpenSpecy-package.R | 2 +- R/as_OpenSpecy.R | 13 +- R/interactive_plots.R | 226 +++++++++++++++++++---------- R/manage_lib.R | 114 ++++++++++++++- R/match_spec.R | 27 ++-- README.md | 2 +- cran-comments.md | 11 +- man/OpenSpecy-package.Rd | 6 +- man/interactive_plots.Rd | 13 +- man/manage_lib.Rd | 114 ++++++++++++++- tests/testthat/test-as_OpenSpecy.R | 7 +- tests/testthat/test-match_spec.R | 43 +++++- tests/testthat/test-read_ext.R | 16 +- vignettes/advanced.Rmd | 2 +- vignettes/sop.Rmd | 2 +- 18 files changed, 494 insertions(+), 139 deletions(-) diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index 053b014b..b7c2c8a1 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ -Version: 1.0.3 -Date: 2023-09-13 15:19:30 UTC -SHA: 2ff9c1a9be7e2e3c99747f8f65302223b7951830 +Version: 1.0.4 +Date: 2023-10-01 19:33:04 UTC +SHA: 54ff4c6288617c5b1af0705bcba2278f911a4b0d diff --git a/DESCRIPTION b/DESCRIPTION index d26329bd..2ccbea41 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: OpenSpecy Type: Package Title: Analyze, Process, Identify, and Share Raman and (FT)IR Spectra -Version: 1.0.3 -Date: 2023-09-13 +Version: 1.0.4 +Date: 2023-10-01 Authors@R: c(person("Win", "Cowger", role = c("cre", "aut", "dtc"), email = "wincowger@gmail.com", comment = c(ORCID = "0000-0001-9226-3104")), @@ -11,13 +11,13 @@ Authors@R: c(person("Win", "Cowger", role = c("cre", "aut", "dtc"), comment = c(ORCID = "0000-0001-6675-5033")), person("Nick", "Leong", role = c("aut"), comment = c(ORCID = "0009-0008-3313-4132")), - person("Andrea","Faltynkova", role = c("aut", "dtc"), + person("Andrea", "Faltynkova", role = c("aut", "dtc"), comment = c(ORCID = "0000-0003-2523-3137")), person("Andrew B", "Gray", role = c("ctb"), comment = c(ORCID = "0000-0003-2252-7367")), person("Hannah", "Hapich", role = c("ctb"), comment = c(ORCID = "0000-0003-0000-6632")), - person("Jennifer", "Lynch", role = c("ctb","dtc"), + person("Jennifer", "Lynch", role = c("ctb", "dtc"), comment = c(ORCID = "0000-0003-3572-8782")), person("Hannah", "De Frond", role = c("ctb", "dtc"), comment = c(ORCID = "0000-0003-1199-0727")), @@ -42,6 +42,14 @@ Authors@R: c(person("Win", "Cowger", role = c("cre", "aut", "dtc"), comment = c(ORCID = "0000-0003-1211-9351")), person("Samiksha", "Singh", role = c("ctb")), person("Katherine", "Lasdin", role = c("ctb")), + person("Cristiane", "Vidal", role = c("ctb"), + comment = c(ORCID = "0000-0001-6363-9475")), + person("Clare", "Murphy-Hagan", role = c("ctb"), + comment = c(ORCID = "0009-0009-9629-2856")), + person("Philipp", "Baumann", role = c("ctb"), + email = "info@spectral-cockpit.space", + comment = c(ORCID = "0000-0002-3194-8975")), + person("Pierre", "Roudier", role = c("ctb")), person("National Renewable Energy Laboratory", role = c("fnd")), person("Possibility Lab", role = c("fnd"))) Description: Raman and (FT)IR spectral analysis tool for plastic particles and diff --git a/NEWS.md b/NEWS.md index 3fba8728..5fc26c8d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,16 @@ +# OpenSpecy 1.0.4 + +## Minor Improvements + +- More contributors +- `showlegend` argument for interactive plots + +## Bug Fixes + +- Fixes a fatal error in `match_spec()` probably causing incorrect + identifications + + # OpenSpecy 1.0.3 ## Minor Improvements diff --git a/R/OpenSpecy-package.R b/R/OpenSpecy-package.R index 9ae22c6b..bb83bcd1 100644 --- a/R/OpenSpecy-package.R +++ b/R/OpenSpecy-package.R @@ -12,7 +12,7 @@ #' \emph{Applied Spectroscopy}, \strong{74}(9), 989–1010. #' \doi{10.1177/0003702820929064}. #' -#' Cowger, W (2021). “Library data.” \emph{OSF}. \doi{10.17605/OSF.IO/X7DPZ}. +#' Cowger, W (2023). “Library data.” \emph{OSF}. \doi{10.17605/OSF.IO/X7DPZ}. #' #' Cowger W, Steinmetz Z, Gray A, Munno K, Lynch J, Hapich H, Primpke S, #' De Frond H, Rochman C, Herodotou O (2021). “Microplastic Spectral diff --git a/R/as_OpenSpecy.R b/R/as_OpenSpecy.R index bacdc11f..d4b3557a 100644 --- a/R/as_OpenSpecy.R +++ b/R/as_OpenSpecy.R @@ -182,13 +182,13 @@ as_OpenSpecy.data.frame <- function(x, colnames = list(wavenumber = NULL, if (is.null(colnames$wavenumber)) { if (any(grepl("wav", ignore.case = T, names(x)))) { if (length(grep("wav", ignore.case = T, names(x))) > 1L) - warning("Ambiguous column names: taking 'wavenumber' data from the", + message("Ambiguous column names: taking 'wavenumber' data from the", " first column; use 'colnames' to supply user-defined columns", call. = F) wavenumber <- x[[grep("wav", ignore.case = T, names(x))[1L]]] wn <- names(x)[grep("wav", ignore.case = T, names(x))] } else { - warning("Ambiguous column names: taking 'wavenumber' data from the", + message("Ambiguous column names: taking 'wavenumber' data from the", " first column; use 'colnames' to supply user-defined columns", call. = F) wavenumber <- x[[1L]] @@ -205,7 +205,7 @@ as_OpenSpecy.data.frame <- function(x, colnames = list(wavenumber = NULL, spectra <- x[, grepl("(transmit.*)|(reflect.*)|(abs.*)|(intens.*)", ignore.case = T, names(x)), with = F] } else { - warning("Ambiguous column names: taking 'spectra' data from all but the", + message("Ambiguous column names: taking 'spectra' data from all but the", " 'wavenumber' column; use 'colnames' to supply user-defined", " columns", call. = F) spectra <- x[, -wn, with = F] @@ -274,7 +274,7 @@ as_OpenSpecy.default <- function(x, spectra, if (inherits(coords, "character")) { obj$metadata <- do.call(coords, list(ncol(obj$spectra))) - } else if (inherits(coords, c("data.frame", "list")) && + } else if(inherits(coords, c("data.frame", "list")) && all(is.element(c("x", "y"), names(coords)))) { obj$metadata <- as.data.table(coords) } else if(is.null(coords)){ @@ -286,14 +286,13 @@ as_OpenSpecy.default <- function(x, spectra, if (!is.null(metadata)) { if (inherits(metadata, c("data.frame", "list"))) { obj$metadata <- cbind(obj$metadata, as.data.table(metadata)) + obj$metadata$col_id <- names(obj$spectra) if(session_id) obj$metadata$session_id <- paste(digest(Sys.info()), digest(sessionInfo()), sep = "/") if(!c("file_id") %in% names(obj$metadata)) - obj$metadata$file_id = digest(obj[c("wavenumber", "spectra")]) - if(!c("col_id") %in% names(obj$metadata)) - obj$metadata$col_id = names(obj$spectra) + obj$metadata$file_id <- digest(obj[c("wavenumber", "spectra")]) } else { stop("inconsistent input for 'metadata'", call. = F) } diff --git a/R/interactive_plots.R b/R/interactive_plots.R index 117f3be7..fa276eae 100644 --- a/R/interactive_plots.R +++ b/R/interactive_plots.R @@ -32,7 +32,13 @@ #' @param font list; passed to \code{\link[plotly]{layout}()}. #' @param plot_bgcolor color value; passed to \code{\link[plotly]{layout}()}. #' @param paper_bgcolor color value; passed to \code{\link[plotly]{layout}()}. -#' @param colorscale colorscale passed to \code{\link[plotly]{add_trace}()}. +#' @param colorscale colorscale passed to \code{\link[plotly]{add_trace}()} can +#' be an array or one of `"Blackbody"`, `"Bluered"`, `"Blues"`, `"Cividis"`, +#' `"Earth"`, `"Electric"`, `"Greens"`, `"Greys"`, `"Hot"`, `"Jet"`, `"Picnic"`, +#' `"Portland"`, `"Rainbow"`, `"RdBu"`, `"Reds"`, `"Viridis"`, `"YlGnBu"`, +#' `"YlOrRd"`. +#' @param showlegend whether to show the legend passed to +#' \code{\link[plotly]{plot_ly}()}. #' @param \ldots further arguments passed to \code{\link[plotly]{plot_ly}()}. #' #' @return @@ -46,7 +52,7 @@ #' tiny_map <- read_extdata("CA_tiny_map.zip") |> read_zip() #' plotly_spec(raman_hdpe) #' -#' heatmap_spec(tiny_map, z = tiny_map$metadata$y) +#' heatmap_spec(tiny_map, z = tiny_map$metadata$y, showlegend = TRUE) #' #' sample_spec(tiny_map, size = 12) |> #' interactive_plot(select = 2, x2 = raman_hdpe) @@ -72,54 +78,64 @@ plotly_spec.default <- function(x, ...) { #' @rdname interactive_plots #' #' @export -plotly_spec.OpenSpecy <- function(x, x2 = NULL, +plotly_spec.OpenSpecy <- function(x, + x2 = NULL, line = list(color = 'rgb(255, 255, 255)'), line2 = list(dash = "dot", color = "rgb(255,0,0)"), font = list(color = '#FFFFFF'), plot_bgcolor = 'rgba(17, 0, 73, 0)', paper_bgcolor = 'rgb(0, 0, 0)', + showlegend = FALSE, ...) { x <- make_rel(x, na.rm = T) dt <- cbind(wavenumber = x$wavenumber, x$spectra) |> - melt(id.vars = "wavenumber", variable.name = "id", value.name = "intensity") - - p <- plot_ly(dt, type = "scatter", mode = "lines") |> - add_trace(x = ~wavenumber, - y = ~intensity, - split = ~id, - line = line, - name = "x1", - showlegend = F) |> - layout(xaxis = list(title = "wavenumber [cm-1]", - autorange = "reversed"), - yaxis = list(title = "intensity [-]"), - plot_bgcolor = plot_bgcolor, - paper_bgcolor = paper_bgcolor, - legend = list(orientation = 'h', y = 1.1), - font = font) - - # Add dummy trace for Your Spectra - p <- p |> - add_trace(x = NULL, y = NULL, - line = line, name = "x1", showlegend = T) - - if (!is.null(x2)) { + melt( + id.vars = "wavenumber", + variable.name = "id", + value.name = "intensity" + ) + + p <- plot_ly(dt, type = "scatter", mode = "lines", ...) |> + add_trace( + x = ~ wavenumber, + y = ~ intensity, + split = ~ id, + line = line, + name = "x1", + showlegend = showlegend + ) |> + layout( + xaxis = list(title = "wavenumber [cm-1]", + autorange = "reversed"), + yaxis = list(title = "intensity [-]"), + plot_bgcolor = plot_bgcolor, + paper_bgcolor = paper_bgcolor, + legend = list(orientation = 'h', y = 1.1), + font = font + ) + + if(!is.null(x2)) { x2 <- make_rel(x2, na.rm = T) dt2 <- cbind(wavenumber = x2$wavenumber, x2$spectra) |> - melt(id.vars = "wavenumber", variable.name = "id", value.name = "intensity") + melt( + id.vars = "wavenumber", + variable.name = "id", + value.name = "intensity" + ) p <- p |> - add_trace(data = dt2, x = ~wavenumber, y = ~intensity, - split = ~id, type = "scatter", mode = "lines", - name = "x2", - line = line2, showlegend = F) - - # Add dummy trace for Library Spectra - p <- p |> - add_trace(x = NULL, y = NULL, - line = line2, - name = "x2", showlegend = T) + add_trace( + data = dt2, + x = ~ wavenumber, + y = ~ intensity, + split = ~ id, + type = "scatter", + mode = "lines", + name = "x2", + line = line2, + showlegend = showlegend + ) } return(p) @@ -143,12 +159,17 @@ heatmap_spec.default <- function(x, ...) { #' #' @export heatmap_spec.OpenSpecy <- function(x, - z = NULL, sn = NULL, cor = NULL, - min_sn = NULL, min_cor = NULL, select = NULL, + z = NULL, + sn = NULL, + cor = NULL, + min_sn = NULL, + min_cor = NULL, + select = NULL, font = list(color = '#FFFFFF'), plot_bgcolor = 'rgba(17, 0, 73, 0)', paper_bgcolor = 'rgb(0, 0, 0)', colorscale = 'Viridis', + showlegend = FALSE, ...) { if(!is.null(z)) plot_z <- z # default @@ -156,37 +177,76 @@ heatmap_spec.OpenSpecy <- function(x, plot_z <- cor else if(!is.null(sn)) plot_z <- sn - else stop("z, cor, or sn need to be specified to plot the z axis", call. = F) + else + stop("z, cor, or sn need to be specified to plot the z axis", call. = F) - if (!is.null(sn) && !is.null(min_sn)) + if(!is.null(sn) && !is.null(min_sn)) plot_z <- ifelse(sn > min_sn, plot_z, NA) - if (!is.null(cor) && !is.null(min_cor)) + if(!is.null(cor) && !is.null(min_cor)) plot_z <- ifelse(cor > min_cor, plot_z, NA) if(all(is.na(plot_z))) - plot_z = rep(-88, length.out = length(plot_z)) + plot_z = rep(-88, length.out = length(plot_z)) p <- plot_ly(...) |> - add_trace(x = x$metadata$x, y = x$metadata$y, z = if(!is.numeric(plot_z)){as.numeric(as.factor(plot_z))} else{plot_z}, - colorscale = colorscale, type = "heatmap", hoverinfo = 'text', - showscale = F, - text = ~paste("row: ", 1:nrow(x$metadata), - "
x: ", x$metadata$x,", y: ", x$metadata$y, - ", z: ", plot_z, - if(!is.null(sn)) paste("
snr: ", signif(sn, 2)) else "", - if(!is.null(cor)) paste("
cor: ", signif(cor, 2)) else "" - )) |> + add_trace( + x = x$metadata$x, + y = x$metadata$y, + z = if(!is.numeric(plot_z)) { + as.numeric(as.factor(plot_z)) + } else { + plot_z + }, + colorscale = colorscale, + type = "heatmap", + hoverinfo = 'text', + showscale = showlegend, + text = ~ paste( + "row: ", + 1:nrow(x$metadata), + "
x: ", + x$metadata$x, + ", y: ", + x$metadata$y, + ", z: ", + plot_z, + if(!is.null(sn)) + paste("
snr: ", signif(sn, 2)) + else + "", + if(!is.null(cor)) + paste("
cor: ", signif(cor, 2)) + else + "" + ) + ) |> layout( - xaxis = list(title = 'x', zeroline = F, showgrid = F), - yaxis = list(title = 'y', scaleanchor = "x", scaleratio = 1, - zeroline = F, showgrid = F), - plot_bgcolor = plot_bgcolor, paper_bgcolor = paper_bgcolor, - showlegend = FALSE, font = font) - - if(!is.null(select)){ - p <- p |> add_markers(x = x$metadata$x[select], y = x$metadata$y[select], - name = "Selected Spectrum") + xaxis = list( + title = 'x', + zeroline = F, + showgrid = F + ), + yaxis = list( + title = 'y', + scaleanchor = "x", + scaleratio = 1, + zeroline = F, + showgrid = F + ), + plot_bgcolor = plot_bgcolor, + paper_bgcolor = paper_bgcolor, + showlegend = showlegend, + font = font + ) + + if(!is.null(select)) { + p <- + p |> add_markers( + x = x$metadata$x[select], + y = x$metadata$y[select], + name = "Selected Spectrum" + ) } return(p) @@ -209,7 +269,9 @@ interactive_plot.default <- function(x, ...) { #' @rdname interactive_plots #' #' @export -interactive_plot.OpenSpecy <- function(x, x2 = NULL, select = NULL, +interactive_plot.OpenSpecy <- function(x, + x2 = NULL, + select = NULL, line = list(color = 'rgb(255, 255, 255)'), line2 = list(dash = "dot", color = "rgb(255,0,0)"), @@ -219,26 +281,42 @@ interactive_plot.OpenSpecy <- function(x, x2 = NULL, select = NULL, colorscale = 'Viridis', ...) { # Generate the heatmap - heat_map <- heatmap_spec(x, z = x$metadata$y, select = select, - font = font, plot_bgcolor = plot_bgcolor, - paper_bgcolor = paper_bgcolor, - colorscale = colorscale) + heat_map <- heatmap_spec( + x, + z = x$metadata$y, + select = select, + font = font, + plot_bgcolor = plot_bgcolor, + paper_bgcolor = paper_bgcolor, + colorscale = colorscale + ) x3 <- filter_spec(x, logic = select) # Generate the spectral plot - spectra_plot <- plotly_spec(x3, x2 = x2, - line = line, line2 = line2, font = font, - plot_bgcolor = plot_bgcolor, - paper_bgcolor = paper_bgcolor) - + spectra_plot <- plotly_spec( + x3, + x2 = x2, + line = line, + line2 = line2, + font = font, + plot_bgcolor = plot_bgcolor, + paper_bgcolor = paper_bgcolor + ) # Add margin to heatmap for separation - heat_map <- heat_map |> layout(autosize = TRUE, margin = list(b = 100)) + heat_map <- + heat_map |> layout(autosize = TRUE, margin = list(b = 100)) # Combine both plots using subplot - plot_grid <- subplot(heat_map, spectra_plot, nrows = 2, heights = c(0.6, 0.4), - margin = 0.1) + plot_grid <- + subplot( + heat_map, + spectra_plot, + nrows = 2, + heights = c(0.6, 0.4), + margin = 0.1 + ) # Show the interactive plot return(plot_grid) diff --git a/R/manage_lib.R b/R/manage_lib.R index 49ebcebd..4c77368b 100644 --- a/R/manage_lib.R +++ b/R/manage_lib.R @@ -3,10 +3,12 @@ #' #' @description #' These functions will import the spectral libraries from Open Specy if they -#' were not already downloaded. -#' The CRAN does not allow for deployment of large datasets so this was a -#' workaround that we are using to make sure everyone can easily get Open Specy -#' functionality running on their desktop. +#' were not already downloaded. The CRAN does not allow for deployment of large +#' datasets so this was a workaround that we are using to make sure everyone can +#' easily get Open Specy functionality running on their desktop. Please see the +#' references when using these libraries. These libraries are the accumulation +#' of a massive amount of effort from independant groups and each should be +#' attributed when you are using their data. #' #' @details #' \code{check_lib()} checks to see if the Open Specy reference library @@ -56,13 +58,113 @@ #' Zacharias Steinmetz, Win Cowger #' #' @references +#' Bell IB, Clark RJH, Gibbs PJ (2010). “Raman Spectroscopic Library.” +#' *Christopher Ingold Laboratories, University College London, UK*. +#' \url{https://www.chem.ucl.ac.uk/resources/raman/}. +#' +#' Berzinš K, Sales RE, Barnsley JE, Walker G, Fraser-Miller SJ, Gordon KC +#' (2020). “Low-Wavenumber Raman Spectral Database of Pharmaceutical +#' Excipients.” *Vibrational Spectroscopy* **107**, 103021. +#' \doi{10.5281/zenodo.3614035}. +#' +#' Cabernard L, Roscher L, Lorenz C, Gerdts G, Primpke S (2018). “Comparison of +#' Raman and Fourier Transform Infrared Spectroscopy for the Quantification of +#' Microplastics in the Aquatic Environment.” *Environmental Science & +#' Technology* **52**(22), 13279--13288. \doi{10.1021/acs.est.8b03438}. +#' +#' Caggiani MC, Cosentino A, Mangone A (2016). “Pigments Checker version 3.0, a +#' handy set for conservation scientists: A free online Raman spectra database.” +#' *Microchemical Journal* **129**, 123--132. +#' \doi{10.1016/j.microc.2016.06.020}. +#' +#' Chabuka BK, Kalivas JH (2020). “Application of a Hybrid Fusion Classification +#' Process for Identification of Microplastics Based on Fourier Transform +#' Infrared Spectroscopy. Applied Spectroscopy.” *Applied Spectroscopy* +#' **74**(9), 1167--1183. \doi{10.1177/0003702820923993}. +#' +#' Cowger, W (2023). “Library data.” \emph{OSF}. \doi{10.17605/OSF.IO/X7DPZ}. +#' #' Cowger W, Gray A, Christiansen SH, De Frond H, Deshpande AD, Hemabessiere L, #' Lee E, Mill L, et al. (2020). “Critical Review of Processing and #' Classification Techniques for Images and Spectra in Microplastic Research.” -#' \emph{Applied Spectroscopy}, \strong{74}(9), 989–1010. +#' \emph{Applied Spectroscopy}, \strong{74}(9), 989--1010. #' \doi{10.1177/0003702820929064}. #' -#' Cowger, W (2021). “Library data.” \emph{OSF}. \doi{10.17605/OSF.IO/X7DPZ}. +#' Cowger W, Roscher L, Chamas A, Maurer B, Gehrke L, Jebens H, Gerdts G, +#' Primpke S (2023). “High Throughput FTIR Analysis of Macro and Microplastics +#' with Plate Readers.” *ChemRxiv Preprint*. \doi{10.26434/chemrxiv-2023-x88ss}. +#' +#' De Frond H, Rubinovitz R, Rochman CM (2021). “µATR-FTIR Spectral Libraries of +#' Plastic Particles (FLOPP and FLOPP-e) for the Analysis of Microplastics.” +#' *Analytical Chemistry* **93**(48), 15878--15885. +#' \doi{10.1021/acs.analchem.1c02549}. +#' +#' El Mendili Y, Vaitkus A, Merkys A, Gražulis S, Chateigner D, Mathevet F, +#' Gascoin S, Petit S, Bardeau JF, Zanatta M, Secchi M, Mariotto G, Kumar A, +#' Cassetta M, Lutterotti L, Borovin E, Orberger B, Simon P, Hehlen B, +#' Le Guen M (2019). “Raman Open Database: first interconnected Raman–X-ray +#' diffraction open-access resource for material identification.” *Journal of +#' Applied Crystallography*, **52**(3), 618--625. +#' \doi{10.1107/s1600576719004229}. +#' +#' Johnson TJ, Blake TA, Brauer CS, Su YF, Bernacki BE, Myers TL, Tonkyn RG, +#' Kunkel BM, Ertel AB (2015). “Reflectance Spectroscopy for Sample +#' Identification: Considerations for Quantitative Library +#' Results at Infrared Wavelengths.” *International Conference on Advanced +#' Vibrational Spectroscopy (ICAVS 8)*. +#' \url{https://www.osti.gov/biblio/1452877}. +#' +#' Lafuente R, Downs RT, Yang H, Stone N (2016). “The power of databases: The +#' RRUFF project.” *Highlights in Mineralogical Crystallography*. +#' \doi{10.1515/9783110417104-003}. +#' +#' Munno K, De Frond H, O’Donnell B, Rochman CM (2020). “Increasing the +#' Accessibility for Characterizing Microplastics: Introducing New +#' Application-Based and Spectral Libraries of Plastic Particles (SLoPP and +#' SLoPP-E).” *Analytical Chemistry* **92**(3), 2443--2451. +#' \doi{10.1021/acs.analchem.9b03626}. +#' +#' Myers TL, Brauer CS, Su YF, Blake TA, Johnson TJ, Richardson RL (2014). +#' “The influence of particle size on infrared reflectance spectra.” +#' *Proceedings Volume 9088, Algorithms and Technologies for Multispectral, +#' Hyperspectral, and Ultraspectral Imagery XX*, 908809. +#' \doi{10.1117/12.2053350}. +#' +#' Myers TL, Brauer CS, Su YF, Blake TA, Tonkyn RG, Ertel AB, Johnson TJ, +#' Richardson RL (2015). “Quantitative reflectance spectra of solid powders +#' as a function of particle size.” *Applied Optics* **54**(15), 4863--4875. +#' \doi{10.1364/ao.54.004863}. +#' +#' Primpke S, Wirth M, Lorenz C, Gerdts G (2018). “Reference database design +#' for the automated analysis of microplastic samples based on Fourier +#' transform infrared (FTIR) spectroscopy.” +#' *Analytical and Bioanalytical Chemistry* **410**, 5131–-5141. +#' \doi{10.1007/s00216-018-1156-x}. +#' +#' Roscher L, Fehres A, Reisel L, Halbach M, Scholz-Böttcher B, Gerriets M, +#' Badewien TH, Shiravani G, Wurpts A, Primpke S, Gerdts G (2021). “Abundances +#' of large microplastics (L-MP, 500-5000 µm) in surface waters of the Weser +#' estuary and the German North Sea.” *PANGAEA*. \doi{10.1594/PANGAEA.938143}. +#' +#' “Handbook of Raman Spectra for geology” (2023). +#' \url{http://www.geologie-lyon.fr/Raman/}. +#' +#' “Scientific Workgroup for the Analysis of Seized Drugs.” (2023). +#' https://swgdrug.org/ir.htm. +#' +#' **Further contribution of spectra:** +#' Suja Sukumaran (Thermo Fisher Scientific), +#' Aline Carvalho, +#' Jennifer Lynch (NIST), +#' Claudia Cella and Dora Mehn (JRC), +#' Horiba Scientific, +#' USDA Soil Characterization Data +#' (\url{https://ncsslabdatamart.sc.egov.usda.gov}), +#' Archaeometrielabor, +#' and S.B. Engelsen (Royal Vet. and Agricultural University, Denmark). +#' Kimmel Center data was collected and provided by Prof. Steven Weiner +#' (Kimmel Center for Archaeological Science, Weizmann Institute of Science, +#' Israel). #' #' @export check_lib <- function(type = c("derivative", "nobaseline", "raw", "mediod", diff --git a/R/match_spec.R b/R/match_spec.R index 4a1c95c9..1a3467c5 100644 --- a/R/match_spec.R +++ b/R/match_spec.R @@ -138,7 +138,7 @@ match_spec.OpenSpecy <- function(x, library, na.rm = T, top_n = NULL, order = NULL, add_library_metadata = NULL, add_object_metadata = NULL, fill = NULL, ...) { if(is_OpenSpecy(library)) { - res <- cor_spec(x, library = library) |> + res <- cor_spec(x, library = library) |> ident_spec(x, library = library, top_n = top_n, add_library_metadata = add_library_metadata, add_object_metadata = add_object_metadata) @@ -163,25 +163,28 @@ ident_spec <- function(cor_matrix, x, library, top_n = NULL, add_object_metadata = NULL, ...){ if(is.numeric(top_n) && top_n > ncol(library$spectra)){ top_n = NULL - message("'top_n' was larger than the number of spectra in the library; ", + message("'top_n' larger than the number of spectra in the library; ", "returning all matches") } - out <- data.table(object_id = colnames(x$spectra), - library_id = rep(colnames(library$spectra), - each = ncol(x$spectra)), - match_val = c(cor_matrix)) + out <- as.data.table(cor_matrix, keep.rownames = T) |> melt(id.vars = "rn") - if (is.character(add_library_metadata)) + names(out) <- c("library_id", "object_id", "match_val") + + if(is.numeric(top_n)) { + match_val <- NULL # workaround for data.table non-standard evaluation + setorder(out, -match_val) + out <- out[!is.na(match_val), head(.SD, top_n), by = "object_id"] + } + + if(is.character(add_library_metadata)) out <- merge(out, library$metadata, by.x = "library_id", by.y = add_library_metadata, all.x = T) - if (is.character(add_object_metadata)) + + if(is.character(add_object_metadata)) + out <- merge(out, x$metadata, by.x = "object_id", by.y = add_object_metadata, all.x = T) - if (is.numeric(top_n)) { - setorder(out, -"match_val") - out <- out[, head(.SD, top_n), by = "object_id"] - } return(out) } diff --git a/README.md b/README.md index d2db2c77..2744e7b8 100644 --- a/README.md +++ b/README.md @@ -103,5 +103,5 @@ Needs an Open Source Community: Open Specy to the Rescue!” [10.1021/acs.analchem.1c00123](https://doi.org/10.1021/acs.analchem.1c00123). Cowger W, Steinmetz Z, Leong N, Faltynkova A (2023). “OpenSpecy: Analyze, -Process, Identify, and Share Raman and (FT)IR Spectra.” *R package*, **1.0.3**. +Process, Identify, and Share Raman and (FT)IR Spectra.” *R package*, **1.0.4**. [https://github.com/wincowgerDEV/OpenSpecy-package](https://github.com/wincowgerDEV/OpenSpecy-package). diff --git a/cran-comments.md b/cran-comments.md index 009a957a..a2721f05 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -10,9 +10,16 @@ ## R CMD check results -0 errors | 0 warnings | 0 notes +0 errors | 0 warnings | 1 note ## Comments -For further details, see NEWS.md + installed size is 5.8Mb + sub-directories of 1Mb or more: + doc 4.3Mb + +We already tried to reduce the vignette size as much as possible but would like +to keep the current number of figures for better comprehensibility. + +For further details, see NEWS.md. diff --git a/man/OpenSpecy-package.Rd b/man/OpenSpecy-package.Rd index 05a95ade..9851d1e5 100644 --- a/man/OpenSpecy-package.Rd +++ b/man/OpenSpecy-package.Rd @@ -21,7 +21,7 @@ Classification Techniques for Images and Spectra in Microplastic Research.” \emph{Applied Spectroscopy}, \strong{74}(9), 989–1010. \doi{10.1177/0003702820929064}. -Cowger, W (2021). “Library data.” \emph{OSF}. \doi{10.17605/OSF.IO/X7DPZ}. +Cowger, W (2023). “Library data.” \emph{OSF}. \doi{10.17605/OSF.IO/X7DPZ}. Cowger W, Steinmetz Z, Gray A, Munno K, Lynch J, Hapich H, Primpke S, De Frond H, Rochman C, Herodotou O (2021). “Microplastic Spectral @@ -81,6 +81,10 @@ Other contributors: \item Rachel Kozloski (\href{https://orcid.org/0000-0003-1211-9351}{ORCID}) [contributor, data contributor] \item Samiksha Singh [contributor] \item Katherine Lasdin [contributor] + \item Cristiane Vidal (\href{https://orcid.org/0000-0001-6363-9475}{ORCID}) [contributor] + \item Clare Murphy-Hagan (\href{https://orcid.org/0009-0009-9629-2856}{ORCID}) [contributor] + \item Philipp Baumann \email{info@spectral-cockpit.space} (\href{https://orcid.org/0000-0002-3194-8975}{ORCID}) [contributor] + \item Pierre Roudier [contributor] \item National Renewable Energy Laboratory [funder] \item Possibility Lab [funder] } diff --git a/man/interactive_plots.Rd b/man/interactive_plots.Rd index 82b906ad..a93a86aa 100644 --- a/man/interactive_plots.Rd +++ b/man/interactive_plots.Rd @@ -24,6 +24,7 @@ plotly_spec(x, ...) font = list(color = "#FFFFFF"), plot_bgcolor = "rgba(17, 0, 73, 0)", paper_bgcolor = "rgb(0, 0, 0)", + showlegend = FALSE, ... ) @@ -43,6 +44,7 @@ heatmap_spec(x, ...) plot_bgcolor = "rgba(17, 0, 73, 0)", paper_bgcolor = "rgb(0, 0, 0)", colorscale = "Viridis", + showlegend = FALSE, ... ) @@ -81,6 +83,9 @@ spectral data for the second group.} \item{paper_bgcolor}{color value; passed to \code{\link[plotly]{layout}()}.} +\item{showlegend}{whether to show the legend passed to +\code{\link[plotly]{plot_ly}()}.} + \item{z}{optional numeric vector specifying the intensity values for the heatmap. If not provided, the function will use the intensity values from the \code{OpenSpecy} object.} @@ -104,7 +109,11 @@ will be excluded.} \item{select}{optional index of the selected spectrum to highlight on the heatmap.} -\item{colorscale}{colorscale passed to \code{\link[plotly]{add_trace}()}.} +\item{colorscale}{colorscale passed to \code{\link[plotly]{add_trace}()} can +be an array or one of \code{"Blackbody"}, \code{"Bluered"}, \code{"Blues"}, \code{"Cividis"}, +\code{"Earth"}, \code{"Electric"}, \code{"Greens"}, \code{"Greys"}, \code{"Hot"}, \code{"Jet"}, \code{"Picnic"}, +\code{"Portland"}, \code{"Rainbow"}, \code{"RdBu"}, \code{"Reds"}, \code{"Viridis"}, \code{"YlGnBu"}, +\code{"YlOrRd"}.} \item{\ldots}{further arguments passed to \code{\link[plotly]{plot_ly}()}.} } @@ -123,7 +132,7 @@ data("raman_hdpe") tiny_map <- read_extdata("CA_tiny_map.zip") |> read_zip() plotly_spec(raman_hdpe) -heatmap_spec(tiny_map, z = tiny_map$metadata$y) +heatmap_spec(tiny_map, z = tiny_map$metadata$y, showlegend = TRUE) sample_spec(tiny_map, size = 12) |> interactive_plot(select = 2, x2 = raman_hdpe) diff --git a/man/manage_lib.Rd b/man/manage_lib.Rd index d5d163f0..e809d106 100644 --- a/man/manage_lib.Rd +++ b/man/manage_lib.Rd @@ -63,10 +63,12 @@ respective spectral reference library. } \description{ These functions will import the spectral libraries from Open Specy if they -were not already downloaded. -The CRAN does not allow for deployment of large datasets so this was a -workaround that we are using to make sure everyone can easily get Open Specy -functionality running on their desktop. +were not already downloaded. The CRAN does not allow for deployment of large +datasets so this was a workaround that we are using to make sure everyone can +easily get Open Specy functionality running on their desktop. Please see the +references when using these libraries. These libraries are the accumulation +of a massive amount of effort from independant groups and each should be +attributed when you are using their data. } \details{ \code{check_lib()} checks to see if the Open Specy reference library @@ -87,13 +89,113 @@ spec_lib <- load_lib("derivative") } \references{ +Bell IB, Clark RJH, Gibbs PJ (2010). “Raman Spectroscopic Library.” +\emph{Christopher Ingold Laboratories, University College London, UK}. +\url{https://www.chem.ucl.ac.uk/resources/raman/}. + +Berzinš K, Sales RE, Barnsley JE, Walker G, Fraser-Miller SJ, Gordon KC +(2020). “Low-Wavenumber Raman Spectral Database of Pharmaceutical +Excipients.” \emph{Vibrational Spectroscopy} \strong{107}, 103021. +\doi{10.5281/zenodo.3614035}. + +Cabernard L, Roscher L, Lorenz C, Gerdts G, Primpke S (2018). “Comparison of +Raman and Fourier Transform Infrared Spectroscopy for the Quantification of +Microplastics in the Aquatic Environment.” \emph{Environmental Science & +Technology} \strong{52}(22), 13279--13288. \doi{10.1021/acs.est.8b03438}. + +Caggiani MC, Cosentino A, Mangone A (2016). “Pigments Checker version 3.0, a +handy set for conservation scientists: A free online Raman spectra database.” +\emph{Microchemical Journal} \strong{129}, 123--132. +\doi{10.1016/j.microc.2016.06.020}. + +Chabuka BK, Kalivas JH (2020). “Application of a Hybrid Fusion Classification +Process for Identification of Microplastics Based on Fourier Transform +Infrared Spectroscopy. Applied Spectroscopy.” \emph{Applied Spectroscopy} +\strong{74}(9), 1167--1183. \doi{10.1177/0003702820923993}. + +Cowger, W (2023). “Library data.” \emph{OSF}. \doi{10.17605/OSF.IO/X7DPZ}. + Cowger W, Gray A, Christiansen SH, De Frond H, Deshpande AD, Hemabessiere L, Lee E, Mill L, et al. (2020). “Critical Review of Processing and Classification Techniques for Images and Spectra in Microplastic Research.” -\emph{Applied Spectroscopy}, \strong{74}(9), 989–1010. +\emph{Applied Spectroscopy}, \strong{74}(9), 989--1010. \doi{10.1177/0003702820929064}. -Cowger, W (2021). “Library data.” \emph{OSF}. \doi{10.17605/OSF.IO/X7DPZ}. +Cowger W, Roscher L, Chamas A, Maurer B, Gehrke L, Jebens H, Gerdts G, +Primpke S (2023). “High Throughput FTIR Analysis of Macro and Microplastics +with Plate Readers.” \emph{ChemRxiv Preprint}. \doi{10.26434/chemrxiv-2023-x88ss}. + +De Frond H, Rubinovitz R, Rochman CM (2021). “µATR-FTIR Spectral Libraries of +Plastic Particles (FLOPP and FLOPP-e) for the Analysis of Microplastics.” +\emph{Analytical Chemistry} \strong{93}(48), 15878--15885. +\doi{10.1021/acs.analchem.1c02549}. + +El Mendili Y, Vaitkus A, Merkys A, Gražulis S, Chateigner D, Mathevet F, +Gascoin S, Petit S, Bardeau JF, Zanatta M, Secchi M, Mariotto G, Kumar A, +Cassetta M, Lutterotti L, Borovin E, Orberger B, Simon P, Hehlen B, +Le Guen M (2019). “Raman Open Database: first interconnected Raman–X-ray +diffraction open-access resource for material identification.” \emph{Journal of +Applied Crystallography}, \strong{52}(3), 618--625. +\doi{10.1107/s1600576719004229}. + +Johnson TJ, Blake TA, Brauer CS, Su YF, Bernacki BE, Myers TL, Tonkyn RG, +Kunkel BM, Ertel AB (2015). “Reflectance Spectroscopy for Sample +Identification: Considerations for Quantitative Library +Results at Infrared Wavelengths.” \emph{International Conference on Advanced +Vibrational Spectroscopy (ICAVS 8)}. +\url{https://www.osti.gov/biblio/1452877}. + +Lafuente R, Downs RT, Yang H, Stone N (2016). “The power of databases: The +RRUFF project.” \emph{Highlights in Mineralogical Crystallography}. +\doi{10.1515/9783110417104-003}. + +Munno K, De Frond H, O’Donnell B, Rochman CM (2020). “Increasing the +Accessibility for Characterizing Microplastics: Introducing New +Application-Based and Spectral Libraries of Plastic Particles (SLoPP and +SLoPP-E).” \emph{Analytical Chemistry} \strong{92}(3), 2443--2451. +\doi{10.1021/acs.analchem.9b03626}. + +Myers TL, Brauer CS, Su YF, Blake TA, Johnson TJ, Richardson RL (2014). +“The influence of particle size on infrared reflectance spectra.” +\emph{Proceedings Volume 9088, Algorithms and Technologies for Multispectral, +Hyperspectral, and Ultraspectral Imagery XX}, 908809. +\doi{10.1117/12.2053350}. + +Myers TL, Brauer CS, Su YF, Blake TA, Tonkyn RG, Ertel AB, Johnson TJ, +Richardson RL (2015). “Quantitative reflectance spectra of solid powders +as a function of particle size.” \emph{Applied Optics} \strong{54}(15), 4863--4875. +\doi{10.1364/ao.54.004863}. + +Primpke S, Wirth M, Lorenz C, Gerdts G (2018). “Reference database design +for the automated analysis of microplastic samples based on Fourier +transform infrared (FTIR) spectroscopy.” +\emph{Analytical and Bioanalytical Chemistry} \strong{410}, 5131–-5141. +\doi{10.1007/s00216-018-1156-x}. + +Roscher L, Fehres A, Reisel L, Halbach M, Scholz-Böttcher B, Gerriets M, +Badewien TH, Shiravani G, Wurpts A, Primpke S, Gerdts G (2021). “Abundances +of large microplastics (L-MP, 500-5000 µm) in surface waters of the Weser +estuary and the German North Sea.” \emph{PANGAEA}. \doi{10.1594/PANGAEA.938143}. + +“Handbook of Raman Spectra for geology” (2023). +\url{http://www.geologie-lyon.fr/Raman/}. + +“Scientific Workgroup for the Analysis of Seized Drugs.” (2023). +https://swgdrug.org/ir.htm. + +\strong{Further contribution of spectra:} +Suja Sukumaran (Thermo Fisher Scientific), +Aline Carvalho, +Jennifer Lynch (NIST), +Claudia Cella and Dora Mehn (JRC), +Horiba Scientific, +USDA Soil Characterization Data +(\url{https://ncsslabdatamart.sc.egov.usda.gov}), +Archaeometrielabor, +and S.B. Engelsen (Royal Vet. and Agricultural University, Denmark). +Kimmel Center data was collected and provided by Prof. Steven Weiner +(Kimmel Center for Archaeological Science, Weizmann Institute of Science, +Israel). } \author{ Zacharias Steinmetz, Win Cowger diff --git a/tests/testthat/test-as_OpenSpecy.R b/tests/testthat/test-as_OpenSpecy.R index 455f51c9..57c72dad 100644 --- a/tests/testthat/test-as_OpenSpecy.R +++ b/tests/testthat/test-as_OpenSpecy.R @@ -11,13 +11,13 @@ test_that("as_OpenSpecy() handles errors correctly", { expect_error() as_OpenSpecy(data.frame(x = df$wavenumber, abs = df$intensity)) |> - expect_warning() + expect_message() as_OpenSpecy(data.frame(wav = df$wavenumber, y = df$intensity)) |> - expect_warning() + expect_message() amb <- df names(amb) <- c("a", "b") - as_OpenSpecy(amb) |> expect_warning() |> expect_warning() + as_OpenSpecy(amb) |> expect_message() |> expect_message() as_OpenSpecy(df$wavenumber, as.data.frame(df$intensity), coords = "") |> expect_error() @@ -57,6 +57,7 @@ test_that("as_OpenSpecy() generates OpenSpecy objects", { expect_equal(ost$spectra, osf$spectra) expect_equal(ost$wavenumber, osf$wavenumber) expect_equal(ost$metadata, osf$metadata) + expect_equal(osf$metadata$col_id, names(osf$spectra)) }) test_that("check_OpenSpecy() work as expected", { diff --git a/tests/testthat/test-match_spec.R b/tests/testthat/test-match_spec.R index 03898a4c..c77b118c 100644 --- a/tests/testthat/test-match_spec.R +++ b/tests/testthat/test-match_spec.R @@ -4,6 +4,12 @@ dir.create(tmp, showWarnings = F) data("test_lib") +tiny_map <- read_extdata("CA_tiny_map.zip") |> + read_any() |> + conform_spec(range = test_lib$wavenumber, + res = NULL) |> + process_spec(smooth_intens = T, make_rel = T) + unknown <- read_extdata("ftir_ldpe_soil.asp") |> read_any() preproc <- conform_spec(unknown, range = test_lib$wavenumber, res = spec_res(test_lib)) |> @@ -20,7 +26,9 @@ test_that("match_spec() returns correct structure with AI", { get_lib("model", path = tmp) lib <- load_lib(type = "model", path = tmp) - check_OpenSpecy(lib) |> expect_error() |> expect_warning() |> expect_warning() |> expect_warning() |> expect_warning() |> expect_warning() + check_OpenSpecy(lib) |> + expect_error() |> expect_warning() |> expect_warning() |> + expect_warning() |> expect_warning() |> expect_warning() set.seed(47) rn <- runif(n = length(unique(lib$variables_in))) @@ -52,10 +60,10 @@ test_that("match_spec() returns correct structure", { nrow(matches) |> expect_equal(5) names(matches) |> expect_contains(c("object_id", "library_id", "match_val")) - round(matches$match_val, 2) |> expect_equal(c(0.67, 0.57, 0.55, 0.50, 0.43)) + round(matches$match_val, 2) |> expect_equal(c(0.57, 0.67, 0.55, 0.43, 0.50)) tolower(matches$polymer) |> expect_equal( - c("poly(ethylene)", "polystyrene", "poly(vinyl chloride)", - "poly(dimethylsiloxane) (pdms)", NA) + c("polystyrene", "poly(ethylene)", "poly(vinyl chloride)", NA, + "poly(dimethylsiloxane) (pdms)") ) expect_equal(matches, order) }) @@ -104,10 +112,10 @@ test_that("cor_spec() returns a data.table with correct columns", { nrow(full_test) |> expect_equal(5) names(full_test) |> expect_contains(c("object_id", "library_id", "match_val")) - round(full_test$match_val, 2) |> expect_equal(c(0.67, 0.57, 0.55, 0.50, 0.43)) + round(full_test$match_val, 2) |> expect_equal(c(0.57, 0.67, 0.55, 0.43, 0.50)) tolower(full_test$polymer) |> expect_equal( - c("poly(ethylene)", "polystyrene", "poly(vinyl chloride)", - "poly(dimethylsiloxane) (pdms)", NA) + c("polystyrene", "poly(ethylene)", "poly(vinyl chloride)", NA, + "poly(dimethylsiloxane) (pdms)") ) }) @@ -115,6 +123,19 @@ test_that("filter_spec() handles input errors correctly", { filter_spec(1:1000) |> expect_error() }) +test_that("Test that raman hdpe accurately identified", { + proc_rhdpe <- process_spec(raman_hdpe,conform_spec = T, + conform_spec_args = list(range = test_lib$wavenumber, + res = NULL, + type = "interp")) + + check <- match_spec(proc_rhdpe, test_lib, top_n = 1, + add_library_metadata = "sample_name") + + expect_identical(round(check$match_val, 3), 0.974) + expect_identical(check$polymer_class, "Polyolefins (POLYALKENES)") +}) + # Write the tests for filter_spec function test_that("filter_spec() returns erroneous OpenSpecy object when removing all spectra", { os_filtered <- filter_spec(test_lib, logic = rep(F, ncol(test_lib$spectra))) |> @@ -141,5 +162,13 @@ test_that("get_metadata() handles input errors correctly", { get_metadata(1:1000) |> expect_error() }) +test_that("cor_spec() routine and match_spec() return same values", { + cors <- cor_spec(tiny_map, test_lib) + max_correlations <- max_cor_named(cors) + names <- max_correlations |> sort(decreasing = T) |> names() + top_matches <- match_spec(x = tiny_map, library = test_lib, top_n = 1) + expect_identical(names, top_matches$library_id) +}) + # Tidy up unlink(tmp, recursive = T) diff --git a/tests/testthat/test-read_ext.R b/tests/testthat/test-read_ext.R index a0fe2af4..ffa73b40 100644 --- a/tests/testthat/test-read_ext.R +++ b/tests/testthat/test-read_ext.R @@ -23,15 +23,15 @@ test_that("read_text() gives expected output", { dtf <- read_extdata("raman_hdpe.csv") |> read_text(method = "fread") |> expect_silent() read_extdata("ftir_pva_without_header.csv") |> read_text() |> - expect_warning() |> expect_warning() + expect_message() |> expect_message() read_extdata("ftir_pva_without_header.csv") |> read_text(header = F) |> - expect_warning() |> expect_warning() + expect_message() |> expect_message() read_extdata("ftir_pva_without_header.csv") |> read_text(method = "fread") |> - expect_warning() |> expect_warning() + expect_message() |> expect_message() expect_s3_class(csv, "OpenSpecy") expect_true(check_OpenSpecy(csv)) - + expect_equal(names(csv), c("wavenumber", "spectra", "metadata")) expect_equal(csv$wavenumber, raman_hdpe$wavenumber) expect_equal(csv$spectra, raman_hdpe$spectra) @@ -48,7 +48,7 @@ test_that("read_asp() gives expected output", { expect_s3_class(asp, "OpenSpecy") expect_true(check_OpenSpecy(asp)) - + expect_equal(names(asp), c("wavenumber", "spectra", "metadata")) expect_length(asp$wavenumber, 1798) range(asp$wavenumber) |> round(1) |> @@ -68,7 +68,7 @@ test_that("read_spa() gives expected output", { expect_s3_class(spa, "OpenSpecy") expect_true(check_OpenSpecy(spa)) - + expect_equal(names(spa), c("wavenumber", "spectra", "metadata")) expect_length(spa$wavenumber, 1738) range(spa$wavenumber) |> round(1) |> @@ -87,7 +87,7 @@ test_that("read_jdx() gives expected output", { expect_s3_class(jdx, "OpenSpecy") expect_true(check_OpenSpecy(jdx)) - + expect_equal(names(jdx), c("wavenumber", "spectra", "metadata")) expect_length(jdx$wavenumber, 7154) range(jdx$wavenumber) |> round(1) |> @@ -106,7 +106,7 @@ test_that("read_spc() gives expected output", { expect_s3_class(spc, "OpenSpecy") expect_true(check_OpenSpecy(spc)) - + expect_equal(names(spc), c("wavenumber", "spectra", "metadata")) expect_length(spc$wavenumber, 559) range(spc$wavenumber) |> round(1) |> diff --git a/vignettes/advanced.Rmd b/vignettes/advanced.Rmd index 637a3e3f..2f3ff453 100644 --- a/vignettes/advanced.Rmd +++ b/vignettes/advanced.Rmd @@ -46,7 +46,7 @@ current Open Specy spectral libraries to improve material identification and reduce sample processing times. Pearson's r values range from 0 - 1 with 0 being a completely different spectrum and 1 being an exact match. Some general guidelines that we have observed from using Open Specy. If no matches are \> -\~0.3 the material may require additional processing or may not exist in the +\~0.6 the material may require additional processing or may not exist in the Open Specy library. Correlation values are not the only metric you should use to assess your spectra's match to a material in the library, matches need to make sense. diff --git a/vignettes/sop.Rmd b/vignettes/sop.Rmd index b5e35f2a..f11b8126 100644 --- a/vignettes/sop.Rmd +++ b/vignettes/sop.Rmd @@ -1,7 +1,7 @@ --- title: "Open Specy Package Tutorial" author: > - Win Cowger, Zacharias Steinmetz + Win Cowger, Zacharias Steinmetz, Rachel Kozloski, Aleksandra Karapetrova date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: >