Skip to content

Commit

Permalink
Various bug fixes (#147)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
wincowgerDEV and zsteinmetz authored Oct 2, 2023
1 parent 8a3197b commit 5675be0
Show file tree
Hide file tree
Showing 18 changed files with 494 additions and 139 deletions.
6 changes: 3 additions & 3 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -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
16 changes: 12 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]",
comment = c(ORCID = "0000-0001-9226-3104")),
Expand All @@ -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")),
Expand All @@ -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 = "[email protected]",
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
Expand Down
13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/OpenSpecy-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions R/as_OpenSpecy.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand All @@ -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]
Expand Down Expand Up @@ -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)){
Expand All @@ -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)
}
Expand Down
Loading

0 comments on commit 5675be0

Please sign in to comment.