Skip to content

Commit

Permalink
ToxicR 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wheelemw committed May 11, 2022
1 parent 0083b04 commit 13fba73
Show file tree
Hide file tree
Showing 110 changed files with 8,849 additions and 973 deletions.
16 changes: 0 additions & 16 deletions CHANGELOG.md

This file was deleted.

23 changes: 12 additions & 11 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
Package: ToxicR
Type: Package
Title: This package is for analyzing toxicology dose-response data.
Version: 22.01
Date: 2022-1-31
Title: Analyzing Toxicology Dose-Response Data in R
Version: 22.5
Date: 2022-05-31
Author: NIEHS-BCBB
Maintainer: Matt Wheeler <matt.wheeler@nih.gov>
Description: This package provides standard toxicology routines for analyzing
Description: Standard toxicology routines for analyzing
dose-response data, which include: dose-response analysis, trend tests,
and Bayesian sensitivity analyses.
and Bayesian sensitivity analyses. For more information,
go to the website <https://github.com/NIEHS/ToxicR>.
Depends:
R (>= 4.1.0)
License: MIT
License: MIT + file LICENSE
LazyData: true
Imports: Rcpp (>= 1.0.0), ggplot2 (>= 3.3.2), shiny (>= 1.5.0), plotly (>= 4.9.2.1),
Imports: Rcpp (>= 1.0.0), ggplot2 (>= 3.3.2), shiny (>= 1.5.0), coda (>= 0.19-4),
scales (>= 1.1.1), tidyverse (>= 1.3.0), forcats, ggridges (>= 0.5.3), doBy (>= 4.6.11),
modules , multcomp (>= 1.4), VIM (>= 6.1.1), gridExtra (>= 2.3), knitr (>= 1.36),
dplyr (>= 1.0.7), ggpubr (>= 0.4.0), bibtex (>= 0.4.2.3), testthat (>= 3.1.0), actuar (>= 3.2-0)
Include: RcppEigen, RcppGSL
multcomp (>= 1.4), dplyr (>= 1.0.7)
LinkingTo: Rcpp, RcppEigen, RcppGSL
RoxygenNote: 7.1.2
VignetteBuilder: knitr
Suggests:
rmarkdown
rmarkdown, actuar (>= 3.2-0),ggpubr (>= 0.4.0), testthat (>= 3.1.0),gridExtra (>= 2.3),
VIM (>= 6.1.1), knitr (>= 1.36), modules, plotly (>= 4.9.2.1)

4 changes: 1 addition & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
MIT License

Copyright (c) 2022 Matthew Wheeler
Copyright (c) 2022 <NIEHS matt.wheeler@nih.gov>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
41 changes: 34 additions & 7 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ importFrom(forcats,fct_reorder)
# Necessary Packages
###############################
import(tidyverse)
#importFrom(doBy, summaryBy)
import(doBy)

importFrom(doBy, summaryBy)
#import(doBy)
import(multcomp)
import(shiny)
import(scales)
import(ggplot2)
import(dplyr)
importFrom(dplyr,"filter","%>%","select","mutate")



importFrom("stats", "aov", "as.formula", "coefficients", "cor.test",
"density", "lm", "pchisq", "pgamma", "pnorm", "qnorm",
"quantile", "sd", "splinefun", "var")

# Added two additional package 2012/12/08 SL
import(ggridges)
Expand All @@ -22,17 +29,37 @@ import(ggridges)
#register all of the S3 methods for the print commands
#and the plot commands etc.

S3method(print, BMD_Bayes_dichotomous_model, .print.BMD_Bayes_model)
S3method(print, BMD_Bayes_continuous_model, .print.BMD_Bayes_model)
S3method(print, BMD_CDF, .print.BMD_CDF)
S3method(print, BMDdich_fit, .print.BMDdich_fit)
#S3method(print, BMD_Bayes_dichotomous_model, .print.BMD_Bayes_model)
#S3method(print, BMD_Bayes_continuous_model, .print.BMD_Bayes_model)
#S3method(print, BMD_CDF, .print.BMD_CDF)
#S3method(print, BMDdich_fit, .print.BMDdich_fit)

# Summary Methods
S3method(summary, BMDcont_fit_maximized ,.summary_continuous_max)
S3method(print,summary_continuous_max ,.print_summary_continuous_max)
S3method(summary, BMDdich_fit_maximized ,.summary_dichotomous_max)
S3method(print,summary_dichotomous_max ,.print_summary_dichotomous_max)

S3method(summary,BMDcont_fit_MCMC , .summary_continuous_mcmc)
S3method(summary,BMDdich_fit_MCMC , .summary_continuous_mcmc)
S3method(print,summary_mcmc , .print_summary_continuous_mcmc)

S3method(summary,BMDcontinuous_MA_laplace , .summary_ma_max)
S3method(summary,BMDdichotomous_MA_laplace , .summary_ma_max)
S3method(print,ma_summary_max,.print_summary_ma_max )

S3method(summary , ntp.shirley, .summary_ntpshirley)
S3method(summary , ntp.williams, .summary_ntpwilliams)
S3method(summary , ntp.dunn, .summary_ntpdunn)
S3method(summary , ntp.dunnett, .summary_ntpdunnett)
#Predict Methods

S3method(predict,BMDdich_fit_maximized, .dichotomous_predict_model)
S3method(predict,BMDcont_fit_maximized, .continuous_predict_model)
S3method(predict,BMDcont_fit_MCMC, .continuous_predict_model_mcmc)
S3method(predict,BMDdich_fit_MCMC, .dichotomous_predict_model_mcmc)


