forked from MartinSchobben/pointapply
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
144 lines (103 loc) · 5.53 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
133
134
135
136
137
138
139
140
141
142
143
144
---
output: github_document
bibliography: ["vignettes/packages.bib"]
biblio-style: apalike
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
out.width = "100%"
)
```
```{r pkgs, include=FALSE, message=FALSE, eval=FALSE}
# Required packages
pkgs <- c(
# tidy data manipulation
"purrr", "dplyr", "tibble", "tidyr", "stringr", "magrittr",
# plots
"ggplot2", "scales", "ggrepel", "RColorBrewer",
# package dev
"devtools", "roxygen2", "rlang", "fs", "testthat", "vdiffr", "cpp11",
# documentation and paper
"knitr", "rmarkdown", "bookdown", "rticles", "kableExtra", "bibtex", "pkgdown",
# reading and downloading data
"readmat", "R.matlab", "zen4R",
# statistics
"point", "MASS", "nortest"
)
knitr::write_bib(pkgs, fs::path("vignettes", "packages.bib"), prefix = "")
fs::file_copy(
fs::path("inst/paper/preprint/SIMS_method.bib"),
fs::path("vignettes", "SIMS_method.bib"),
overwrite = TRUE
)
hadley <- bibentry(
key = "Wickham2015",
bibtype = "Book",
title = "R packages: organize, test, document, and share your code",
author = person("Hadley","Wickham"),
year = "2015",
publisher = " O'Reilly Media, Inc.",
url = "https://r-pkgs.org/"
)
# Get the R reference
rref <- citation()
# Create ref key
rref$key <- "rversion"
# Write the R reference
pkgs <- bibtex::read.bib("vignettes/packages.bib")
bibtex::write.bib(
purrr::reduce(list(rref, hadley, pkgs), append),
file = fs::path("vignettes", "packages.bib")
)
```
# pointapply
<!-- badges: start -->
[![R-CMD-check](https://github.com/MartinSchobben/pointapply/workflows/R-CMD-check/badge.svg)](https://github.com/MartinSchobben/pointapply/actions)
[![Codecov test coverage](https://codecov.io/gh/MartinSchobben/pointapply/branch/master/graph/badge.svg)](https://app.codecov.io/gh/MartinSchobben/pointapply?branch=master)
[![DOI](https://zenodo.org/badge/340077309.svg)](https://zenodo.org/badge/latestdoi/340077309)
<!-- badges: end -->
The R package *pointapply* contains the code and data to reconstruct the publication: Martin Schobben, Michiel Kienhuis, and Lubos Polerecky. 2021. *New methods to detect isotopic heterogeneity with Secondary Ion Mass Spectrometry*, preprint on [Eartharxiv](https://eartharxiv.org/).
This paper assesses the performance of the application of the `diag_R()` function of the sister package *point* [@point] in detecting isotope heterogeneity in natural substrates.
# Data
The data is stored on the [Zenodo](https://doi.org/10.5281/zenodo.4580159) repository *pointdata*.
The data can be directly downloaded with `download_point()`, which is build around *zen4R* [@zen4R].
``` r
# Download
download_point()
```
# Render the paper
Use the function `render_paper()` and specify the directory to save the paper. Make sure to have latex installed on your system. Check e.g., https://yihui.org/tinytex/ for a light weight LaTeX version.
``` r
# install.packages('tinytex')
# Knit
render_paper(title = "Schobbenetal_SIMS_method", output_dir = "mydir")
```
## Credits
The construction of the R [@rversion] package *pointapply* and associated documentation was aided by the packages; *devtools* [@devtools], *roxygen2* [@roxygen2], *testthat* [@testthat], *vdiffr* [@vdiffr], *cpp11* [@cpp11], and *fs* [@fs].
The book: *R packages: organize, test, document, and share your code*, by @Wickham2015 is a great guide for learning how to build packages.
In addition, this package relies on a set of external packages from the tidyverse universe, including: *dplyr* [@dplyr], *tidyr* [@tidyr], *tibble* [@tibble], *stringr* [@stringr], *magrittr* [@magrittr], and *purrr* [@purrr] for data manipulation.
Data plots are constructed with *ggplot2* [@ggplot2; @ggplot22016], *ggrepel* [@ggrepel], *RColorBrewer* [@RColorBrewer], and *scales* [@scales]
The package *rlang* [@rlang] was used for tidy evaluation.
Some specialised packages where used, notably; *readmat* for loading the matlab LANS files [@readmat] and *MASS* [@MASS; @MASS2002] for 2D density estimates.
The data download from Zenodo with an api is facilitated by *zen4R* [@zen4R].
The documentation and paper was written with *knitr* [@knitr; @knitr2014; @knitr2015], *rmarkdown* [@rmarkdown; @rmarkdown2018; @rmarkdown2020], *bookdown* [@bookdown; @bookdown2016], *pkgdown* [@pkgdown], *rticles* [@rticles] and *bibtex* [@bibtex].
## Installation
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("MartinSchobben/pointapply", build_vignettes = TRUE)
```
## Reconstruct the paper from scratch
The data figures can be constructed with the functions contain in this package. The following vignettes detail all these operations in a coherent story line.
**Data:**
* Synthetic data for validation of model performance and Figure 2 and 3 and Supplementary Figure 1 (`vignette("simulation")`).
* Real data reading and processing and Supplementary Figure 2 (`vignette("data")`).
Because of the excessive file-sizes of ion count data, the data is stored externally on [Zenodo](https://doi.org/10.5281/zenodo.4564170), and can be accessed with the function `download_point()`.
**Figures:**
* Evaluation of model performance; Figures 4 and 5 (`vignette("performance")`).
* Raster images and scatter plots of real SIMS ^13^C/^12^C analyses; Figures 6--8 and Supplementary Figures 7 and 8 (`vignette("raster")`).
* Regression diagnostics; Supplementary Figures 3--5 (`vignette("regression")`).
* Accuracy of SIMS isotope analysis; Supplementary Figures 3 and 7 (`vignette("accuracy")`).
# References