ir

Tidy data structure for infrared spectra and functions to handle and preprocess them.

https://github.com/henningte/ir

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
    Links to: nature.com, zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.3%) to scientific vocabulary

Keywords

chemometrics infrared infrared-spectra ir-package mid-infrared-spectra r r-package rstats spectroscopy
Last synced: 9 months ago · JSON representation

Repository

Tidy data structure for infrared spectra and functions to handle and preprocess them.

Basic Info
Statistics
  • Stars: 8
  • Watchers: 2
  • Forks: 4
  • Open Issues: 0
  • Releases: 4
Topics
chemometrics infrared infrared-spectra ir-package mid-infrared-spectra r r-package rstats spectroscopy
Created over 6 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog Contributing License

README.Rmd

---
output: 
  github_document
bibliography: inst\\REFERENCES.bib
---



```{r, echo = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  eval = TRUE
)
```

# ir logo


[![DOI](https://zenodo.org/badge/234117897.svg)](https://zenodo.org/badge/latestdoi/234117897)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![CRAN status](https://www.r-pkg.org/badges/version/ir)](https://CRAN.R-project.org/package=ir)

  

## Overview

'ir' is an R package to import, handle and preprocess infrared spectra. Infrared spectra are stored as list columns in data frames which enables efficient storage of metadata along with the spectra and using 'tidyverse' functions for data operations.

**Spectra in the following formats can be imported:**

1. `csv` files with individual spectra.
2. Thermo Galactic's `spc` files with individual spectra.

**Functions for spectral preprocessing and data handling:**

1. baseline correction with:
    * a polynomial baseline
    * a convex hull baseline
    * a Savitzky-Golay baseline [@Lasch.2012]
2. binning
3. clipping
4. interpolating (resampling, linearly)
5. replacing selected parts of a spectrum by a straight line
6. averaging spectra within specified groups
7. normalizing spectra:
    * to the maximum intensity
    * to the intensity at a specific x value
    * so that all intensity values sum to 1
    * vector normalization
    * Standard Normal Variate correction
8. smoothing: 
    * Savitzky-Golay smoothing 
    * Fourier smoothing
9. computing derivatives of spectra using Savitzky-Golay smoothing
10. spectral arithmetic (addition, subtraction, multiplication, division)
11. computing the variance of intensity values (optionally after subtracting reference spectra)
12. computing maxima, minima, median, and ranges of intensity values of spectra
13. Atmospheric background correction [@Perez-Guaita.2013]
14. Scaling intensity values in spectra
15. Wrapper to sampling algorithms implemented in the 'prospectr' package. 
16. plotting
17. [tidyverse](https://www.tidyverse.org/) methods

### How to install

You can install 'ir' from CRAN:

```{r installation-cran, eval = FALSE}
install.packages("ir")
```


You can install the development version of 'ir' from GitHub:

```{r installation-github, eval = FALSE}
remotes::install_github(repo = "henningte/ir", ref = "dev")
```

### How to use

Load 'ir':

```{r load_ir, warning=FALSE}
# load ir package
library(ir)

# load additional packages needed for this tutorial
library(ggplot2)
```

For brief introductions, see below and the two vignettes:

1. [`r rmarkdown::yaml_front_matter("vignettes/ir-introduction.Rmd")$title`](https://henningte.github.io/ir/articles/ir-introduction.html)
2. [`r rmarkdown::yaml_front_matter("vignettes/ir-class.Rmd")$title`](https://henningte.github.io/ir/articles/ir-class.html)

#### Sample workflow

Here is an example preprocessing pipeline for the sample data in the package (`ir_sample_data`) which does baseline correction, binning (bin width of 10), normalization (so that the maximum intensity value is 1 and the minimum intensity value is 0), and finally plots the preprocessed spectra for each sample and sample type:

```{r sample_data_workflow}
ir_sample_data |>                                      # data
  ir::ir_bc(method = "rubberband") |>                  # baseline correction
  ir::ir_bin(width = 10) |>                            # binning
  ir::ir_normalize(method = "zeroone") |>              # normalization
  plot() + ggplot2::facet_wrap(~ sample_type)          # plot
```

#### Data structure

You can load the sample data with:

```{r ir_sample_data_load}
ir::ir_sample_data
```

`ir_sample_data` is an object of class `ir`. An Object of class `ir` is a data frame where each row represents one infrared measurement and column `spectra` contains the infrared spectra (one per row) as list column. This allows to store metadata along each spectrum (for example the N content for each sample) and to manipulate `ir` objects with 'tidyverse' functions.

The column `spectra` is a list column of data frames, meaning that each cell of `spectra` contains a data frame which contains the data for one spectrum. For example, here are the first rows of the first spectrum in `ir_smaple_data`:

```{r ir_sample_data_inspect_spectra}
# View the first ten rows of the first spectrum in ir_sample_data
head(ir_sample_data$spectra[[1]])
```

Column `x` contains values for the spectral channel (in this case wavenumbers [cm-1]) and column `y` the corresponding intensity values.

### How to cite

Please cite this R package as:

> Henning Teickner (`r format(Sys.Date(), "%Y")`). _ir: Functions to Handle and Preprocess Infrared Spectra_. DOI: 10.5281/zenodo.5747169. Accessed `r format(Sys.Date(), "%d %b %Y")`. Online at .


### Companion packages

The [irpeat](https://github.com/henningte/irpeat/) package provides functions to analyze infrared spectra of peat (humification indices, prediction models) and uses the 'ir' package to handle spectral data.

### Licenses

**Text and figures :**  [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

**Code :** See the [DESCRIPTION](DESCRIPTION) file

**Data :** [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) attribution requested in reuse. See the sources section for data sources and how to give credit to the original author(s) and the source.

### Contributions

We welcome contributions from everyone. Before you get started, please see our [contributor guidelines](CONTRIBUTING.md). Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.

### Sources

`ir_sample_data` is derived from @Hodgkins.2018 and was reformatted to match the requirements of 'ir'. The original article containing the data can be downloaded from https://www.nature.com/articles/s41467-018-06050-2 and is distributed under the Creative Commons Attribution 4.0 International License (https://creativecommons.org/licenses/by/4.0/). The data on Klason lignin and holocellulose content are originally from @DelaCruz.2016.

### References

Owner

  • Name: Henning Teickner
  • Login: henningte
  • Kind: user
  • Location: Germany
  • Company: Biogeochemistry and Ecohydrology Group, Institue for Landscape Ecology, University of Münster

GitHub Events

Total
  • Release event: 1
  • Watch event: 3
  • Push event: 14
  • Fork event: 1
  • Create event: 1
Last Year
  • Release event: 1
  • Watch event: 3
  • Push event: 14
  • Fork event: 1
  • Create event: 1

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 119
  • Total Committers: 1
  • Avg Commits per committer: 119.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
henningte 3****e 119

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 2
  • Total pull requests: 0
  • Average time to close issues: 11 days
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • henningte (2)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 296 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 3
  • Total maintainers: 1
cran.r-project.org: ir

Functions to Handle and Preprocess Infrared Spectra

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 296 Last month
Rankings
Forks count: 12.2%
Stargazers count: 21.9%
Dependent repos count: 23.8%
Dependent packages count: 28.6%
Average: 32.7%
Downloads: 77.0%
Last synced: 10 months ago

Dependencies

DESCRIPTION cran
  • R >= 4.0.0 depends
  • ChemoSpec >= 5.2.12 imports
  • Rdpack * imports
  • baseline * imports
  • dplyr * imports
  • ggplot2 * imports
  • grDevices * imports
  • hyperSpec >= 0.99.20200527 imports
  • lifecycle * imports
  • magrittr * imports
  • methods * imports
  • purrr * imports
  • quantities * imports
  • rlang * imports
  • signal * imports
  • stats * imports
  • stringr * imports
  • tibble * imports
  • tidyr * imports
  • units * imports
  • fda * suggests
  • kableExtra * suggests
  • knitr * suggests
  • rmarkdown * suggests
  • spelling * suggests
  • tidyselect * suggests
  • vctrs * suggests
.github/workflows/pkgdown.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
  • r-lib/actions/setup-r-dependencies v1 composite