Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andschar/standartox
Standardising toxicity data
https://github.com/andschar/standartox
api ecotoxicology r
Last synced: 21 days ago
JSON representation
Standardising toxicity data
- Host: GitHub
- URL: https://github.com/andschar/standartox
- Owner: andschar
- License: other
- Created: 2019-08-03T13:48:56.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-11-21T16:39:53.000Z (about 2 years ago)
- Last Synced: 2024-04-25T18:42:45.759Z (8 months ago)
- Topics: api, ecotoxicology, r
- Language: R
- Homepage: https://andschar.github.io/standartox
- Size: 4.18 MB
- Stars: 13
- Watchers: 4
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.Rmd
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
---
title: "Standartox"
output: rmarkdown::github_document
editor_options:
chunk_output_type: console
---[![CRAN](https://www.r-pkg.org/badges/version/standartox)](https://CRAN.R-project.org/package=standartox)
[![Downloads](https://cranlogs.r-pkg.org/badges/standartox)](https://cran.r-project.org/package=standartox)Standartox is a database and tool facilitating the retrieval of ecotoxicological test data. It is based on the [EPA ECOTOX database](https://cfpub.epa.gov/ecotox/) as well as on data from several other chemical databases and allows users to filter and aggregate ecotoxicological test data in an easy way. It can either be accessed via or this R-package [standartox](https://github.com/andschar/standartox). Ecotoxicological test data is used in environmental risk assessment to calculate effect measures such as [TU - Toxic Units](https://en.wikipedia.org/wiki/Toxic_unit) or [SSD - Species Sensitivity Distributions](https://edild.github.io/ssd/) to asses environmental toxicity of chemicals.
The project lives in two repositories:
- [standartox-build](https://github.com/andschar/standartox-build) - Compiles and serves database
- [standartox](https://github.com/andschar/standartox) - R-package## Installation
```{r eval=FALSE}
install.packages('standartox')
# remotes::install_github('andschar/standartox') # development version
```## Functions
Standartox consists of the two functions `stx_catalog()` and `stx_query()`. The former allows you to retrieve a catalog of possible parameters that can be used as an input for `stx_query()`. The latter fetches toxicity values from the database.
### `stx_catalog()`
The function returns a list of all possible arguments that can bes use in `stx_query()`.
```{r message=FALSE}
require(standartox)
catal = stx_catalog()
names(catal)
``````{r eval=FALSE}
catal$endpoint # access the parameter endpoint
``````{r echo=FALSE}
endpoint = catal$endpoint
knitr::kable(endpoint)
```### `stx_query()`
The function allows you to retrieve filtered and aggregated toxicity data according to the parameters below.
```{r echo=FALSE}
df = data.frame(parameter = names(catal),
example = sapply(lapply(lapply(lapply(catal, `[[`, 1), head, 3), na.omit),
paste0, collapse = ', '),
row.names = NULL,
stringsAsFactors = FALSE)
df[ df$parameter == 'duration', ]$example = paste(24, 96, sep = ', ')
df = df[ df$parameter != 'meta', ]
knitr::kable(df)
```You can type in parameters manually or subset the object returned by `stx_catalog()`:
```{r}
require(standartox)
cas = c(Copper2Sulfate = '7758-98-7',
Permethrin = '52645-53-1',
Imidacloprid = '138261-41-3')
# query
l = stx_query(cas = cas,
endpoint = 'XX50',
taxa = grep('Oncorhynchus', catal$taxa$variable, value = TRUE), # fish genus
exposure = 'aquatic',
duration = c(24, 120))
```#### Important parameter settings
- __CAS__ (`cas =`) Can be input in the form of 7758-98-7 or 7758987
- __Endpoints__ (`endpoint =`) Only one endpoint per query is allowed:
- `NOEX` summarises [No observed effect concentration/level](https://en.wikipedia.org/wiki/No-observed-adverse-effect_level) (i.e. NOEC, NOEL, NOAEL, etc.)
- `LOEX` summarises Lowest observed effects concentration (i.e. LOEC, LOEL, etc.)
- `XX50` summarises [Half maximal effective concentration](https://en.wikipedia.org/wiki/EC50) (i.e. EC50, LC50, LD50, etc.)
- If you leave a parameter empty Standartox will not filter for it## Query result
Standartox returns a list object with five entries.
- `l$filtred` and `l$filtered_all` contain the filtered Standartox data set (the former only is a shorter and more concise version of the latter):
```{r echo=FALSE}
cols = c('cas', 'cname', 'concentration', 'concentration_unit', 'effect', 'endpoint')
knitr::kable(l$filtered[1:3, .SD, .SDcols = cols ])
```- `l$aggregated` contains the several aggregates of the Standartox data:
- `cname`, `cas` - chemical identifiers
- `min` - Minimum
- `tax_min` - Most sensitive taxon
- __`gmn`__ - __Geometric mean__
- `amn` - Arithmetic mean
- `sd` - Standard Deviation of the arithmetic mean
- `max` - Maximum
- `tax_max` - Most insensitive taxon
- `n` - Number of distinct taxa used for the aggregation
- `tax_all` - Concatenated string of all taxa used for the aggregation
```{r echo=FALSE}
knitr::kable(head(l$aggregated[ , .SD, .SDcols = c('cname', 'cas', 'min', 'tax_min', 'gmn', 'max')], 3))
```- `l$meta` contains meta information on the request:
```{r echo=FALSE}
knitr::kable(l$meta)
```## Example: _Oncorhynchus_
Let's say, we want to retrieve the 20 most tested chemicals on the genus _[Oncorhynchus](https://en.wikipedia.org/wiki/Oncorhynchus)_. We allow for test durations between 48 and 120 hours and want the tests restricted to active ingredients only. Since we are only interested in the half maximal effective concentration, we choose XX50 as our endpoint. As an aggregation method we choose the geometric mean.
```{r warning=FALSE}
require(standartox)
l2 = stx_query(concentration_type = 'active ingredient',
endpoint = 'XX50',
taxa = grep('Oncorhynchus', catal$taxa$variable, value = TRUE), # fish genus
duration = c(48, 120))
```We subset the retrieved data to the 20 most tested chemicals and plot the result.
```{r warning=FALSE, message=FALSE}
require(data.table)
dat = merge(l2$filtered, l2$aggregated, by = c('cas', 'cname'))
cas20 = l2$aggregated[ order(-n), cas ][1:20]
dat = dat[ cas %in% cas20 ]
``````{r warning=FALSE, message=FALSE, fig.width=9, fig.height=6, dpi=300}
require(ggplot2)
ggplot(dat, aes(y = reorder(cname, -gmn))) +
geom_point(aes(x = concentration, col = 'All values'),
pch = 1, alpha = 0.3) +
geom_point(aes(x = gmn, col = 'Standartox value\n(Geometric mean)'),
size = 3) +
scale_x_log10(breaks = c(0.01, 0.1, 1, 10, 100, 1000, 10000),
labels = c(0.01, 0.1, 1, 10, 100, 1000, 10000)) +
scale_color_viridis_d(name = '') +
labs(title = 'Oncorhynchus EC50 values',
subtitle = '20 most tested chemicals',
x = 'Concentration (ppb)') +
theme_minimal() +
theme(axis.title.y = element_blank())
```## Usage
We ask you to use the API service thoughtfully, which means to run the `stx_query()` only once and to re-run it only when parameters change or you want to query new versions. Here is an example of how to easily store the queried data locally from within R.
```{r eval=FALSE}
run = FALSE # set to TRUE for the first run
if (run) {
l2 = stx_query(concentration_type = 'active ingredient',
endpoint = 'XX50',
taxa = grep('Oncorhynchus', catal$taxa$variable, value = TRUE), # fish genus
duration = c(48, 120))
saveRDS(l2, file.path('path/to/directory', 'data.rds'))
} else {
l2 = readRDS(file.path('path/to/directory', 'data.rds'))
}# put rest of the script here
# ...
```## Article
The article on Standartox is published [here](https://www.mdpi.com/2306-5729/5/2/46).
## Information
### Contributors
- [Andreas Scharmüller](https://andschar.github.io)
### Want to contribute?Check out our [contribution guide here](https://github.com/andschar/standartox/blob/master/CONTRIBUTING.md).
### Meta
- Please report any [issues, bugs or feature requests](https://github.com/andschar/standartox/issues)
- License: MIT
- Get citation information for the standartox package in R doing `citation(package = 'standartox')`