Skip to content

Commit

Permalink
Merge pull request #406 from ldecicco-USGS/main
Browse files Browse the repository at this point in the history
Getting ready for minor CRAN update
  • Loading branch information
ldecicco-USGS committed Jan 29, 2024
2 parents 27eb744 + 808306b commit eceacc5
Show file tree
Hide file tree
Showing 37 changed files with 492 additions and 473 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

- uses: r-lib/actions/setup-pandoc@52330cc136b963487918a8867f948ddf954e9e63

- uses: r-lib/actions/setup-r@52330cc136b963487918a8867f948ddf954e9e63
- uses: r-lib/actions/setup-r@756399d909bf9c180bbdafe8025f794f51f2da02
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
Expand Down
24 changes: 4 additions & 20 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,14 @@ jobs:
steps:
- uses: actions/checkout@c0a81a463886bb75afe234e07a9fd5bb79219196

- uses: r-lib/actions/setup-r@52330cc136b963487918a8867f948ddf954e9e63
- uses: r-lib/actions/setup-r@756399d909bf9c180bbdafe8025f794f51f2da02

- uses: r-lib/actions/setup-pandoc@52330cc136b963487918a8867f948ddf954e9e63

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v1
- uses: r-lib/actions/setup-r-dependencies@756399d909bf9c180bbdafe8025f794f51f2da02
with:
path: ${{ env.R_LIBS_USER }}
key: macOS-r-4.0-2-${{ hashFiles('.github/depends.Rds') }}
restore-keys: macOS-r-4.0-2-

- name: Install dependencies
run: |
options(pkgType = "binary")
install.packages(c("remotes"))
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("covr")
shell: Rscript {0}
extra-packages: any::rcmdcheck
needs: check

