Skip to content

Commit

Permalink
Merge pull request #410 from ldecicco-USGS/response_to_review
Browse files Browse the repository at this point in the history
Response to review
  • Loading branch information
ldecicco-USGS authored Oct 2, 2024
2 parents 9faef98 + 3e59c14 commit 0096aa5
Show file tree
Hide file tree
Showing 52 changed files with 643 additions and 527 deletions.
4 changes: 1 addition & 3 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,5 @@ vignettes/group.png
vignettes/sites.png
vignettes/thres.png
^docker$
vignettes/update_data.Rmd


^review$

11 changes: 7 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
image: ${CI_REGISTRY_IMAGE}:latest

workflow:
rules:
- if: $CI_COMMIT_TAG
Expand Down Expand Up @@ -29,6 +31,7 @@ variables:

build-image:
stage: build
cache: []
image: ${DEVOPS_REGISTRY}usgs/docker:20
services:
- name: ${DEVOPS_REGISTRY}usgs/docker:20-dind
Expand All @@ -53,7 +56,7 @@ build-image:

buildcheck:
stage: check
image: ${CI_REGISTRY_IMAGE}:latest
cache: []
dependencies:
- build-image
script:
Expand All @@ -66,7 +69,7 @@ buildcheck:

unittests:
stage: test
image: ${CI_REGISTRY_IMAGE}:latest
cache: []
dependencies:
- build-image
- buildcheck
Expand All @@ -82,7 +85,6 @@ unittests:

covertests:
stage: test
image: ${CI_REGISTRY_IMAGE}:latest
dependencies:
- build-image
- buildcheck
Expand All @@ -98,7 +100,6 @@ covertests:

