A curated list of open technology projects to sustain a stable climate, energy supply, biodiversity and natural resources.

wqbench

Generate download and compile data from EPA ECOTOX database to generate aquatic life water quality benchmarks.
https://github.com/bcgov/wqbench

Category: Natural Resources
Sub Category: Water Supply and Quality

Keywords from Contributors

species-sensitivity-distribution ssd water-quality-guideline geo

Last synced: about 18 hours ago
JSON representation

Repository metadata

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

README.Rmd

          ---
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 Shiny 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_09_12_2024.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)
```

## Developer Instructions

See the [Developer Instructions](https://bcgov.github.io/wqbench/articles/Developer-instructions.html) on the package website for
instructions on updating the reference data for the database and updating the "Add Data" template

See the [README in the shinywqbench repository](https://github.com/bcgov/shinywqbench?tab=readme-ov-file#shinywqbench) for instructions for updating
and deploying the [shiny app](https://bcgov-env.shinyapps.io/shinywqbench/).

## 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

        

Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 8 days ago

Total Commits: 603
Total Committers: 4
Avg Commits per committer: 150.75
Development Distribution Score (DDS): 0.114

Commits in past year: 77
Committers in past year: 2
Avg Commits per committer in past year: 38.5
Development Distribution Score (DDS) in past year: 0.221

Name Email Commits
Ayla Pearson a****a@p****a 534
Andy Teucher a****r@g****m 60
Joe Thorley j****e@p****a 7
repo-mountie[bot] 4****] 2

Committer domains:


Issue and Pull Request metadata

Last synced: 2 days ago

Total issues: 46
Total pull requests: 17
Average time to close issues: about 1 month
Average time to close pull requests: 6 days
Total issue authors: 2
Total pull request authors: 3
Average comments per issue: 1.24
Average comments per pull request: 0.24
Merged pull request: 14
Bot issues: 0
Bot pull requests: 1

Past year issues: 1
Past year pull requests: 12
Past year average time to close issues: 20 days
Past year average time to close pull requests: 6 days
Past year issue authors: 1
Past year pull request authors: 2
Past year average comments per issue: 0.0
Past year average comments per pull request: 0.25
Past year merged pull request: 9
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/bcgov/wqbench

Top Issue Authors

  • aylapear (45)
  • ateucher (1)

Top Pull Request Authors

  • aylapear (11)
  • ateucher (5)
  • repo-mountie[bot] (1)

Top Issue Labels

  • Priority: 1 Critical (3)
  • Type: Enhancement (3)
  • Type: Testing (2)
  • Priority: 5 Don't Do! (2)
  • Difficulty: 1 Simple (1)
  • Effort: 1 Low (1)
  • Next Release (1)
  • Priority: 4 Low (1)

Top Pull Request Labels


Dependencies

.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION cran
  • DBI * imports
  • RSQLite * imports
  • chk * imports
  • dplyr * imports
  • ggplot2 * imports
  • httr * imports
  • readr * imports
  • rlang * imports
  • rvest * imports
  • scales * imports
  • ssdtools * imports
  • stringr * imports
  • tibble * imports
  • tidyr * imports
  • utils * imports
  • withr * imports
  • covr * suggests
  • testthat >= 3.0.0 suggests
  • wqbenchdata * suggests
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.4.1 composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite

Score: 2.772588722239781