-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
132 lines (85 loc) · 5.86 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
---
output:
github_document
bibliography: inst\\REFERENCES.bib
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
eval = TRUE
)
```
# irpeat <img src='man/figures/logo-hex.png' align="right" height="139" alt="logo" style="float:right; height:200px;" />
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
<!-- badges: end -->
## Overview
'irpeat' is an R package that contains simple functions to analyze infrared spectra of peat samples. Some functions may also work with organic matter samples in general.
Provided functions for analyzing infrared spectra of peat are:
1. Computation of several humification indices.
2. Klason lignin mass fraction (following @Hodgkins.2018 and @Teickner.2022a) (note that these models are not reliable for peat, see @Teickner.2022a).
3. Holocellulose mass fraction (following @Hodgkins.2018 and @Teickner.2022a) (note that these models are not reliable for peat, see @Teickner.2022a).
4. Peat electron accepting capacity (following @Teickner.2022).
5. Peat electron donating capacity (following @Teickner.2022).
### How to install
You can install 'irpeat' from GitHub using R via:
```{r installation, eval = FALSE}
remotes::install_github(repo = "henningte/irpeat")
```
'irpeat' relies on the R package ['ir'](https://github.com/henningte/ir) for handling infrared spectra.
### How to use
You can load 'irpeat' in R with:
```{r load_irpeat}
library(irpeat)
# load additional packages needed for this tutorial
library(ir)
library(ggplot2)
```
You can test 'irpeat' with sample data from the R package 'ir':
```{r ir_sample_data_load}
ir::ir_sample_data
```
`ir::ir_sample_data` contains various ATR-MIR spectra of organic reference material (e.g. newspaper, wood, grass).
A simple workflow could be, for example, to baseline correct the spectra (using functions of the package 'ir') compute various humification indices and Klason lignin and holocellulose mass fractions in the samples. We use only the first few spectra from `ir::ir_sample_data` to speed the computations a bit up.
```{r sample_data_workflow}
x <-
ir::ir_sample_data[1:10, ] %>% # data
ir::ir_bc(method = "rubberband") %>% # baseline correction
irpeat::irp_hi() %>% # humification indices
irpeat::irp_klason_lignin_2(do_summary = TRUE) # Klason lignin content
```
`x` is identical to `ir::ir_sample_data[1:10, ]`, but contains additional columns for the computed humification indices (`h1`, `h2`, `h3`, `h4`) and the computed Klason lignin content (`klason_lignin_2`)
```{r x_inspect}
x
```
Plot of the humification index (ratio of the intensities at 1420 and 1090 cm<sup>-1</sup> [@Broder.2012]) versus the Klason lignin content:
```{r x_plot}
ggplot2::ggplot(x, aes(x = quantities::drop_quantities(klason_lignin_2) * 100, y = hi1)) +
ggplot2::geom_point() +
ggplot2::labs(x = "Klason lignin content [mass-%]",
y = expression("Ratio of the intensities at"~1420~and~1090~cm^{-1}))
```
All computed quantities come with units and standard errors (thanks to the [quantities](https://github.com/r-quantities/quantities) package):
```{r x_klh_inspect_quantities}
x$klason_lignin_2
```
### Future development
Henning Teickner plans, as part of his PhD project, to extensively extent 'irpeat' by developing a set of calibration models that can predict various peat physicochemical properties from mid infrared spectra. These models should be finished by September 2024. Currently, a data compendium ([pmird](https://henningte.github.io/pmird/index.html)) is developed to collect the data required for this task.
### How to cite
Please cite this R package as:
> Henning Teickner, Suzanne B. Hodgkins (`r format(Sys.Date(), "%Y")`). _irpeat: Functions to Analyze Mid Infrared Spectra of Peat Samples_. Accessed `r format(Sys.Date(), "%Y-%m-%d")`. Online at <https://github.com/henningte/irpeat>.
### 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
The data and prediction models for holocellulose and Klason lignin (`irp_content_h_hodgkins_model`, `irp_content_kl_hodgkins_model`) are derived from @Hodgkins.2018 and were restructured 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 was originally derived from @LaCruz.2016.
Modified prediction models for holocellulose and Klason lignin (`model_holocellulose_2`, `model_klason_lignin_2`) are derived from @Teickner.2022a.
Data and models for the electrochemical accepting and donating capacities (EAC, EDC) of peat were derived from @Teickner.2022 and @Teickner.2021c
This packages was developed in R (`r R.Version()$version.string`) [@RCoreTeam.2019] using functions from devtools [@Wickham.2019], usethis [@Wickham.2019b], rrtools [@Marwick.2019] and roxygen2 [@Wickham.2019c].
### References