pages:
stage: end
image: ${CI_REGISTRY_IMAGE}:latest
only:
- main
script:
Expand All @@ -112,6 +113,8 @@ pages:
Validate Inventory:
stage: end
image: ${INTERNAL_REGISTRY}software/software-management:latest
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- software-management review
--project "${CI_PROJECT_PATH}"
Expand Down
7 changes: 3 additions & 4 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.2
Version: 1.4.0
Authors@R: c(person("Laura", "DeCicco",
role = c("aut","cre"),
email = "[email protected]",
Expand Down Expand Up @@ -33,7 +33,7 @@ Copyright: This software is in the public domain because it contains materials
official USGS copyright policy at
https://www.usgs.gov/visual-id/credit_usgs.html#copyright
Depends:
R (>= 3.5.0)
R (>= 4.1.0)
Imports:
dplyr,
tidyr,
Expand All @@ -60,5 +60,4 @@ BugReports: https://github.com/DOI-USGS/toxEval/issues
VignetteBuilder: knitr
BuildVignettes: true
LazyLoad: yes
RoxygenNote: 7.3.1

RoxygenNote: 7.3.2
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export(endpoint_hits)
export(endpoint_hits_DT)
export(explore_endpoints)
export(filter_groups)
export(flags)
export(get_ACC)
export(get_chemical_summary)
export(get_concentration_summary)
Expand Down
6 changes: 6 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
toxEval 1.4.0
===========
* Switched to version 4.1 of the ToxCast database
* Added a default flag to remove in remove_flags


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.
Expand Down
14 changes: 3 additions & 11 deletions R/clean_endPoint_info.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#' clean_endPoint_info
#'
#' Define a subset of the ToxCast database for relevance to toxEval analyses.
#' 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
#' categories to intended_target_family and intended_target_family_sub as
#' described in the paper linked above.
#' As of ToxCast 4.1, this function only helps clean up abbrieviations
#' found in the end_point_info data frame.
#'
#' @param end_point_info Data frame Endpoint information from ToxCast.
#' @export
Expand All @@ -21,9 +15,7 @@
#' cleaned_ep <- clean_endPoint_info(end_point_info)
#' nrow(cleaned_ep)
clean_endPoint_info <- function(end_point_info) {
end_point_info <- end_point_info[!(end_point_info$assay_source_name == "ATG" & end_point_info$signal_direction == "loss"), ]
end_point_info <- end_point_info[!(end_point_info$assay_source_name == "NVS" & end_point_info$signal_direction == "gain"), ]


end_point_info$intended_target_family[end_point_info$assay_component_endpoint_name %in%
c(
"CLD_CYP1A1_24hr", "CLD_CYP1A1_48hr", "CLD_CYP1A1_6hr",
Expand Down
6 changes: 3 additions & 3 deletions R/create_toxEval.R
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,17 @@ summary.toxEval <- function(object, ...) {

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

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

message(length(CAS_w_data), " chemicals have ", bench_word, " information")
message("Chemicals returned from this function do NOT have ", bench_word, " information:")
Expand Down
24 changes: 7 additions & 17 deletions R/filter_endPoint_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' supplied data frame \code{\link{end_point_info}} to be used in subsequent analysis steps.
#' First, the user specifies the ToxCast assay annotation using the 'groupCol'
#' argument, which is a column header in 'end_point_info'. Second, the user
#' specifies the families of assays to use. Finally, the user can choose to
#' specifies the families of assays to exclude. Finally, the user can choose to
#' remove specific group(s) from the category. The default is to remove
#' 'Background Measurement' and 'Undefined'. Choices for this should be
#' reconsidered based on individual study objectives.
Expand All @@ -17,11 +17,8 @@
#'
#' @param ep Data frame containing Endpoint information from ToxCast
#' @param groupCol Character name of ToxCast annotation column to use as a group category
#' @param assays Vector of assays to use in the data analysis. Possible values are "ACEA", "APR", "ATG",
#' "NVS", "OT", "TOX21", "CEETOX", "LTEA", "CLD", "TANGUAY", "CCTE_PADILLA", "BSK" ,
#' "CCTE", "STM", "ARUNA", "CCTE_SHAFER", "CPHEA_STOKER", "CCTE_GLTED", "UPITT", "UKN",
#' "ERF", "TAMU", "IUF", "CCTE_MUNDY", "UTOR", "VALA". By default, the
#' "BSK" (BioSeek) assay is removed.
#' @param remove_assays Vector of assays to EXCLUDE in the data analysis.
#' By default, the "BSK" (BioSeek) assay is removed.
#' @param remove_groups Vector of groups within the selected 'groupCol' to remove.
#' @export
#' @examples
Expand All @@ -31,18 +28,11 @@
#' head(filtered_ep)
filter_groups <- function(ep,
groupCol = "intended_target_family",
assays = c(
"ACEA", "APR", "ATG",
"NVS", "OT", "TOX21", "CEETOX",
"LTEA", "CLD", "TANGUAY", "CCTE_PADILLA",
"CCTE", "STM", "ARUNA", "CCTE_SHAFER",
"CPHEA_STOKER", "CCTE_GLTED", "UPITT", "UKN",
"ERF", "TAMU", "IUF", "CCTE_MUNDY",
"UTOR", "VALA"
),
remove_assays = c("BSK"),
remove_groups = c("Background Measurement", "Undefined")) {

possible_assays <- unique(end_point_info$assay_source_name)
match.arg(assays, possible_assays, several.ok = TRUE)
match.arg(remove_assays, possible_assays, several.ok = TRUE)

# Getting rid of NSE warnings:
assay_source_name <- assay_component_endpoint_name <- ".dplyr"
Expand All @@ -54,7 +44,7 @@ filter_groups <- function(ep,
)
names(ep)[names(ep) == groupCol] <- "groupCol"

ep <- ep[(ep$assaysFull %in% assays), ]
ep <- ep[!(ep$assaysFull %in% remove_assays), ]
ep <- ep[!is.na(ep$groupCol), ]
if (any(!is.na(remove_groups))) {
if (any(remove_groups != "")) {
Expand Down
44 changes: 20 additions & 24 deletions R/get_ACC.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
#' The \code{get_ACC} function retrieves the activity concentration at cutoff
#' (ACC) values for specified chemicals.
#'
#' The data used in toxEval were combined from files in the
#' "INVITRODB_V3_LEVEL5" directory that were included in the October 2018
#' release of the ToxCast database. The function \code{get_ACC} will
#' convert the ACC values in the ToxCast database from units of (log \eqn{\mu}M)
#' The function \code{get_ACC} will
#' convert the ACC values in the ToxCast database from units of (\eqn{\mu}M)
#' to units of \eqn{\mu}g/L, and reformat the data as input to toxEval.
#'
#' @param CAS Vector of CAS.
Expand All @@ -19,27 +17,25 @@
#' head(ACC)
get_ACC <- function(CAS) {

chem_list <- dplyr::select(tox_chemicals,
casrn = Substance_CASRN,
MlWt = Structure_MolWt
)
chem_list <- dplyr::filter(chem_list, casrn %in% CAS)
chem_list <- tox_chemicals |>
dplyr::select(casrn = casn,
MlWt = Structure_MolWt) |>
dplyr::filter(casrn %in% CAS)

ACC <- ToxCast_ACC
ACC <- dplyr::filter(ACC, CAS %in% CAS)
ACC <- dplyr::right_join(ACC, chem_list,
by = c("CAS" = "casrn")
)

ACC <- dplyr::mutate(ACC,
ACC_value = 10^ACC,
ACC_value = ACC_value * MlWt
)
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")
ACC <- ToxCast_ACC |>
dplyr::filter(casn %in% CAS) |>
dplyr::right_join(chem_list, by = c("casn" = "casrn")) |>
dplyr::rename(CAS = casn) |>
dplyr::mutate(ACC_value = hit_val * MlWt) |>
dplyr::filter(!is.na(ACC_value)) |>
dplyr::left_join(dplyr::select(tox_chemicals,
CAS = casn,
chnm = chnm),
by = "CAS") |>
dplyr::left_join(end_point_info |>
dplyr::select(aeid,
endPoint = assay_component_endpoint_name),
by = "aeid")

if (any(is.na(ACC$MlWt))) {
warning("Some chemicals are missing molecular weights")
Expand Down
Loading

0 comments on commit 0096aa5

Please sign in to comment.