diff --git a/DESCRIPTION b/DESCRIPTION index adf3e78b..e81d0f29 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: toxEval Type: Package Title: ToxCast Evaluations -Version: 0.3.3 -Date: 2017-04-28 +Version: 0.3.4 +Date: 2017-05-02 Authors@R: c( person("Steven", "Corsi", role = c("aut"), email = "srcorsi@usgs.gov"), person("Laura", "DeCicco", role = c("aut","cre"), diff --git a/R/plot_chemical_boxplots.R b/R/plot_chemical_boxplots.R index f12306cd..e51e1a60 100644 --- a/R/plot_chemical_boxplots.R +++ b/R/plot_chemical_boxplots.R @@ -4,6 +4,7 @@ #' @param chemicalSummary data frame from \code{graph_chem_data} #' @param manual_remove vector of categories to remove #' @param mean_logic logical \code{TRUE} is mean, \code{FALSE} is maximum +#' @param plot_ND logical whether or not to plot the non-detects #' @export #' @import ggplot2 #' @importFrom stats median quantile @@ -32,7 +33,8 @@ #' plot_chemical_boxplots(chemicalSummary) plot_chemical_boxplots <- function(chemicalSummary, manual_remove=NULL, - mean_logic = FALSE){ + mean_logic = FALSE, + plot_ND = TRUE){ site <- EAR <- sumEAR <- meanEAR <- groupCol <- nonZero <- ".dplyr" chnm <- Class <- maxEAR <- ".dplyr" @@ -41,16 +43,20 @@ plot_chemical_boxplots <- function(chemicalSummary, "#FFFF00","#78C15A","#79AEAE","#FF0000","#00FF00","#B1611D", "#FFA500","#F4426e", "#800000", "#808000") + if(!plot_ND){ + chemicalSummary <- chemicalSummary[chemicalSummary$EAR > 0,] + } + if(length(unique(chemicalSummary$Class)) > length(cbValues)){ n <- length(unique(chemicalSummary$Class)) if(n > 20 & n<30){ cbValues <- c(brewer.pal(n = 12, name = "Set3"), brewer.pal(n = 8, name = "Set2"), - brewer.pal(n = n-20, name = "Set1")) + brewer.pal(n = max(c(3,n-20)), name = "Set1")) } else if (n <= 20){ cbValues <- c(brewer.pal(n = 12, name = "Set3"), - brewer.pal(n = n-12, name = "Set2")) + brewer.pal(n = max(c(3,n-12)), name = "Set2")) } else { cbValues <- colorRampPalette(brewer.pal(11,"Spectral"))(n) } diff --git a/R/plot_group_boxplots.R b/R/plot_group_boxplots.R index be3523b1..1f009a49 100644 --- a/R/plot_group_boxplots.R +++ b/R/plot_group_boxplots.R @@ -5,6 +5,7 @@ #' @param category either "Biological", "Chemical Class", or "Chemical" #' @param manual_remove vector of categories to remove #' @param mean_logic logical \code{TRUE} is mean, \code{FALSE} is maximum +#' @param plot_ND logical whether or not to plot the non-detects #' @export #' @import ggplot2 #' @importFrom stats median @@ -35,7 +36,8 @@ plot_tox_boxplots <- function(chemicalSummary, category = "Biological", manual_remove = NULL, - mean_logic = FALSE){ + mean_logic = FALSE, + plot_ND = TRUE){ match.arg(category, c("Biological","Chemical Class","Chemical")) @@ -43,11 +45,14 @@ plot_tox_boxplots <- function(chemicalSummary, if(category == "Chemical"){ - chemPlot <- plot_chemical_boxplots(chemicalSummary, mean_logic = mean_logic) + chemPlot <- plot_chemical_boxplots(chemicalSummary, mean_logic = mean_logic, plot_ND = plot_ND) return(chemPlot) } else { + if(!plot_ND){ + chemicalSummary <- chemicalSummary[chemicalSummary$EAR > 0,] + } single_site <- length(unique(chemicalSummary$site)) == 1 bioPlot <- ggplot()+ diff --git a/R/plot_heat_chemical.R b/R/plot_heat_chemical.R index a0188d6c..41291059 100644 --- a/R/plot_heat_chemical.R +++ b/R/plot_heat_chemical.R @@ -98,6 +98,7 @@ plot_heat_chemicals <- function(graphData, chem_site){ #' @param category either "Biological", "Chemical Class", or "Chemical" #' @param manual_remove vector of categories to remove #' @param mean_logic logical \code{TRUE} is mean, \code{FALSE} is maximum +#' @param plot_ND logical whether or not to plot the non-detects #' @export #' @import ggplot2 #' @importFrom stats median @@ -157,12 +158,18 @@ plot_tox_heatmap <- function(chemicalSummary, chem_site, category = "Biological", manual_remove = NULL, - mean_logic = FALSE){ + mean_logic = FALSE, + plot_ND = TRUE){ match.arg(category, c("Biological","Chemical Class","Chemical")) SiteID <- site_grouping <- `Short Name` <- chnm <- maxEAR <- ".dplyr" site <- EAR <- sumEAR <- meanEAR <- ".dplyr" + + if(!plot_ND){ + chemicalSummary <- chemicalSummary[chemicalSummary$EAR > 0,] + } + if(category == "Chemical"){ graphData <- graph_chem_data(chemicalSummary, mean_logic=mean_logic) plot_back <- plot_heat_chemicals(graphData=graphData, chem_site=chem_site) diff --git a/inst/shiny/boxPlot.R b/inst/shiny/boxPlot.R index 49a79353..704a6b11 100644 --- a/inst/shiny/boxPlot.R +++ b/inst/shiny/boxPlot.R @@ -1,6 +1,8 @@ output$graphGroup <- renderPlot({ catType = as.numeric(input$radioMaxGroup) + + plot_ND = input$plot_ND chemicalSummary <- chemicalSummary() @@ -12,7 +14,8 @@ output$graphGroup <- renderPlot({ bioPlot <- plot_tox_boxplots(chemicalSummary, category = category, - mean_logic = as.logical(input$meanEAR)) + mean_logic = as.logical(input$meanEAR), + plot_ND = plot_ND) if(catType == 2){ ggsave("boxPlot.png", diff --git a/inst/shiny/heatMap.R b/inst/shiny/heatMap.R index e846afee..ac0d039b 100644 --- a/inst/shiny/heatMap.R +++ b/inst/shiny/heatMap.R @@ -3,7 +3,7 @@ output$graphHeat <- renderPlot({ validate( need(!is.null(input$data), "Please select a data set") ) - + plot_ND = input$plot_ND_heat catType = as.numeric(input$radioMaxGroup) chemicalSummary <- chemicalSummary() @@ -22,7 +22,8 @@ output$graphHeat <- renderPlot({ heatMap <- plot_tox_heatmap(chemicalSummary, chem_site, - category = c("Biological","Chemical","Chemical Class")[catType]) + category = c("Biological","Chemical","Chemical Class")[catType], + plot_ND = plot_ND) ggsave("heatPlot.png",heatMap,bg = "transparent") @@ -31,11 +32,9 @@ output$graphHeat <- renderPlot({ }) output$graphHeat.ui <- renderUI({ - # heightOfGraph <- 500 - # if(as.numeric(input$radioMaxGroup) == 2){ - # heightOfGraph <- 800 - # } - plotOutput("graphHeat", width = "100%") + height <- PlotHeight() + + plotOutput("graphHeat", height = height, width = 800) }) output$downloadHeatPlot <- downloadHandler( diff --git a/inst/shiny/ui.R b/inst/shiny/ui.R index 550581e4..41d5b228 100644 --- a/inst/shiny/ui.R +++ b/inst/shiny/ui.R @@ -140,8 +140,8 @@ body <- dashboardBody( ), tabPanel(title = tagList("Box Plots", shiny::icon("bar-chart")), value="summary", + checkboxInput("plot_ND", "Plot ND's?", TRUE), uiOutput("graphGroup.ui"), - # div(style = 'overflow-y: scroll', uiOutput("graphGroup.ui")), downloadButton('downloadBoxPlot', 'Download PNG') ), tabPanel(title = tagList("Bar Charts", shiny::icon("bar-chart")), @@ -176,6 +176,7 @@ body <- dashboardBody( ), tabPanel(title = tagList("Heat Map", shiny::icon("bar-chart")), value="heat", + checkboxInput("plot_ND_heat", "Plot ND's?", TRUE), uiOutput("graphHeat.ui"), downloadButton('downloadHeatPlot', 'Download PNG') ) diff --git a/man/plot_chemical_boxplots.Rd b/man/plot_chemical_boxplots.Rd index 80d791dd..c8b7714a 100644 --- a/man/plot_chemical_boxplots.Rd +++ b/man/plot_chemical_boxplots.Rd @@ -5,7 +5,7 @@ \title{plot_chemical_boxplots} \usage{ plot_chemical_boxplots(chemicalSummary, manual_remove = NULL, - mean_logic = FALSE) + mean_logic = FALSE, plot_ND = TRUE) } \arguments{ \item{chemicalSummary}{data frame from \code{graph_chem_data}} @@ -13,6 +13,8 @@ plot_chemical_boxplots(chemicalSummary, manual_remove = NULL, \item{manual_remove}{vector of categories to remove} \item{mean_logic}{logical \code{TRUE} is mean, \code{FALSE} is maximum} + +\item{plot_ND}{logical whether or not to plot the non-detects} } \description{ Plot boxplot of chemicals diff --git a/man/plot_tox_boxplots.Rd b/man/plot_tox_boxplots.Rd index 5fecf444..260a9c30 100644 --- a/man/plot_tox_boxplots.Rd +++ b/man/plot_tox_boxplots.Rd @@ -5,7 +5,7 @@ \title{plot_tox_boxplots} \usage{ plot_tox_boxplots(chemicalSummary, category = "Biological", - manual_remove = NULL, mean_logic = FALSE) + manual_remove = NULL, mean_logic = FALSE, plot_ND = TRUE) } \arguments{ \item{chemicalSummary}{data frame from \code{get_chemical_summary}} @@ -15,6 +15,8 @@ plot_tox_boxplots(chemicalSummary, category = "Biological", \item{manual_remove}{vector of categories to remove} \item{mean_logic}{logical \code{TRUE} is mean, \code{FALSE} is maximum} + +\item{plot_ND}{logical whether or not to plot the non-detects} } \description{ Plot boxplot of groups diff --git a/man/plot_tox_heatmap.Rd b/man/plot_tox_heatmap.Rd index 0acafc22..4453c2bf 100644 --- a/man/plot_tox_heatmap.Rd +++ b/man/plot_tox_heatmap.Rd @@ -5,7 +5,7 @@ \title{plot_tox_heatmap} \usage{ plot_tox_heatmap(chemicalSummary, chem_site, category = "Biological", - manual_remove = NULL, mean_logic = FALSE) + manual_remove = NULL, mean_logic = FALSE, plot_ND = TRUE) } \arguments{ \item{chemicalSummary}{data frame from \code{get_chemical_summary}} @@ -17,6 +17,8 @@ plot_tox_heatmap(chemicalSummary, chem_site, category = "Biological", \item{manual_remove}{vector of categories to remove} \item{mean_logic}{logical \code{TRUE} is mean, \code{FALSE} is maximum} + +\item{plot_ND}{logical whether or not to plot the non-detects} } \description{ Plot heat map