Learn R Programming

Open Specy 1.0

Analyze, Process, Identify, and Share Raman and (FT)IR Spectra

Raman and (FT)IR spectral analysis tool for plastic particles and other environmental samples (Cowger et al. 2021, doi: 10.1021/acs.analchem.1c00123). With read_any(), Open Specy provides a single function for reading individual, batch, or map spectral data files like .asp, .csv, .jdx, .spc, .spa, .0, and .zip. process_spec() simplifies processing spectra, including smoothing, baseline correction, range restriction and flattening, intensity conversions, wavenumber alignment, and min-max normalization. Spectra can be identified in batch using an onboard reference library (Cowger et al. 2020, doi: 10.1177/0003702820929064) using match_spec(). A Shiny app is available via run_app() or online at https://www.openanalysis.org/openspecy/.

Installation

OpenSpecy is available from CRAN and GitHub.

Install from CRAN (stable version)

You can install the latest release of OpenSpecy from CRAN with:

install.packages("OpenSpecy")

Install from GitHub (development version)

To install the development version of this package, paste the following code into your R console (requires devtools):

if (!require(devtools)) install.packages("devtools")
devtools::install_github("wincowgerDEV/OpenSpecy-package")

Install on Web Assemply through webr (experimental), you can test here: https://webr.r-wasm.org/latest/

library(caTools)
library(data.table)
library(jsonlite)
library(yaml)
library(hyperSpec)
library(mmand)
library(plotly)
library(digest)
library(signal)
library(glmnet)
library(jpeg)
library(shiny)
webr::install("OpenSpecy", repos = "https://wincowger.com/OpenSpecy-package/")
library(OpenSpecy)

Getting started

library(OpenSpecy)
run_app()

Simple workflow for single spectral identification

See package vignette for a detailed standard operating procedure.

# Fetch current spectral library from https://osf.io/x7dpz/
get_lib("derivative")

# Load library into global environment
spec_lib <- load_lib("derivative")

# Read sample spectrum
raman_hdpe <- read_extdata("raman_hdpe.csv") |> 
  read_any()

# Look at the spectrum
plotly_spec(raman_hdpe)

# Process the spectra and conform it to the library format
raman_proc <- raman_hdpe |>
  process_spec(conform_spec_args = list(range = spec_lib$wavenumbers), 
               smooth_intens = T, make_rel = T)

# Compare raw and processed spectra
plotly_spec(raman_hdpe, raman_proc)

top_matches <- match_spec(raman_proc, library = spec_lib, na.rm = T, top_n = 5,
                          add_library_metadata = "sample_name",
                          add_object_metadata = "col_id")

# Print the top 5 results with relevant metadata
top_matches[, c("object_id", "library_id", "match_val", "SpectrumType",
                "SpectrumIdentity")]

# Get all metadata for the matches
get_metadata(spec_lib, logic = top_matches$library_id)

Citations

Cowger W, Steinmetz Z, Gray A, Munno K, Lynch J, Hapich H, Primpke S, De Frond H, Rochman C, Herodotou O (2021). “Microplastic Spectral Classification Needs an Open Source Community: Open Specy to the Rescue!” Analytical Chemistry, 93(21), 7543–7548. doi: 10.1021/acs.analchem.1c00123.

Cowger W, Steinmetz Z, Leong N, Faltynkova A, Sherrod H (2024). “OpenSpecy: Analyze, Process, Identify, and Share Raman and (FT)IR Spectra.” R package, 1.0.8. https://github.com/wincowgerDEV/OpenSpecy-package.

Copy Link

Version

Install

install.packages('OpenSpecy')

Monthly Downloads

387

Version

1.5.3

License

CC BY 4.0

Issues

Pull Requests

Stars

Forks

Maintainer

Win Cowger

Last Published

April 26th, 2025

Functions in OpenSpecy (1.5.3)

plotly_spec

Interactive plots for OpenSpecy objects
write_spec

Read and write spectral data
raman_hdpe

Sample Raman spectrum
make_rel

Make spectral intensities relative
cor_spec

Identify and filter spectra
c_spec

Manage spectral objects
check_lib

Manage spectral libraries
manage_na

Ignore or remove NA intensities
read_envi

Read ENVI data
read_text

Read spectral data
read_opus

Read spectral data from Bruker OPUS binary files
process_spec

Process Spectra
smooth_intens

Smooth spectral intensities
split_spec

Split Open Specy objects
sig_noise

Calculate signal and noise metrics for OpenSpecy objects
read_any

Read spectral data from multiple files
run_app

Run Open Specy app
spec_res

Spectral resolution
spatial_smooth

Spatial Smoothing of OpenSpecy Objects
read_opus_raw

Read a Bruker OPUS spectrum binary raw string
test_lib

Test reference library
subtr_baseline

Automated background subtraction for spectral data
human_ts

Create human readable timestamps
restrict_range

Range restriction and flattening for spectra
adj_intens

Adjust spectral intensities to standard absorbance units.
head.OpenSpecy

Generic Open Specy Methods
adj_res

Normalization and conversion of spectral data
as_OpenSpecy

Create OpenSpecy objects
conform_spec

Conform spectra to a standard wavenumber series
adj_wave

Adjust wavelength to wavenumbers for Raman
OpenSpecy-package

OpenSpecy: Analyze, Process, Identify, and Share Raman and (FT)IR Spectra
collapse_spec

Define features