Skip to content

Commit

Permalink
Merge pull request #210 from ldecicco-USGS/master
Browse files Browse the repository at this point in the history
Export benchmarks
  • Loading branch information
ldecicco-USGS authored Jan 5, 2018
2 parents a217a94 + ba55b43 commit 50d004a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 29 deletions.
29 changes: 14 additions & 15 deletions R/get_chemical_summary.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#' get_chemical_summary
#'
#' Get ACC values for vector of CAS's
#' @param ACClong data frame with at least columns: CAS, chnm, endPoint, ACC_value
#' @param filtered_ep data frame with colums: endPoints, groupCol
#' @param tox_list list with data frames for chem_data, chem_info, chem_site,
#' and optionally exclusions and benchmarks. Created with \code{\link{create_toxEval}}
#' @param chem.data data frame with (at least) columns: CAS, SiteID, Value
#' @param chem.site data frame with (at least) columns: SiteID, Short Name
#' @param chem.info data frame with (at least) columns: CAS, class
#' @param exclusion OPTIONAL data frame with (at least) columns: CAS and endPoint
#' @param ACClong data frame with at least columns: CAS, chnm, endPoint, ACC_value
#' @param filtered_ep data frame with colums: endPoints, groupCol. Default is \code{"All"}, where no
#' filtering occurs.
#' @param chem.data OPTIONAL data frame with (at least) columns: CAS, SiteID, Value. Default is \code{NULL}.
#' Will over-ride what is in tox_list.
#' @param chem.site OPTIONAL data frame with (at least) columns: SiteID, Short Name. Default is \code{NULL}.
#' Will over-ride what is in tox_list.
#' @param chem.info OPTIONAL data frame with (at least) columns: CAS, class. Default is \code{NULL}.
#' Will over-ride what is in tox_list.
#' @param exclusion OPTIONAL data frame with (at least) columns: CAS and endPoint. Default is \code{NULL}.
#' Will over-ride what is in tox_list.
#' @export
#' @importFrom tidyr gather
#' @importFrom dplyr full_join filter mutate select left_join right_join anti_join
Expand All @@ -27,15 +32,6 @@
#'
#' chemicalSummary <- get_chemical_summary(tox_list, ACClong, filtered_ep)
#'
#' library(readxl)
#' chem_data <- read_excel(full_path, sheet = "Data")
#' chem_info <- read_excel(full_path, sheet = "Chemicals")
#' chem_site <- read_excel(full_path, sheet = "Sites")
#'
#' chemicalSummary1 <- get_chemical_summary(tox_list = NULL, ACClong, filtered_ep,
#' chem.data = chem_data,
#' chem.site = chem_site,
#' chem.info = chem_info)
get_chemical_summary <- function(tox_list, ACClong = NULL, filtered_ep = "All",
chem.data=NULL, chem.site=NULL,
chem.info=NULL, exclusion=NULL){
Expand Down Expand Up @@ -240,6 +236,9 @@ remove_flags <- function(ACClong, flagsShort = c("Borderline",
#' # The example workflow takes a bit of time to load and compute,
#' # so an example chemicalSummary is included pre-calculated in the package.
#' chemicalSummary <- ex_chemSum #loading example data
#' exclusion <- data.frame(CAS = c("134-62-3","486-56-6"),
#' endPoint = c("", "TOX21_p53_BLA_p3_viability"),
#' stringsAsFactors = FALSE)
#' chemicalSummary <- exclude_points(chemicalSummary, exclusion)
exclude_points <- function(chemicalSummary, exclusion){

Expand Down
45 changes: 45 additions & 0 deletions inst/shiny/benchmarks.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
output$downloadBenchmarks <- downloadHandler(

filename = "Benchmarks.csv",

content = function(filename) {
write.csv(get_benchmarks(), filename, row.names = FALSE)
}
)

get_benchmarks <- reactive({

groupCol <- epDF[["groupColName"]]
assays <- epDF[["assays"]]
flags <- epDF[["flags"]]
sites <- epDF[["sites"]]
groups <- epDF[["group"]]
removeFlags <- all_flags[!(all_flags %in% flags)]
rawData <- rawData()

if(!is.null(rawData)){
if(all(is.null(rawData$benchmarks))){

ACClong <- get_ACC(rawData$chem_info$CAS)
ACClong <- remove_flags(ACClong, flagsShort = removeFlags)

remove_groups <- unique(cleaned_ep[[groupCol]])[which(!unique(cleaned_ep[[groupCol]]) %in% groups)]
remove_groups <- remove_groups[!is.na(remove_groups)]

filtered_ep <- filter_groups(cleaned_ep,
groupCol = groupCol, assays = assays,
remove_groups = remove_groups)

bench <- ACClong %>%
filter(endPoint %in% filtered_ep$endPoint) %>%
rename(Value = ACC_value,
Chemical = chnm) %>%
left_join(filtered_ep, by = "endPoint")

} else {
bench <- rawData$benchmarks
}
}

return(bench)
})
3 changes: 3 additions & 0 deletions man/exclude_points.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 10 additions & 14 deletions man/get_chemical_summary.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 50d004a

Please sign in to comment.