Skip to content

Commit

Permalink
Merge pull request #286 from ldecicco-USGS/master
Browse files Browse the repository at this point in the history
More movement to all snake case
  • Loading branch information
ldecicco-USGS authored Jul 17, 2018
2 parents a7fa69b + 43609ac commit b89b1a0
Show file tree
Hide file tree
Showing 81 changed files with 782 additions and 782 deletions.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Generated by roxygen2: do not edit by hand

S3method(summary,toxEval)
export(ACC)
export(ToxCast_ACC)
export(clean_endPoint_info)
export(createLink)
export(create_toxEval)
export(endPointInfo)
export(end_point_info)
export(endpoint_hits)
export(endpoint_hits_DT)
export(explore_endpoints)
Expand Down
38 changes: 19 additions & 19 deletions R/clean_endPoint_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@
#' categories to intended_target_family and intended_target_family_sub as
#' described in the paper linked above.
#'
#' @param endPointInfo Data frame Endpoint information from ToxCast.
#' @param end_point_info Data frame Endpoint information from ToxCast.
#' @export
#' @return The returned data frame is based on endPointInfo, but with some endPoints
#' @return The returned data frame is based on end_point_info, but with some endPoints
#' filtered out and some additional categories in intended_target_family and
#' intended_target_family_sub. The names in intended_target_family
#' are revised to look more appealing in graphs and tables.
#' @importFrom tools toTitleCase
#' @examples
#' endPointInfo <- endPointInfo
#' cleaned_ep <- clean_endPoint_info(endPointInfo)
clean_endPoint_info <- function(endPointInfo){
#' end_point_info <- end_point_info
#' cleaned_ep <- clean_endPoint_info(end_point_info)
clean_endPoint_info <- function(end_point_info){

endPointInfo <- endPointInfo[!(endPointInfo$assay_source_name == "ATG" & endPointInfo$signal_direction == "loss"),]
endPointInfo <- endPointInfo[!(endPointInfo$assay_source_name == "NVS" & endPointInfo$signal_direction == "gain"),]
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"),]

endPointInfo$intended_target_family[endPointInfo$assay_component_endpoint_name %in%
end_point_info$intended_target_family[end_point_info$assay_component_endpoint_name %in%
c("CLD_CYP1A1_24hr","CLD_CYP1A1_48hr","CLD_CYP1A1_6hr",
"CLD_CYP1A2_24hr","CLD_CYP1A2_48hr","CLD_CYP1A2_6hr")] <- "dna binding"

endPointInfo$intended_target_family[endPointInfo$assay_component_endpoint_name %in%
end_point_info$intended_target_family[end_point_info$assay_component_endpoint_name %in%
c("CLD_CYP2B6_24hr","CLD_CYP2B6_48hr","CLD_CYP2B6_6hr",
"CLD_CYP3A4_24hr","CLD_CYP3A4_48hr","CLD_CYP3A4_6hr",
"CLD_SULT2A_48hr","CLD_UGT1A1_48hr","NVS_NR_bER",
"NVS_NR_bPR","NVS_NR_cAR")] <- "nuclear receptor"

endPointInfo$intended_target_family[endPointInfo$assay_component_endpoint_name %in%
end_point_info$intended_target_family[end_point_info$assay_component_endpoint_name %in%
c("Tanguay_ZF_120hpf_ActivityScore",
"Tanguay_ZF_120hpf_AXIS_up",
"Tanguay_ZF_120hpf_BRAI_up",
Expand All @@ -53,34 +53,34 @@ clean_endPoint_info <- function(endPointInfo){
"Tanguay_ZF_120hpf_TRUN_up",
"Tanguay_ZF_120hpf_YSE_up")] <- "zebrafish"

endPointInfo$intended_target_family[is.na(endPointInfo$intended_target_family)] <- "Undefined"
end_point_info$intended_target_family[is.na(end_point_info$intended_target_family)] <- "Undefined"

cleanUpNames <- endPointInfo$intended_target_family
cleanUpNames <- end_point_info$intended_target_family
cleanUpNames <- tools::toTitleCase(cleanUpNames)
cleanUpNames[grep("Dna",cleanUpNames)] <- "DNA Binding"
cleanUpNames[grep("Cyp",cleanUpNames)] <- "CYP"
cleanUpNames[grep("Gpcr",cleanUpNames)] <- "GPCR"
endPointInfo$intended_target_family <- cleanUpNames
end_point_info$intended_target_family <- cleanUpNames

endPointInfo$intended_target_family_sub[endPointInfo$assay_component_endpoint_name %in%
end_point_info$intended_target_family_sub[end_point_info$assay_component_endpoint_name %in%
c("CLD_CYP1A1_24hr","CLD_CYP1A1_48hr",
"CLD_CYP1A1_6hr","CLD_CYP1A2_24hr",
"CLD_CYP1A2_48hr","CLD_CYP1A2_6hr")] <- "basic helix-loop-helix protein"

endPointInfo$intended_target_family_sub[endPointInfo$assay_component_endpoint_name %in%
end_point_info$intended_target_family_sub[end_point_info$assay_component_endpoint_name %in%
c("CLD_CYP2B6_24hr","CLD_CYP2B6_48hr",
"CLD_CYP2B6_6hr","CLD_CYP3A4_24hr",
"CLD_CYP3A4_48hr","CLD_CYP3A4_6hr",
"CLD_SULT2A_48hr","CLD_UGT1A1_48hr")] <- "non-steroidal"

endPointInfo$intended_target_family_sub[endPointInfo$assay_component_endpoint_name %in%
end_point_info$intended_target_family_sub[end_point_info$assay_component_endpoint_name %in%
c("NVS_NR_bER","NVS_NR_bPR","NVS_NR_cAR")] <- "steroidal"


cleanUpNames <- endPointInfo$intended_target_family_sub
cleanUpNames <- end_point_info$intended_target_family_sub
cleanUpNames <- tools::toTitleCase(cleanUpNames)
cleanUpNames[grep("Dna",cleanUpNames)] <- "DNA Conformation"
endPointInfo$intended_target_family_sub <- cleanUpNames
end_point_info$intended_target_family_sub <- cleanUpNames

return(endPointInfo)
return(end_point_info)
}
2 changes: 1 addition & 1 deletion R/create_toxEval.R
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ summary.toxEval <- function(object, ...){
CAS <- endPoint <- chnm <- flags <- ".dplyr"

if(is.null(object[["benchmarks"]])){
ACC <- ACC %>%
ACC <- ToxCast_ACC %>%
dplyr::filter(CAS %in% unique(object$chem_info$CAS))
bench_word <- "ToxCast"
} else {
Expand Down
38 changes: 19 additions & 19 deletions R/endpoint_hits.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' instance is the number of samples with hits rather than the number of sites
#' with hits.
#'
#' @param chemicalSummary Data frame from \code{get_chemical_summary}
#' @param chemical_summary Data frame from \code{get_chemical_summary}
#' @param mean_logic Logical. \code{TRUE} displays the mean sample from each site,
#' FALSE displays the maximum sample from each site.
#' @param sum_logic Logical. \code{TRUE} sums the EARs in a specified grouping,
Expand Down Expand Up @@ -45,16 +45,16 @@
#' ACC <- get_ACC(tox_list$chem_info$CAS)
#' ACC <- remove_flags(ACC)
#'
#' cleaned_ep <- clean_endPoint_info(endPointInfo)
#' cleaned_ep <- clean_endPoint_info(end_point_info)
#' filtered_ep <- filter_groups(cleaned_ep)
#' chemicalSummary <- get_chemical_summary(tox_list, ACC, filtered_ep)
#' chemical_summary <- get_chemical_summary(tox_list, ACC, filtered_ep)
#'
#' hits_df <- endpoint_hits(chemicalSummary, category = "Biological")
#' endpoint_hits_DT(chemicalSummary, category = "Biological")
#' endpoint_hits_DT(chemicalSummary, category = "Chemical Class")
#' endpoint_hits_DT(chemicalSummary, category = "Chemical")
#' hits_df <- endpoint_hits(chemical_summary, category = "Biological")
#' endpoint_hits_DT(chemical_summary, category = "Biological")
#' endpoint_hits_DT(chemical_summary, category = "Chemical Class")
#' endpoint_hits_DT(chemical_summary, category = "Chemical")
#' }
endpoint_hits_DT <- function(chemicalSummary,
endpoint_hits_DT <- function(chemical_summary,
category = "Biological",
mean_logic = FALSE,
sum_logic = TRUE,
Expand All @@ -63,7 +63,7 @@ endpoint_hits_DT <- function(chemicalSummary,

chnm <- CAS <- ".dplyr"

fullData <- endpoint_hits(chemicalSummary = chemicalSummary,
fullData <- endpoint_hits(chemical_summary = chemical_summary,
category = category,
mean_logic = mean_logic,
sum_logic = sum_logic,
Expand All @@ -72,7 +72,7 @@ endpoint_hits_DT <- function(chemicalSummary,
if(category == "Chemical"){
orig_names <- names(fullData)

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

numeric_hits <- fullData
Expand Down Expand Up @@ -138,7 +138,7 @@ endpoint_hits_DT <- function(chemicalSummary,

#' @rdname endpoint_hits_DT
#' @export
endpoint_hits <- function(chemicalSummary,
endpoint_hits <- function(chemical_summary,
category = "Biological",
mean_logic = FALSE,
sum_logic = TRUE,
Expand All @@ -152,17 +152,17 @@ endpoint_hits <- function(chemicalSummary,
fullData <- fullData_init

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

if(length(unique(chemicalSummary$site)) > 1){
if(length(unique(chemical_summary$site)) > 1){

if(!sum_logic){
fullData <- chemicalSummary %>%
fullData <- chemical_summary %>%
group_by(site, category, endPoint, date) %>%
summarize(sumEAR = max(EAR)) %>%
group_by(site, category, endPoint) %>%
Expand All @@ -171,7 +171,7 @@ endpoint_hits <- function(chemicalSummary,
summarize(nSites = sum(meanEAR > hit_threshold)) %>%
spread(category, nSites)
} else {
fullData <- chemicalSummary %>%
fullData <- chemical_summary %>%
group_by(site, category, endPoint, date) %>%
summarize(sumEAR = sum(EAR)) %>%
group_by(site, category, endPoint) %>%
Expand All @@ -183,12 +183,12 @@ endpoint_hits <- function(chemicalSummary,

} else {
if(!sum_logic){
fullData <- chemicalSummary %>%
fullData <- chemical_summary %>%
group_by(category, endPoint) %>%
summarise(nSites = sum(EAR > hit_threshold)) %>%
spread(category, nSites)
} else {
fullData <- chemicalSummary %>%
fullData <- chemical_summary %>%
group_by(category, endPoint, date) %>%
summarize(sumEAR = sum(EAR)) %>%
group_by(category, endPoint) %>%
Expand Down
8 changes: 4 additions & 4 deletions R/filter_endPoint_info.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#' Filter endPoints based on groups and assays.
#'
#' This function provides a mechanism to specify 3 levels of information in the
#' supplied data frame \code{\link{endPointInfo}} to be used in subsequent analysis steps.
#' 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 'endPointInfo'. Second, the user
#' 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
#' remove specific group(s) from the category. The default is to remove
#' 'Background Measurement' and 'Undefined'. Choices for this should be
Expand All @@ -25,8 +25,8 @@
#' @export
#' @importFrom dplyr rename
#' @examples
#' endPointInfo <- endPointInfo
#' cleaned_ep <- clean_endPoint_info(endPointInfo)
#' end_point_info <- end_point_info
#' cleaned_ep <- clean_endPoint_info(end_point_info)
#' filtered_ep <- filter_groups(cleaned_ep)
filter_groups <- function(ep,
groupCol = "intended_target_family",
Expand Down
2 changes: 1 addition & 1 deletion R/get_ACC.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ get_ACC <- function(CAS){
MlWt = Structure_MolWt) %>%
filter(casrn %in% CAS)

ACC <- ACC %>%
ACC <- ToxCast_ACC %>%
filter(CAS %in% CAS) %>%
right_join(chem_list,
by= c("CAS"="casrn")) %>%
Expand Down
28 changes: 14 additions & 14 deletions R/get_chemical_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
#' ACC <- get_ACC(tox_list$chem_info$CAS)
#' ACC <- remove_flags(ACC)
#'
#' cleaned_ep <- clean_endPoint_info(endPointInfo)
#' cleaned_ep <- clean_endPoint_info(end_point_info)
#' filtered_ep <- filter_groups(cleaned_ep)
#'
#' chemicalSummary <- get_chemical_summary(tox_list, ACC, filtered_ep)
#' chemical_summary <- get_chemical_summary(tox_list, ACC, filtered_ep)
#'
get_chemical_summary <- function(tox_list, ACC = NULL, filtered_ep = "All",
chem_data=NULL, chem_site=NULL,
Expand Down Expand Up @@ -85,14 +85,14 @@ get_chemical_summary <- function(tox_list, ACC = NULL, filtered_ep = "All",
if(is.null(ACC)){
ACC <- tox_list[["benchmarks"]]
} else {
ACC <- select(ACC, CAS, chnm, endPoint, ACC_value)
ACC <- dplyr::select(ACC, CAS, chnm, endPoint, ACC_value)
}

if(class(chem_data$Value) == "character"){
chem_data$Value <- as.numeric(chem_data$Value)
}

chemicalSummary <- full_join(ACC,
chemical_summary <- full_join(ACC,
select(chem_data, CAS, SiteID, Value, `Sample Date`), by="CAS") %>%
filter(!is.na(ACC_value)) %>%
filter(!is.na(Value)) %>%
Expand All @@ -101,42 +101,42 @@ get_chemical_summary <- function(tox_list, ACC = NULL, filtered_ep = "All",
date = `Sample Date`)

if(all(filtered_ep != "All")){
chemicalSummary <- chemicalSummary %>%
chemical_summary <- chemical_summary %>%
select(CAS, chnm, endPoint, site, date, EAR) %>%
filter(endPoint %in% filtered_ep$endPoint) %>%
left_join(select(filtered_ep, endPoint, groupCol), by="endPoint")

} else {

chemicalSummary <- chemicalSummary %>%
chemical_summary <- chemical_summary %>%
select(CAS, chnm, endPoint, site, date, EAR, groupCol)

}

chemicalSummary <- chemicalSummary %>%
chemical_summary <- chemical_summary %>%
left_join(select(chem_site, site=SiteID, `Short Name`),
by="site") %>%
left_join(select(chem_info, CAS, Class), by="CAS") %>%
rename(Bio_category = groupCol,
shortName = `Short Name`)

if(!is.null(exclusion)){
chemicalSummary <- exclude_points(chemicalSummary, exclusion)
chemical_summary <- exclude_points(chemical_summary, exclusion)
}

graphData <- graph_chem_data(chemicalSummary)
graphData <- graph_chem_data(chemical_summary)

orderClass_df <- orderClass(graphData)

orderChem_df <- orderChem(graphData, orderClass_df)

chemicalSummary$chnm <- factor(chemicalSummary$chnm,
chemical_summary$chnm <- factor(chemical_summary$chnm,
levels = unique(orderChem_df$chnm))

chemicalSummary$Class <- factor(chemicalSummary$Class,
chemical_summary$Class <- factor(chemical_summary$Class,
levels = rev(levels(orderChem_df$Class)))

return(chemicalSummary)
return(chemical_summary)
}


Expand Down Expand Up @@ -248,7 +248,7 @@ remove_flags <- function(ACC, flagsShort = c("Borderline",
}


exclude_points <- function(chemicalSummary, exclusion){
exclude_points <- function(chemical_summary, exclusion){

CAS <- endPoint <- casrn <- ".dplyr"

Expand All @@ -259,7 +259,7 @@ exclude_points <- function(chemicalSummary, exclusion){
filter(!is.na(CAS),
!is.na(endPoint))

chem_filtered <- chemicalSummary %>%
chem_filtered <- chemical_summary %>%
filter(!(CAS %in% exclude_chem)) %>%
filter(!(endPoint %in% exclude_ep))

Expand Down
Loading

0 comments on commit b89b1a0

Please sign in to comment.