Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
*.Rproj
*.ini
tests/*
R/my_custom_fun.R
R/my_custom_fun.R
8 changes: 5 additions & 3 deletions R/standartox.R
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ stx_query = function(
# Split up list object
total_entries = nrow(stxDb$test_fin)
tox.dt = stxDb$test_fin # final output object. LARGE right after import!
suppressWarnings( tox.dt[, casnr := NULL] ) # HOT FIX!
suppressWarnings( tox.dt[, cl_id := NULL] ) # HOT FIX!
stxDb = stxDb[stx_table[-1]] # dump the largest object! <- hope to save some memory with that.

# First quick filter steps:
Expand Down Expand Up @@ -410,9 +410,11 @@ stx_query = function(
if( nrow(stxDb$phch) == 0 ) {
warning("No query matches found for the provided CAS numbers. Please check the input values.")
}
merge(stxDb$phch, tox.dt, all.x = TRUE, by = "cl_id") -> tox.dt
#merge(stxDb$phch, tox.dt, all.x = TRUE, by = "cl_id") -> tox.dt
merge(stxDb$phch, tox.dt, all.x = TRUE, by = "casnr") -> tox.dt
} else {
merge(stxDb$phch, tox.dt, all.y = TRUE, by = "cl_id") -> tox.dt
#merge(stxDb$phch, tox.dt, all.y = TRUE, by = "cl_id") -> tox.dt
merge(stxDb$phch, tox.dt, all.y = TRUE, by = "casnr") -> tox.dt
}
suppressWarnings( tox.dt[, c("chem_class","casnr", "cl_id") := NULL] ) # don't need the cl_id column anymore.

Expand Down
33 changes: 7 additions & 26 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ Standartox is a database and tool facilitating the retrieval of ecotoxicological

## Installation

**_NOTE:_** Currently v0.0.2 is only available here on GitHub.

```{r eval=FALSE}
# install.packages('standartox') # Currently only available on GitHub
if (!requireNamespace("standartox", quietly = TRUE)) {
remotes::install_github('andschar/standartox') # development version
}
# install.packages('standartox') # CRAN Server version
remotes::install_github('andschar/standartox') # Github version
```

## Functions
Expand Down Expand Up @@ -81,33 +77,18 @@ We subset the retrieved data to the 20 most tested chemicals and plot the result
```{r warning=FALSE, message=FALSE}
cas20 = oncor[ , .N, cas ][ order(-N) ][1:20]
oncor20 = oncor[ cas %in% cas20$cas ]
# add new column which combines chem_name & cas
oncor20[ , chem_name := paste0(chem_name, ' [CAS: ', cas, ']') ]
gmn_dt = oncor20[ , .(gmn = exp(mean(log(concentration), na.rm = TRUE))), .(cas, chem_name, tax_genus)]
# add new column which combines common_name & cas
oncor20[ , new_chem_name := paste0(common_name, ' [CAS: ', cas, ']') ]
gmn_dt = oncor20[ , .(gmn = exp(mean(log(concentration), na.rm = TRUE))), .(cas, new_chem_name, tax_genus)]
```

```{r warning=FALSE, message=FALSE, fig.width=9, fig.height=6, dpi=300}
require(ggplot2)
# ggplot(oncor20, aes(y = cas)) +
# geom_point(aes(x = concentration, col = 'All values'),
# pch = 1, alpha = 0.3) +
# geom_point(data = gmn_dt,
# aes(y = reorder(cas, -gmn), 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 = 'LC50 values for Genus: Oncorhynchus',
# subtitle = '20 most tested chemicals',
# x = 'Concentration [g/L]') +
# theme_minimal() +
# theme(axis.title.y = element_blank())

ggplot(oncor20, aes(y = chem_name)) +
ggplot(oncor20, aes(y = new_chem_name)) +
geom_point(aes(x = concentration, col = 'All values'),
pch = 1, alpha = 0.3) +
geom_point(data = gmn_dt,
aes(y = reorder(chem_name, -gmn), x = gmn, col = 'Standartox value\n(Geometric mean)'),
aes(y = reorder(new_chem_name, -gmn), 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)) +
Expand Down
69 changes: 31 additions & 38 deletions README.html

Large diffs are not rendered by default.

68 changes: 29 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@ environmental toxicity of chemicals.

## Installation

***NOTE:*** Currently v0.0.2 is only available here on GitHub.

``` r
# install.packages('standartox') # Currently only available on GitHub
if (!requireNamespace("standartox", quietly = TRUE)) {
remotes::install_github('andschar/standartox') # development version
}
# install.packages('standartox') # CRAN Server version
remotes::install_github('andschar/standartox') # Github version
```

## Functions
Expand All @@ -48,16 +44,16 @@ catal = stx_catalog()
names(catal)
```

## [1] "date_compiled" "standartox_version" "cas" "chem_class"
## [5] "cname" "ref_author" "ref_number" "ref_title"
## [9] "ref_year" "class" "continent" "family"
## [13] "genus" "group" "habitat" "order"
## [17] "rank" "taxon" "casnr" "cl_id"
## [21] "concentration" "concentration_orig" "concentration_type" "concentration_unit"
## [25] "concentration_unit_orig" "duration" "duration_orig" "duration_unit"
## [29] "duration_unit_orig" "effect" "endpoint" "endpoint_group"
## [33] "exposure" "qualifier" "ref_number" "result_id"
## [37] "tl_id"
## [1] "cas" "casnr" "chem_class" "chem_name"
## [5] "ref_author" "ref_number" "ref_title" "ref_year"
## [9] "tax_class" "tax_continent" "tax_family" "tax_genus"
## [13] "tax_group" "tax_habitat" "tax_order" "tax_rank"
## [17] "tax_taxon" "casnr" "cl_id" "concentration"
## [21] "concentration_orig" "concentration_type" "concentration_unit" "concentration_unit_orig"
## [25] "duration" "duration_orig" "duration_unit" "duration_unit_orig"
## [29] "effect" "endpoint" "endpoint_group" "exposure"
## [33] "measurement" "organism_lifestage" "qualifier" "ref_number"
## [37] "result_id" "tl_id"

``` r
catal$endpoint # access the parameter top five endpoints
Expand All @@ -67,16 +63,16 @@ Showing the top 10 endpoint values from `stx_catalog()`

| n | variable |
|-------:|:---------|
| 202306 | NOEL |
| 191672 | NR |
| 162103 | LOEL |
| 152748 | NOEC |
| 135906 | LC50 |
| 113089 | LOEC |
| 53417 | EC50 |
| 22027 | BCF |
| 17337 | NR-LETH |
| 16179 | LD50 |
| 205080 | NOEL |
| 196597 | NR |
| 165693 | LOEL |
| 165146 | NOEC |
| 143740 | LC50 |
| 123889 | LOEC |
| 56362 | EC50 |
| 22496 | BCF |
| 17739 | NR-LETH |
| 16213 | LD50 |

### `stx_query()`

Expand All @@ -93,16 +89,13 @@ more detail.

## Reading in Standartox Data ...

## fstcore package v0.10.0

## (OpenMP detected, using 8 threads)

## Removing rows with 'NR' (not reported) for endpoint & duration_unit ...

## Appending chemical information ...

## Appending taxonomic information ...

## Query returned 801451 results out of 1212683 total entries.
## Done!

## Example: *Oncorhynchus*
Expand Down Expand Up @@ -138,6 +131,7 @@ oncor = stx_query(

## Appending taxonomic information ...

## Query returned 3178 results out of 1212683 total entries.
## Done!

We subset the retrieved data to the 20 most tested chemicals and plot
Expand All @@ -146,18 +140,18 @@ the result.
``` r
cas20 = oncor[ , .N, cas ][ order(-N) ][1:20]
oncor20 = oncor[ cas %in% cas20$cas ]
# add new column which combines cname & cas
oncor20[ , cname := paste0(cname, ' [CAS: ', cas, ']') ]
gmn_dt = oncor20[ , .(gmn = exp(mean(log(concentration), na.rm = TRUE))), .(cas, cname, tax_genus)]
# add new column which combines common_name & cas
oncor20[ , new_chem_name := paste0(common_name, ' [CAS: ', cas, ']') ]
gmn_dt = oncor20[ , .(gmn = exp(mean(log(concentration), na.rm = TRUE))), .(cas, new_chem_name, tax_genus)]
```

``` r
require(ggplot2)
ggplot(oncor20, aes(y = cname)) +
ggplot(oncor20, aes(y = new_chem_name)) +
geom_point(aes(x = concentration, col = 'All values'),
pch = 1, alpha = 0.3) +
geom_point(data = gmn_dt,
aes(y = reorder(cname, -gmn), x = gmn, col = 'Standartox value\n(Geometric mean)'),
aes(y = reorder(new_chem_name, -gmn), 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)) +
Expand All @@ -171,10 +165,6 @@ ggplot(oncor20, aes(y = cname)) +

![](README_files/figure-gfm/unnamed-chunk-8-1.png)<!-- -->

``` r
# Antimycin A (CAS 1397-94-0) listed as NA in standartox! Need to check this ...
```

## Article

The article on Standartox is published
Expand Down
Binary file removed README_files/figure-gfm/unnamed-chunk-12-1.png
Binary file not shown.
Binary file removed README_files/figure-gfm/unnamed-chunk-13-1.png
Binary file not shown.
Binary file modified README_files/figure-gfm/unnamed-chunk-8-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading