Skip to content

Commit

Permalink
Merge pull request #76 from ldecicco-USGS/master
Browse files Browse the repository at this point in the history
Dependency work
  • Loading branch information
ldecicco-USGS committed Aug 5, 2015
2 parents 9c3e7a1 + a2f5963 commit 81fb784
Show file tree
Hide file tree
Showing 20 changed files with 706 additions and 144 deletions.
14 changes: 7 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ Depends:
R (>= 3.0)
Imports:
dplyr,
tidyr
Suggests:
rmarkdown,
knitr,
testthat,
pander,
tidyr,
DT,
leaflet,
formattable,
ggplot2,
gridExtra,
grid,
shiny,
data.table,
RColorBrewer
Suggests:
rmarkdown,
testthat,
pander,
formattable,
knitr
VignetteBuilder: knitr
BuildVignettes: true
LazyLoad: yes
Expand Down
35 changes: 31 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,36 @@ export(chemSummBasic)
export(endPointInfo)
export(endPointSumm)
export(endPointToxCreate)
export(explore_endpoints)
export(siteSumm)
export(totalSamples)
import(dplyr)
importFrom(tidyr,gather)
importFrom(tidyr,gather_)
importFrom(tidyr,separate)
import(DT)
import(RColorBrewer)
import(data.table)
import(ggplot2)
import(grid)
import(gridExtra)
import(tidyr)
importFrom(dplyr,arrange)
importFrom(dplyr,desc)
importFrom(dplyr,distinct)
importFrom(dplyr,filter)
importFrom(dplyr,filter_)
importFrom(dplyr,group_by)
importFrom(dplyr,group_by_)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,mutate_)
importFrom(dplyr,rename)
importFrom(dplyr,rename_)
importFrom(dplyr,right_join)
importFrom(dplyr,select)
importFrom(dplyr,select_)
importFrom(dplyr,summarise)
importFrom(dplyr,summarize)
importFrom(leaflet,addCircles)
importFrom(leaflet,addLegend)
importFrom(leaflet,clearControls)
importFrom(leaflet,clearShapes)
importFrom(leaflet,leaflet)
importFrom(shiny,runApp)
7 changes: 1 addition & 6 deletions R/chemSumm.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#' @param classCol column name of chemical class
#' @param siteCol column name of site
#' @param dateCol column name of date
#' @import dplyr
#' @export
#' @examples
#' wData <- wData
Expand Down Expand Up @@ -73,10 +72,7 @@ chemSumm <- function(chemicalSummary,EAR.key="EAR",chnmCol="chnm",
#' @param code_pCode character name of code column in pCodeInfo
#' @param casrn_ep character name of class column in endPoint
#' @return chemicalSummary data frame
#' @import dplyr
#' @importFrom tidyr gather_
#' @importFrom tidyr gather
#' @importFrom tidyr separate
#' @import tidyr
#' @export
#' @examples
#' wData <- wData
Expand Down Expand Up @@ -114,7 +110,6 @@ chemSummBasic <- function(wData, pCodeInfoDF,endPoint,
#' @param units_pCode character name of units column in pCodeInfo
#' @param mlWt_pCode character name of molecular weight column in pCodeInfo
#' @return endPoint data frame
#' @import dplyr
#' @export
#' @examples
#' pCodeInfo <- pCodeInfo
Expand Down
3 changes: 2 additions & 1 deletion R/endPointSumm.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
#' @param endPointInfo dataframe
#' @param endPointInfo.Key column name of endpoint
#' @param EAR.key column name in chemicalSummary of EAR
#' @import dplyr
#' @export
#' @examples
#' \dontrun{
#' wData <- wData
#' pCodeInfo <- pCodeInfo
#' endPoint <- endPointToxCreate(pCodeInfo)
#' chemicalSummary <- chemSummBasic(wData,pCodeInfo,endPoint)
#' endPointInfo <- endPointInfo
#' epSumm <- endPointSumm(chemicalSummary, endPointInfo=endPointInfo)
#' }
endPointSumm <- function(chemicalSummary, chemicalSummary.Key="endPoint",chemicalSummary.site="site",
endPointInfo, endPointInfo.Key = "assay_component_endpoint_name",
EAR.key="EAR"){
Expand Down
22 changes: 22 additions & 0 deletions R/explore_endpoints.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#' Explore endpoint groupings
#'
#' Open an interactive app
#'
#' @param browse use browser for map rendering
#' @export
#' @importFrom shiny runApp
#' @importFrom leaflet leaflet
#' @importFrom leaflet addLegend
#' @importFrom leaflet addCircles
#' @importFrom leaflet clearControls
#' @importFrom leaflet clearShapes
#' @import tidyr
#' @import DT
#' @import ggplot2
#' @import data.table
#' @import RColorBrewer
#' @import grid
#' @import gridExtra
explore_endpoints <- function(browse=TRUE){
runApp(system.file('shiny', package='toxEval'), launch.browser = browse)
}
3 changes: 2 additions & 1 deletion R/siteSumm.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#'
#' @param chemicalSummary data frame returned from \code{chemSummBasic}
#' @param newSiteKey named vector
#' @import dplyr
#' @export
#' @examples
#' \dontrun{
#' wData <- wData
#' pCodeInfo <- pCodeInfo
#' packagePath <- system.file("extdata", package="toxEval")
Expand All @@ -16,6 +16,7 @@
#' endPoint <- endPointToxCreate(pCodeInfo)
#' chemicalSummary <- chemSummBasic(wData,pCodeInfo,endPoint)
#' siteSummary <- siteSumm(chemicalSummary,newSiteKey)
#' }
siteSumm <- function(chemicalSummary,newSiteKey){

siteSummary <- chemicalSummary %>%
Expand Down
1 change: 0 additions & 1 deletion R/totalSamples.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#' @param chemicalSummary data frame returned from \code{chemSummBasic}
#' @param chemicalSummary.Key character column name for grouping by (default = "endPoint")
#' @param chemicalSummary.site character column name for group by site
#' @import dplyr
#' @export
#' @examples
#' wData <- wData
Expand Down
17 changes: 17 additions & 0 deletions R/toxEval.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@
#'
#' @name toxEval-package
#' @docType package
#' @importFrom dplyr filter
#' @importFrom dplyr rename
#' @importFrom dplyr group_by
#' @importFrom dplyr summarize
#' @importFrom dplyr summarise
#' @importFrom dplyr select
#' @importFrom dplyr arrange
#' @importFrom dplyr distinct
#' @importFrom dplyr left_join
#' @importFrom dplyr right_join
#' @importFrom dplyr desc
#' @importFrom dplyr filter_
#' @importFrom dplyr rename_
#' @importFrom dplyr mutate
#' @importFrom dplyr group_by_
#' @importFrom dplyr select_
#' @importFrom dplyr mutate_
#' @author Steven Corsi \email{srcorsi@@usgs.gov}, Laura De Cicco \email{ldecicco@@usgs.gov}
#' @keywords ToxCast
NULL
Expand Down
37 changes: 13 additions & 24 deletions inst/doc/SummaryToxCast.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ library(leaflet)
library(formattable)
library(ggplot2)
library(gridExtra)
library(data.table)

pCodeInfo <- pCodeInfo
wData <- wData
Expand Down Expand Up @@ -119,7 +120,10 @@ chemicalSummary_passive <- passiveData %>%
select(-mlWt, -conversion, -casrn, -Units) %>%
gather(endPoint, endPointValue, -class, -site, -measuredValue, -chnm) %>%
filter(!is.na(endPointValue)) %>%
mutate(EAR=measuredValue/endPointValue)
mutate(EAR=measuredValue/endPointValue) %>%
mutate(hits = as.numeric(EAR > 0.1),
endPoint=as.character(endPoint)) %>%
filter(!is.na(EAR))

chemicalSummary_passive <- chemicalSummary_passive %>%
mutate(site=paste0("USGS-",gsub("[^0-9]", "", as.character(site))))%>%
Expand Down Expand Up @@ -220,18 +224,18 @@ datatable(chemSum2[,-6], rownames = FALSE,


chemSum3 <- chemicalSummary %>%
mutate(hits= as.numeric(EAR > 0.1)) %>%
group_by(chnm, class, site, endPoint) %>%
summarize(hits=as.numeric(any(hits > 0)),
maxEAR=max(EAR)) %>%
group_by(chnm, class, endPoint) %>%
summarize(freq=sum(hits)/n_distinct(site),
nSites=sum(hits),
maxEAR=max(maxEAR)) %>%
mutate(endPoint=as.character(endPoint))%>%
left_join(endPointInfo, by=c("endPoint"="assay_component_endpoint_name")) %>%
rename(assay_component_endpoint_name=endPoint) %>%
data.table() %>%
left_join(data.table(endPointInfo), by="assay_component_endpoint_name") %>%
select(chnm, maxEAR, freq, nSites,
endPoint, class, contains("intended_target_")) %>%
endPoint=assay_component_endpoint_name, class, contains("intended_target_")) %>%
rename(type=intended_target_type, type_sub=intended_target_type_sub,
family=intended_target_family, family_sub=intended_target_family_sub) %>%
select(-contains("intended_target_")) %>%
Expand All @@ -244,24 +248,9 @@ chemSum3 <- chemicalSummary %>%
formatRound(c("maxEAR", "freq"), digits = 2)


totalSamples_ep <- select(chemicalSummary,site,endPoint) %>%
distinct()%>%
group_by(endPoint) %>%
summarise(totalSites=n())%>%
mutate(endPoint=as.character(endPoint))
endpointSummary <- endPointSumm(chemicalSummary, endPointInfo=endPointInfo)

endpointSummary <- chemicalSummary %>%
mutate(hits= as.numeric(EAR > 0.1)) %>%
group_by(site, endPoint) %>%
summarize(hits=as.numeric(any(hits > 0)),
maxEAR=max(EAR)) %>%
group_by(endPoint) %>%
summarize(nSites=sum(hits),
maxEAR=max(maxEAR)) %>%
mutate(endPoint=as.character(endPoint))%>%
left_join(endPointInfo, by=c("endPoint"="assay_component_endpoint_name")) %>%
left_join(totalSamples_ep, by=c("endPoint")) %>%
mutate(freq=nSites/totalSites)%>%
endpointSummary <- endpointSummary %>%
select(endPoint, maxEAR, freq, nSites,
endPoint, contains("intended_target_")) %>%
rename(type=intended_target_type, type_sub=intended_target_type_sub,
Expand Down Expand Up @@ -394,8 +383,8 @@ datatable(chemSum2_passive_dt, rownames = FALSE,


chemSum3_passive <- chemicalSummary_passive %>%
group_by(chnm, class, site, endPoint) %>%
summarize(hits= as.numeric(any(EAR > 0.1))) %>%
# group_by(chnm, class, site, endPoint) %>%
# summarize(hits= as.numeric(any(EAR > 0.1))) %>%
group_by(chnm, class, endPoint) %>%
summarize(freq=sum(hits)/n_distinct(site),
nSites=sum(hits))
Expand Down
37 changes: 13 additions & 24 deletions inst/doc/SummaryToxCast.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ library(leaflet)
library(formattable)
library(ggplot2)
library(gridExtra)
library(data.table)
pCodeInfo <- pCodeInfo
wData <- wData
Expand Down Expand Up @@ -136,7 +137,10 @@ chemicalSummary_passive <- passiveData %>%
select(-mlWt, -conversion, -casrn, -Units) %>%
gather(endPoint, endPointValue, -class, -site, -measuredValue, -chnm) %>%
filter(!is.na(endPointValue)) %>%
mutate(EAR=measuredValue/endPointValue)
mutate(EAR=measuredValue/endPointValue) %>%
mutate(hits = as.numeric(EAR > 0.1),
endPoint=as.character(endPoint)) %>%
filter(!is.na(EAR))
chemicalSummary_passive <- chemicalSummary_passive %>%
mutate(site=paste0("USGS-",gsub("[^0-9]", "", as.character(site))))%>%
Expand Down Expand Up @@ -294,18 +298,18 @@ This table focuses on the individual endpoint/compound combinations and the prev
chemSum3 <- chemicalSummary %>%
mutate(hits= as.numeric(EAR > 0.1)) %>%
group_by(chnm, class, site, endPoint) %>%
summarize(hits=as.numeric(any(hits > 0)),
maxEAR=max(EAR)) %>%
group_by(chnm, class, endPoint) %>%
summarize(freq=sum(hits)/n_distinct(site),
nSites=sum(hits),
maxEAR=max(maxEAR)) %>%
mutate(endPoint=as.character(endPoint))%>%
left_join(endPointInfo, by=c("endPoint"="assay_component_endpoint_name")) %>%
rename(assay_component_endpoint_name=endPoint) %>%
data.table() %>%
left_join(data.table(endPointInfo), by="assay_component_endpoint_name") %>%
select(chnm, maxEAR, freq, nSites,
endPoint, class, contains("intended_target_")) %>%
endPoint=assay_component_endpoint_name, class, contains("intended_target_")) %>%
rename(type=intended_target_type, type_sub=intended_target_type_sub,
family=intended_target_family, family_sub=intended_target_family_sub) %>%
select(-contains("intended_target_")) %>%
Expand All @@ -318,24 +322,9 @@ chemSum3 <- chemicalSummary %>%
formatRound(c("maxEAR", "freq"), digits = 2)
totalSamples_ep <- select(chemicalSummary,site,endPoint) %>%
distinct()%>%
group_by(endPoint) %>%
summarise(totalSites=n())%>%
mutate(endPoint=as.character(endPoint))
endpointSummary <- endPointSumm(chemicalSummary, endPointInfo=endPointInfo)
endpointSummary <- chemicalSummary %>%
mutate(hits= as.numeric(EAR > 0.1)) %>%
group_by(site, endPoint) %>%
summarize(hits=as.numeric(any(hits > 0)),
maxEAR=max(EAR)) %>%
group_by(endPoint) %>%
summarize(nSites=sum(hits),
maxEAR=max(maxEAR)) %>%
mutate(endPoint=as.character(endPoint))%>%
left_join(endPointInfo, by=c("endPoint"="assay_component_endpoint_name")) %>%
left_join(totalSamples_ep, by=c("endPoint")) %>%
mutate(freq=nSites/totalSites)%>%
endpointSummary <- endpointSummary %>%
select(endPoint, maxEAR, freq, nSites,
endPoint, contains("intended_target_")) %>%
rename(type=intended_target_type, type_sub=intended_target_type_sub,
Expand Down Expand Up @@ -504,8 +493,8 @@ This table focuses on the individual endpoint/compound combinations, and the pre
chemSum3_passive <- chemicalSummary_passive %>%
group_by(chnm, class, site, endPoint) %>%
summarize(hits= as.numeric(any(EAR > 0.1))) %>%
# group_by(chnm, class, site, endPoint) %>%
# summarize(hits= as.numeric(any(EAR > 0.1))) %>%
group_by(chnm, class, endPoint) %>%
summarize(freq=sum(hits)/n_distinct(site),
nSites=sum(hits))
Expand Down
66 changes: 32 additions & 34 deletions inst/doc/SummaryToxCast.html

Large diffs are not rendered by default.

Loading

0 comments on commit 81fb784

Please sign in to comment.