- name: Test coverage
run: covr::codecov()
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: toxEval
Type: Package
Title: Exploring Biological Relevance of Environmental Chemistry Observations
Version: 1.3.0
Version: 1.3.1
Authors@R: c(person("Laura", "DeCicco",
role = c("aut","cre"),
email = "ldecicco@usgs.gov",
Expand Down Expand Up @@ -60,4 +60,4 @@ BugReports: https://github.com/DOI-USGS/toxEval/issues
VignetteBuilder: knitr
BuildVignettes: true
LazyLoad: yes
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export(remove_flags)
export(side_by_side_data)
export(tox_boxplot_data)
export(tox_chemicals)
import(dplyr)
import(ggplot2)
import(shinydashboard)
importFrom(grDevices,colorRampPalette)
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
toxEval 1.3.1
===========
* Made "Chemical" a required column in the Chemical tab. Now all plot names will key off that column instead of the names listed in tox_chemicals.
* Updated documentation to remove some notes.

toxEval 1.3.0
===========
* Switched to version 3.5 of the ToxCast database
Expand Down
4 changes: 2 additions & 2 deletions R/clean_endPoint_info.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' clean_endPoint_info
#'
#' Define a subset of the ToxCast database for relevance to toxEval analyses.
#' Subsetting is done based upon methods defined by
#' \doi{10.1021/acs.est.7b01613}{Blackwell et al., 2017}.
#' Subsetting is done based upon methods defined by Blackwell et al., 2017 (
#' \doi{10.1021/acs.est.7b01613}).
#' Specifically, this function removes endPoints that are ATG sources with
#' signal loss, and NVS with signal gain (basically: some assay/signal combinations
#' are removed because they target non-specific endpoints). Also, this function adds additional
Expand Down
14 changes: 7 additions & 7 deletions R/create_toxEval.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ create_toxEval <- function(excel_file_path, ...) {
names(chem_info) <- names(chem_info) %>%
allowed_names(c("casrn", "casn", "CASRN", "CASN"), "CAS")

if ("CAS" %in% names(chem_info)) {
if (all(c("CAS", "Chemical") %in% names(chem_info))){
chem_info$CAS <- as.character(chem_info$CAS)
} else {
message("Chemical tab missing CAS column")
message("Chemical tab missing CAS or Chemical column")
}
}

Expand Down Expand Up @@ -230,21 +230,21 @@ rm_em_dash <- function(df) {
#' tox_list <- create_toxEval(excel_file_path)
#' summary(tox_list)
summary.toxEval <- function(object, ...) {
CAS <- endPoint <- chnm <- flags <- ".dplyr"


if (is.null(object[["benchmarks"]])) {
ACC <- ToxCast_ACC %>%
filter(CAS %in% unique(object$chem_info$CAS))
dplyr::filter(CAS %in% unique(object$chem_info$CAS))
bench_word <- "ToxCast"
} else {
ACC <- object[["benchmarks"]]
bench_word <- "benchmark"
}

CAS_w_data <- ACC %>%
select(CAS) %>%
distinct() %>%
pull(CAS)
dplyr::select(CAS) %>%
dplyr::distinct() %>%
dplyr::pull(CAS)

message(length(CAS_w_data), " chemicals have ", bench_word, " information")
message("Chemicals returned from this function do NOT have ", bench_word, " information:")
Expand Down
50 changes: 23 additions & 27 deletions R/endpoint_hits.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ endpoint_hits_DT <- function(chemical_summary,
sum_logic = TRUE,
hit_threshold = 0.1,
include_links = TRUE) {
chnm <- CAS <- ".dplyr"

fullData <- endpoint_hits(
chemical_summary = chemical_summary,
Expand All @@ -70,8 +69,8 @@ endpoint_hits_DT <- function(chemical_summary,
if (category == "Chemical") {
orig_names <- names(fullData)

casKey <- select(chemical_summary, chnm, CAS) %>%
distinct()
casKey <- dplyr::select(chemical_summary, chnm, CAS) %>%
dplyr::distinct()

numeric_hits <- fullData
hits <- sapply(fullData, function(x) as.character(x))
Expand Down Expand Up @@ -149,54 +148,52 @@ endpoint_hits <- function(chemical_summary,
mean_logic = FALSE,
sum_logic = TRUE,
hit_threshold = 0.1) {
Bio_category <- Class <- EAR <- sumEAR <- value <- calc <- chnm <- choice_calc <- n <- nHits <- site <- ".dplyr"
endPoint <- meanEAR <- nSites <- CAS <- ".dplyr"

match.arg(category, c("Biological", "Chemical Class", "Chemical"))

fullData_init <- data.frame(endPoint = "", stringsAsFactors = FALSE)
fullData <- fullData_init

if (category == "Chemical") {
chemical_summary <- mutate(chemical_summary, category = chnm)
chemical_summary <- dplyr::mutate(chemical_summary, category = chnm)
} else if (category == "Chemical Class") {
chemical_summary <- mutate(chemical_summary, category = Class)
chemical_summary <- dplyr::mutate(chemical_summary, category = Class)
} else {
chemical_summary <- mutate(chemical_summary, category = Bio_category)
chemical_summary <- dplyr::mutate(chemical_summary, category = Bio_category)
}

if (length(unique(chemical_summary$site)) > 1) {
if (!sum_logic) {
fullData <- chemical_summary %>%
group_by(site, category, endPoint, date) %>%
summarize(sumEAR = max(EAR)) %>%
group_by(site, category, endPoint) %>%
summarize(meanEAR = ifelse(mean_logic, mean(sumEAR), max(sumEAR))) %>%
group_by(category, endPoint) %>%
summarize(nSites = sum(meanEAR > hit_threshold)) %>%
dplyr::group_by(site, category, endPoint, date) %>%
dplyr::summarize(sumEAR = max(EAR)) %>%
dplyr::group_by(site, category, endPoint) %>%
dplyr::summarize(meanEAR = ifelse(mean_logic, mean(sumEAR), max(sumEAR))) %>%
dplyr::group_by(category, endPoint) %>%
dplyr::summarize(nSites = sum(meanEAR > hit_threshold)) %>%
tidyr::spread(category, nSites)
} else {
fullData <- chemical_summary %>%
group_by(site, category, endPoint, date) %>%
summarize(sumEAR = sum(EAR)) %>%
group_by(site, category, endPoint) %>%
summarize(meanEAR = ifelse(mean_logic, mean(sumEAR), max(sumEAR))) %>%
group_by(category, endPoint) %>%
summarize(nSites = sum(meanEAR > hit_threshold)) %>%
dplyr::group_by(site, category, endPoint, date) %>%
dplyr::summarize(sumEAR = sum(EAR)) %>%
dplyr::group_by(site, category, endPoint) %>%
dplyr::summarize(meanEAR = ifelse(mean_logic, mean(sumEAR), max(sumEAR))) %>%
dplyr::group_by(category, endPoint) %>%
dplyr::summarize(nSites = sum(meanEAR > hit_threshold)) %>%
tidyr::spread(category, nSites)
}
} else {
if (!sum_logic) {
fullData <- chemical_summary %>%
group_by(category, endPoint) %>%
summarise(nSites = sum(EAR > hit_threshold)) %>%
dplyr::group_by(category, endPoint) %>%
dplyr::summarise(nSites = sum(EAR > hit_threshold)) %>%
tidyr::spread(category, nSites)
} else {
fullData <- chemical_summary %>%
group_by(category, endPoint, date) %>%
summarize(sumEAR = sum(EAR)) %>%
group_by(category, endPoint) %>%
summarise(nSites = sum(sumEAR > hit_threshold)) %>%
dplyr::group_by(category, endPoint, date) %>%
dplyr::summarize(sumEAR = sum(EAR)) %>%
dplyr::group_by(category, endPoint) %>%
dplyr::summarise(nSites = sum(sumEAR > hit_threshold)) %>%
tidyr::spread(category, nSites)
}
}
Expand Down Expand Up @@ -224,7 +221,6 @@ endpoint_hits <- function(chemical_summary,
#'
#' Create links
#' @param cas character
#' @param hits character
#' @export
#' @keywords internal
createLink <- function(cas) {
Expand Down
2 changes: 1 addition & 1 deletion R/filter_endPoint_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ filter_groups <- function(ep,
assay_source_name <- assay_component_endpoint_name <- ".dplyr"

ep <- ep[, c("assay_component_endpoint_name", groupCol, "assay_source_name")] %>%
rename(
dplyr::rename(
endPoint = assay_component_endpoint_name,
assaysFull = assay_source_name
)
Expand Down
11 changes: 3 additions & 8 deletions R/get_ACC.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#' to units of \eqn{\mu}g/L, and reformat the data as input to toxEval.
#'
#' @param CAS Vector of CAS.
#' @import dplyr
#'
#' @return data frame with columns CAS, chnm, flags, endPoint, ACC, MlWt, and ACC_value
#' @export
Expand All @@ -20,10 +19,6 @@
#' head(ACC)
get_ACC <- function(CAS) {

# Getting rid of NSE warnings:
Structure_MolWt <- Substance_CASRN <- casn <- Substance_Name <- ".dplyr"
chnm <- flags <- MlWt <- ACC_value <- casrn <- endPoint <- ".dplyr"

chem_list <- dplyr::select(tox_chemicals,
casrn = Substance_CASRN,
MlWt = Structure_MolWt
Expand All @@ -36,12 +31,12 @@ get_ACC <- function(CAS) {
by = c("CAS" = "casrn")
)

ACC <- mutate(ACC,
ACC <- dplyr::mutate(ACC,
ACC_value = 10^ACC,
ACC_value = ACC_value * MlWt
)
ACC <- filter(ACC, !is.na(ACC_value))
ACC <- left_join(ACC, select(tox_chemicals,
ACC <- dplyr::filter(ACC, !is.na(ACC_value))
ACC <- dplyr::left_join(ACC, dplyr::select(tox_chemicals,
CAS = Substance_CASRN,
chnm = Substance_Name
), by = "CAS")
Expand Down
Loading

0 comments on commit eceacc5

Please sign in to comment.