Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bcgov/wqbench

R package to generate download and compile data from EPA ECOTOX database
https://github.com/bcgov/wqbench

Last synced: about 1 month ago
JSON representation

R package to generate download and compile data from EPA ECOTOX database

Awesome Lists containing this project

README

        

---
output: github_document
---

# wqbench

[![img](https://img.shields.io/badge/Lifecycle-Experimental-339999)](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md)
[![R-CMD-check](https://github.com/bcgov/wqbench/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/bcgov/wqbench/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/bcgov/wqbench/branch/main/graph/badge.svg)](https://app.codecov.io/gh/bcgov/wqbench?branch=main)

This package contains the functions and tools to generate aquatic life water quality benchmarks.

## Installation

```{r, eval=FALSE}
# install.packages("devtools")
devtools::install_github("bcgov/wqbench")
```

## Workflow

```{r}
library(wqbench)
```

### Create Data Set for App

The `wqb_create_data_set()` function will download the US EPA ECOTOX1 database, create a local .sqlite database, add other data sources and filter conditions, clean and process the data, classify the duration, standardize the effect and output the completed data set needed for the shinywqbench app.
The function will create an RDS file of the data set as well.
It takes a few minutes to download and create the data set.

The default argument for:

- `file_path` will save the raw text files at `"~/Ecotoxicology/ecotox"`.
- `folder_path` will save the .sqlite database and RDS file is at `"~/Ecotoxicology/ecotox_db/"`.
- `version` will download the most recent version of the data set available on the website.

```{r, eval=FALSE}
data_set <- wqb_create_data_set()
```

The data set can be read in after it has been created.

```{r, eval=FALSE}
data_set <- readRDS("~/Ecotoxicology/ecotox_db/ecotox_ascii_03_15_2023.rds")
```

### Generate Benchmark

```{r}
set.seed(101)
```

#### Deterministic Example

```{r}
data <- wqb_filter_chemical(wqbenchdata::aquatic_data, "100016")
data <- wqb_benchmark_method(data)

data_agg <- wqb_aggregate(data)
data_agg <- wqb_af(data_agg)

ctv <- wqb_generate_ctv(data_agg)
ctv
```

To calculate the benchmark for the chemical, divide the critical toxicity value (ctv) by the assessment factors.

```{r}
benchmark <- ctv / (data_agg$af_bc_species * data_agg$af_salmon * data_agg$af_planktonic * data_agg$af_variation)
benchmark
```

*Deterministic* method only generates an estimate, the lcl and ucl columns will always be blank .

```{r}
# Plot data set
wqb_plot(data)
```

```{r, fig.width=14}
# Plot the results
wqb_plot_det(data_agg)
```

#### SSD Example

```{r}
data <- wqb_filter_chemical(wqbenchdata::aquatic_data, "1071836")
data <- wqb_benchmark_method(data)

data_agg <- wqb_aggregate(data)
data_agg <- wqb_af(data_agg)

ctv <- wqb_generate_ctv(data_agg)
ctv
```

To calculate the benchmark for the chemical, divide the critical toxicity value (ctv) by the assessment factors.

```{r}
benchmark <- ctv / (data_agg$af_bc_species * data_agg$af_salmon * data_agg$af_planktonic * data_agg$af_variation)
benchmark
```

*SSD* method can generate a lower and upper confidence interval.

```{r, fig.height=10, fig.width=12}
# Plot data set
wqb_plot(data)
```

```{r}
# Plot the results
fit <- wqb_ssd_fit(data_agg)
wqb_plot_ssd(data_agg, fit)
```

#### Summary Tables

```{r}
wqb_summary_trophic_species(data_agg)
wqb_summary_trophic_groups(data_agg)
wqb_summary_af(data_agg)
```

## Getting Help or Reporting an Issue

To report issues, bugs or enhancements, please file an [issue](https://github.com/bcgov/wqbench/issues).
Check out the [support](https://github.com/bcgov/wqbench/blob/main/.github/SUPPORT.md) for more info.

## Code of Conduct

Please note that the shinywqbench project is released with a [Contributor Code of Conduct](https://github.com/bcgov/wqbench/CODE_OF_CONDUCT.md).
By contributing to this project, you agree to abide by its terms.

## License

The code is released under the Apache License 2.0

> Copyright 2023 Province of British Columbia
>
> Licensed under the Apache License, Version 2.0 (the "License");
> you may not use this file except in compliance with the License.
> You may obtain a copy of the License at
>
> https://www.apache.org/licenses/LICENSE-2.0
>
> Unless required by applicable law or agreed to in writing, software
> distributed under the License is distributed on an "AS IS" BASIS,
> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> See the License for the specific language governing permissions and
> limitations under the License.

## Reference

1. Olker, J. H., Elonen, C. M., Pilli, A., Anderson, A., Kinziger, B., Erickson, S., Skopinski, M., Pomplun, A., LaLone, C. A., Russom, C. L., & Hoff, D. (2022). The ECOTOXicology Knowledgebase: A Curated Database of Ecologically Relevant Toxicity Tests to Support Environmental Research and Risk Assessment. Environmental Toxicology and Chemistry, 41(6):1520-1539. https://doi.org/10.1002/etc.5324