This repository has been archived by the owner on Jan 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
117 lines (85 loc) · 4.46 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
---
output: github_document
bibliography: vignettes/bibliography.bib
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = NULL
)
Sys.setlocale("LC_MESSAGES", 'en_GB.UTF-8') # Force locale
```
# alkahest <img width=120px src="man/figures/logo.png" align="right" />
<!-- badges: start -->
[![R-CMD-check](https://github.com/tesselle/alkahest/workflows/R-CMD-check/badge.svg)](https://github.com/tesselle/alkahest/actions)
[![codecov](https://codecov.io/gh/tesselle/alkahest/branch/main/graph/badge.svg?token=wsIkAQ0XFK)](https://app.codecov.io/gh/tesselle/alkahest)
[![CodeFactor](https://www.codefactor.io/repository/github/tesselle/alkahest/badge/main)](https://www.codefactor.io/repository/github/tesselle/alkahest/overview/main)
[![Dependencies](https://tinyverse.netlify.app/badge/alkahest)](https://cran.r-project.org/package=alkahest)
[![r-universe](https://tesselle.r-universe.dev/badges/alkahest)](https://tesselle.r-universe.dev){.pkgdown-devel}
[![CRAN Version](http://www.r-pkg.org/badges/version/alkahest)](https://cran.r-project.org/package=alkahest){.pkgdown-release}
[![CRAN checks](https://badges.cranchecks.info/worst/alkahest.svg)](https://cran.r-project.org/web/checks/check_results_alkahest.html){.pkgdown-release}
[![CRAN Downloads](http://cranlogs.r-pkg.org/badges/alkahest)](https://cran.r-project.org/package=alkahest){.pkgdown-release}
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7081524.svg)](https://doi.org/10.5281/zenodo.7081524)
<!-- badges: end -->
## Overview
**alkahest** is a lightweight, dependency-free toolbox for pre-processing XY data from experimental methods (i.e. any signal that can be measured along a continuous variable). It provides methods for baseline estimation and correction, smoothing, normalization, integration and peaks detection.
* Baseline estimation methods: Linear, Polynomial [@lieber2003], Asymmetric Least Squares [@eilers2005], Rolling Ball [@kneen1996], Rubberband, SNIP [@morhac1997; @morhac2008; @ryan1988], 4S Peak Filling [@liland2015].
* Smoothing methods: Rectangular, Triangular, Loess, Savitzky-Golay Filter [@gorry1990; @savitzky1964], Whittaker [@eilers2003], Penalized Likelihood [@derooi2014]
---
```{r citation, echo=FALSE, comment='', results='asis'}
cite <- utils::citation("alkahest")
print(cite, bibtex = FALSE)
```
## Installation
You can install the released version of **alkahest** from [CRAN](https://CRAN.R-project.org) with:
```{r cran-installation, eval=FALSE}
install.packages("alkahest")
```
And the development version from [GitHub](https://github.com/) with:
```{r gh-installation, eval=FALSE}
# install.packages("remotes")
remotes::install_github("tesselle/alkahest")
```
## Usage
```{r packages}
## Load the package
library(alkahest)
```
**alkahest** expects the input data to be in the simplest form (a two-column matrix or data frame, a two-element list or two numeric vectors).
```{r baseline}
## X-ray diffraction
data("XRD")
## 4S Peak Filling baseline
baseline <- baseline_peakfilling(XRD, n = 10, m = 5, by = 10, sparse = TRUE)
plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count")
lines(baseline, type = "l", col = "red")
```
```{r peaks}
## Correct baseline
XRD <- signal_drift(XRD, lag = baseline, subtract = TRUE)
## Find peaks
peaks <- peaks_find(XRD, SNR = 3, m = 11)
plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count")
lines(peaks, type = "p", pch = 16, col = "red")
```
```{r smooth, fig.width=5, fig.height=5, out.width='50%', fig.show='hold'}
## Simulate data
set.seed(12345)
x <- seq(-4, 4, length = 100)
y <- dnorm(x)
z <- y + rnorm(100, mean = 0, sd = 0.01) # Add some noise
## Plot raw data
plot(x, z, type = "l", xlab = "", ylab = "", main = "Raw data")
lines(x, y, type = "l", lty = 2, col = "red")
## Savitzky–Golay filter
smooth <- smooth_savitzky(x, z, m = 21, p = 2)
plot(smooth, type = "l", xlab = "", ylab = "", main = "Savitzky–Golay filter")
lines(x, y, type = "l", lty = 2, col = "red")
```
## Contributing
Please note that the **alkahest** project is released with a [Contributor Code of Conduct](https://www.tesselle.org/conduct.html). By contributing to this project, you agree to abide by its terms.
## References