# Base plot for single case

S3method(plot, BMDdich_fit_MCMC, .plot.BMDdich_fit_MCMC)
Expand Down
32 changes: 31 additions & 1 deletion R/Build_Priors.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
#OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

parse_prior<-function(prior){
.parse_prior<-function(prior){
rV <-list()
rV$prior <- prior$prior

Expand All @@ -33,6 +33,23 @@ parse_prior<-function(prior){

}

#' @title create_continuous_prior Given priorlist, a model,
#' and a distribution. Create a prior for a given analysis.
#' @param prior_list First Prior
#' @param model Model to be used
#' @param distribution - Normal "normal", Normal non-constant variance "normal-ncv", or
#' log-normal "lognormal"
#' @param deg - For polynomial models only, the degree of the polynomial.
#' @return new BMDprior list.
#'
#' @examples
#' plist<- create_prior_list(normprior(0,0.1,-100,100), # a
#' normprior(0,1, -1e2,1e2), # b
#' lnormprior(1,0.2,0,18), #k
#' normprior(0,1,-18,18))
#'
#' power_normal <- create_continuous_prior(plist,"power","normal")
#'
create_continuous_prior <- function( prior_list,model,distribution,deg=2){

if (class(prior_list) != "BMDmodelprior"){
Expand Down Expand Up @@ -376,6 +393,19 @@ create_continuous_prior <- function( prior_list,model,distribution,deg=2){
return(prior)
}


#' @title create_dichotomous_prior Given priorlist, a model,
#' and a distribution. Create a prior for a given analysis.
#' @param prior First Prior
#' @param model Model to be used should be one of"hill","gamma","logistic","log-logistic","log-probit","multistage", "probit", "qlinear", or "weibull"
#' @return new BMDprior list that can be used in a dichotomous fit.
#'
#' @examples
#' plist<- create_prior_list(normprior(0,0.1,-100,100), # a
#' lnormprior(1,0.2,0,18))
#'
#' power_normal <- create_dichotomous_prior(plist,"logistic")
#'
create_dichotomous_prior <- function(prior,model){

if (class(prior) != "BMDmodelprior"){
Expand Down
23 changes: 14 additions & 9 deletions R/MAdensity_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@
#' @param A the model averaged model to plot
#' @examples
#' \dontrun{
#' model <- ma_continuous_fit(doses,y,model_list=model_list,
#' doses <- cbind(c(0,25,50,100,200))
#' y <- cbind(c(6,5.2,2.4,1.1,0.75),
#' c(20,20,19,20,20),
#' c(1.2,1.1,0.81,0.74,0.66))
#' model <- ma_continuous_fit(doses,y,
#' fit_type = "mcmc",BMD_TYPE = 'sd',BMR = 1)
#' MAdensity_plot(model)
#' }
#' @export
MAdensity_plot <- function (A, ...){
MAdensity_plot <- function (A){
#source("dicho_functions.R")
UseMethod("MAdensity_plot")
}

# Sample Dichotomous Data set

.plot.density.BMDdichotomous_MA_MCMC<-function(A){
# Construct bmd sample plots for mcmc
X1 <- X2 <- X3 <- NULL
class_list <- names(A)
fit_idx <- grep("Individual_Model",class_list)
qprob=0.05
Expand Down Expand Up @@ -257,7 +261,7 @@ MAdensity_plot <- function (A, ...){
# No we don't need this part

.plot.density.BMDdichotomous_MA_maximized<-function(A){

t_1 <- t_2 <- t_3 <- t_4 <- t_5 <- t_6 <- t_7 <- t_8 <- t_9 <- c3 <- X1 <- X2 <- X3 <- NULL
class_list <- names(A)

if (class(A)[2]=="BMDdichotomous_MA_maximized"){
Expand Down Expand Up @@ -384,6 +388,7 @@ MAdensity_plot <- function (A, ...){

.plot.density.BMDcontinous_MA_MCMC<-function(A){
# Construct bmd sample plots for mcmc
X1 <- X2 <- X3 <- NULL
class_list <- names(A)
fit_idx <- grep("Individual_Model",class_list)
qprob=0.05
Expand All @@ -406,23 +411,23 @@ MAdensity_plot <- function (A, ...){


if (fit$model=="hill"){
Q <- apply(fit$mcmc_result$PARM_samples,1,cont_hill_f, d=test_doses)
Q <- apply(fit$mcmc_result$PARM_samples,1,.cont_hill_f, d=test_doses)

}
if (fit$model=="exp-3"){
Q <- apply(fit$mcmc_result$PARM_samples,1,cont_exp_3_f, d=test_doses)
Q <- apply(fit$mcmc_result$PARM_samples,1,.cont_exp_3_f, d=test_doses)

}
if (fit$model=="exp-5"){
Q <- apply(fit$mcmc_result$PARM_samples,1,cont_exp_5_f, d=test_doses)
Q <- apply(fit$mcmc_result$PARM_samples,1,.cont_exp_5_f, d=test_doses)

}
if (fit$model=="power"){
Q <- apply(fit$mcmc_result$PARM_samples,1,cont_power_f, d=test_doses)
Q <- apply(fit$mcmc_result$PARM_samples,1,.cont_power_f, d=test_doses)

}
if (fit$model=="FUNL"){
Q <- apply(fit$mcmc_result$PARM_samples,1,cont_FUNL_f, d=test_doses)
Q <- apply(fit$mcmc_result$PARM_samples,1,.cont_FUNL_f, d=test_doses)

}

Expand Down
Loading

0 comments on commit 13fba73

Please sign in to comment.