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
132 lines (95 loc) · 4.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: vignettes/bibliography.bib
nocite: '@*'
---
<!-- 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.setenv(LANGUAGE = "en") # Force locale
```
# nexus <img width=120px src="man/figures/logo.png" align="right" />
<!-- badges: start -->
[![R-CMD-check](https://github.com/tesselle/nexus/workflows/R-CMD-check/badge.svg)](https://github.com/tesselle/nexus/actions)
[![codecov](https://codecov.io/gh/tesselle/nexus/graph/badge.svg?token=3xtuBXPGiF)](https://app.codecov.io/gh/tesselle/nexus)
[![CodeFactor](https://www.codefactor.io/repository/github/tesselle/nexus/badge/main)](https://www.codefactor.io/repository/github/tesselle/nexus/overview/main)
[![Dependencies](https://tinyverse.netlify.app/badge/nexus)](https://cran.r-project.org/package=nexus)
[![r-universe](https://tesselle.r-universe.dev/badges/nexus)](https://tesselle.r-universe.dev/nexus){.pkgdown-devel}
[![CRAN Version](https://www.r-pkg.org/badges/version/nexus)](https://cran.r-project.org/package=nexus){.pkgdown-release}
[![CRAN checks](https://badges.cranchecks.info/worst/nexus.svg)](https://cran.r-project.org/web/checks/check_results_nexus.html){.pkgdown-release}
[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/nexus)](https://cran.r-project.org/package=nexus){.pkgdown-release}
[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10225630.svg)](https://doi.org/10.5281/zenodo.10225630)
<!-- badges: end -->
## Overview
This package is currently *experimental*. This means that it is functional, but interfaces and functionalities may change over time, testing and documentation may be lacking.
Exploration and analysis of compositional data in the framework of @aitchison1986. **nexus** provides tools for chemical fingerprinting and source tracking of ancient materials. This package provides methods for compositional data analysis:
* Compositional statistics.
* Compositional data visualization.
* Logratio transformations: `transform_lr()`, `transform_clr()`, `transform_alr()`, `transform_ilr()`, `transform_plr()`.
* Zero and missing value replacement.
* Outlier detection: `detect_outlier()`.
This package also includes methods for provenance studies:
* Multivariate analysis: `pca()`.
* Mixed-mode analysis using geochemical and petrographic data [@baxter2008]: `mix()`.
[**isopleuros**](https://packages.tesselle.org/isopleuros/) is a companion package to **nexus** that allows to create ternary plots.
---
```{r citation, echo=FALSE, comment='', results='asis'}
cite <- utils::citation("nexus")
print(cite, bibtex = FALSE)
```
## Installation
You can install the released version of **nexus** from [CRAN](https://CRAN.R-project.org) with:
```{r cran-installation, eval=FALSE}
install.packages("nexus")
```
And the development version from [GitHub](https://github.com/) with:
```{r gh-installation, eval=FALSE}
# install.packages("remotes")
remotes::install_github("tesselle/nexus")
```
## Usage
```{r packages}
## Install extra packages (if needed)
# install.packages("folio")
## Load the package
library(nexus)
```
**nexus** provides a set of S4 classes that represent different special types of matrix (see `vignette("nexus")`). The most basic class represents a compositional data matrix, i.e. quantitative (nonnegative) descriptions of the parts of some whole, carrying relative, rather than absolute, information [@aitchison1986].
*It assumes that you keep your data tidy*: each variable must be saved in its own column and each observation (sample) must be saved in its own row.
```{r groups}
## Data from Wood and Liu 2023
data("bronze", package = "folio")
## Coerce to compositional data
coda <- as_composition(bronze, parts = 4:11)
## Use dynasties as groups
coda <- group(coda, by = bronze$dynasty)
```
```{r barplot, fig.width=5, fig.height=7}
## Select major elements
major <- coda[, is_element_major(coda)]
## Compositional barplot
barplot(major, order_rows = "Cu", border = NA, space = 0)
```
```{r lra, fig.width=7, fig.height=7, out.width='50%', fig.show='hold'}
## Log-ratio analysis
## (PCA of centered log-ratio; outliers should be removed first)
clr <- transform_clr(coda, weights = TRUE)
lra <- pca(clr)
## Visualize results
viz_individuals(
x = lra,
extra_quali = group_names(clr),
color = c("#004488", "#DDAA33", "#BB5566"),
hull = TRUE
)
viz_variables(lra)
```
## Contributing
Please note that the **nexus** 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