Title: | Spatiotemporal Mixture Risk Assessment |
---|---|
Description: | Connecting spatiotemporal exposure to individual and population-level risk via source-to-outcome continuum modeling. The package, methods, and case-studies are described in Messier, Reif, and Marvel (2024) <doi:10.1101/2024.09.23.24314096> and Eccles et al. (2023) <doi:10.1016/j.scitotenv.2022.158905>. |
Authors: | Skylar Marvel [aut] , David Reif [aut] , Kyle Messier [cre, aut] , Spatiotemporal Exposures and Toxicology Group [cph] |
Maintainer: | Kyle Messier <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.0.9000 |
Built: | 2024-11-19 19:29:30 UTC |
Source: | https://github.com/niehs/geotox |
Calculate the combined response of multiple chemicals. It calculates the generalized concentration addition response, the independent action response, and a hazard quotient
calc_concentration_response( C_invitro, hill_params, max_mult = 1.5, fixed = FALSE )
calc_concentration_response( C_invitro, hill_params, max_mult = 1.5, fixed = FALSE )
C_invitro |
in vitro concentrations |
hill_params |
output from |
max_mult |
upper bound multiplier for max response |
fixed |
if TRUE, sd = 0 |
list of data frames
C_invitro <- list( matrix(1:8 / 1e3, ncol = 2, dimnames = list(NULL, c("c1", "c2"))), matrix(9:16 / 1e3, ncol = 2, dimnames = list(NULL, c("c1", "c2"))) ) hill_params <- fit_hill( data.frame(chem = rep(c("c1", "c2"), each = 3), logc = c(-1, 0, 1, 0, 1, 2), resp = c(10, 5, 0, 4, 2, 0) / 10), chem = "chem" ) calc_concentration_response(C_invitro, hill_params) calc_concentration_response(C_invitro, hill_params, fixed = TRUE)
C_invitro <- list( matrix(1:8 / 1e3, ncol = 2, dimnames = list(NULL, c("c1", "c2"))), matrix(9:16 / 1e3, ncol = 2, dimnames = list(NULL, c("c1", "c2"))) ) hill_params <- fit_hill( data.frame(chem = rep(c("c1", "c2"), each = 3), logc = c(-1, 0, 1, 0, 1, 2), resp = c(10, 5, 0, 4, 2, 0) / 10), chem = "chem" ) calc_concentration_response(C_invitro, hill_params) calc_concentration_response(C_invitro, hill_params, fixed = TRUE)
Calculate independent action response for a set of chemicals with Hill concentration-response curves.
calc_independent_action(conc, max, AC50, Emax, n = 1)
calc_independent_action(conc, max, AC50, Emax, n = 1)
conc |
concentrations in regular space |
max |
maximal (asymptotic) responses |
AC50 |
concentrations of half-maximal response |
Emax |
maximum mixture response |
n |
Hill coefficients (slopes) |
The concentration is computed as:
where is the Hill model
response function for each chemical.
response value
n_chem <- 5 conc <- 10^sample(-1:4, n_chem, replace = TRUE) max <- 80 * runif(n_chem) AC50 <- 10^(5 * runif(n_chem) - 1) Emax <- 100 calc_independent_action(conc, max, AC50, Emax)
n_chem <- 5 conc <- 10^sample(-1:4, n_chem, replace = TRUE) max <- 80 * runif(n_chem) AC50 <- 10^(5 * runif(n_chem) - 1) Emax <- 100 calc_independent_action(conc, max, AC50, Emax)
Estimate the internal dose from inhalation of a chemical given inhalation rate, time, and body weight
calc_internal_dose(C_ext, IR, time = 1, BW = 1, scaling = 1)
calc_internal_dose(C_ext, IR, time = 1, BW = 1, scaling = 1)
C_ext |
ambient chemical concentration in |
IR |
inhalation rate in |
time |
total time in |
BW |
body weight in |
scaling |
scaling factor encompassing any required unit adjustments |
Input C_ext
must be a matrix or list of matrices. Input IR
must be an
atomic vector or list of atomic vectors. The time
, BW
and scaling
arguments are scalars.
The internal dose is calculated as:
list of matrices containing internal chemical doses in
# Single population C_ext <- matrix(1:15, ncol = 3) IR <- 1:5 calc_internal_dose(C_ext, IR) # Multiple populations C_ext <- list( "a" = matrix(1:15 / 10, ncol = 3), "b" = matrix(1:8, ncol = 2) ) IR <- list(1:5, 1:4 / 2) calc_internal_dose(C_ext, IR)
# Single population C_ext <- matrix(1:15, ncol = 3) IR <- 1:5 calc_internal_dose(C_ext, IR) # Multiple populations C_ext <- list( "a" = matrix(1:15 / 10, ncol = 3), "b" = matrix(1:8, ncol = 2) ) IR <- list(1:5, 1:4 / 2) calc_internal_dose(C_ext, IR)
Estimate the in vitro equivalent plasma concentration given internal chemical dose and steady-state plasma concentration.
calc_invitro_concentration(D_int, C_ss = NULL)
calc_invitro_concentration(D_int, C_ss = NULL)
D_int |
internal chemical dose in |
C_ss |
steady-state plasma concentration in |
Input D_int
must be a matrix or list of matrices. Input C_ss
must be a
numeric atomic vector or matrix, or a list of those types.
The in vitro equivalent plasma concentration is calculated as:
list of matrices containing concentrations in
# Single population D_int <- matrix(1:15, ncol = 3) C_ss <- 1:5 calc_invitro_concentration(D_int, C_ss) # Multiple populations D_int <- list( "a" = matrix(1:15 / 10, ncol = 3), "b" = matrix(1:8, ncol = 2) ) C_ss <- list(1:5, 1:4 / 2) calc_invitro_concentration(D_int, C_ss)
# Single population D_int <- matrix(1:15, ncol = 3) C_ss <- 1:5 calc_invitro_concentration(D_int, C_ss) # Multiple populations D_int <- list( "a" = matrix(1:15 / 10, ncol = 3), "b" = matrix(1:8, ncol = 2) ) C_ss <- list(1:5, 1:4 / 2) calc_invitro_concentration(D_int, C_ss)
Calculate mixture response for GeoTox population data
calculate_response(x, ...)
calculate_response(x, ...)
x |
GeoTox object |
... |
additional arguments passed to other functions. See details. |
Additional parameters include time
, BW
, and scaling
for
calc_internal_dose, and max_mult
for calc_concentration_response.
The same object with additional fields added or updated
calc_internal_dose, calc_invitro_concentration, calc_concentration_response
# Use a subset of the package data for demonstration purposes set.seed(2357) n <- 10 # Population size m <- 5 # Number of regions idx <- if (m < 100) sample(1:100, m) else 1:100 # Create GeoTox object and populate required fields geoTox <- GeoTox() |> # Simulate populations for each region simulate_population(age = split(geo_tox_data$age, ~FIPS)[idx], obesity = geo_tox_data$obesity[idx, ], exposure = split(geo_tox_data$exposure, ~FIPS)[idx], simulated_css = geo_tox_data$simulated_css, n = n) |> # Estimated Hill parameters set_hill_params(geo_tox_data$dose_response |> fit_hill(assay = "endp", chem = "casn") |> dplyr::filter(!tp.sd.imputed, !logAC50.sd.imputed)) # Response computations can now be done geoTox <- geoTox |> calculate_response()
# Use a subset of the package data for demonstration purposes set.seed(2357) n <- 10 # Population size m <- 5 # Number of regions idx <- if (m < 100) sample(1:100, m) else 1:100 # Create GeoTox object and populate required fields geoTox <- GeoTox() |> # Simulate populations for each region simulate_population(age = split(geo_tox_data$age, ~FIPS)[idx], obesity = geo_tox_data$obesity[idx, ], exposure = split(geo_tox_data$exposure, ~FIPS)[idx], simulated_css = geo_tox_data$simulated_css, n = n) |> # Estimated Hill parameters set_hill_params(geo_tox_data$dose_response |> fit_hill(assay = "endp", chem = "casn") |> dplyr::filter(!tp.sd.imputed, !logAC50.sd.imputed)) # Response computations can now be done geoTox <- geoTox |> calculate_response()
Compute response sensitivity to parameter variation.
compute_sensitivity( x, vary = c("age", "obesity", "css_params", "fit_params", "C_ext"), max_mult = NULL )
compute_sensitivity( x, vary = c("age", "obesity", "css_params", "fit_params", "C_ext"), max_mult = NULL )
x |
GeoTox object. |
vary |
which parameter to vary. |
max_mult |
input for calc_concentration_response step. |
output from calc_concentration_response
# Use a subset of the package data for demonstration purposes set.seed(2357) n <- 10 # Population size m <- 5 # Number of regions idx <- if (m < 100) sample(1:100, m) else 1:100 # Create GeoTox object and populate required fields geoTox <- GeoTox() |> # Simulate populations for each region simulate_population(age = split(geo_tox_data$age, ~FIPS)[idx], obesity = geo_tox_data$obesity[idx, ], exposure = split(geo_tox_data$exposure, ~FIPS)[idx], simulated_css = geo_tox_data$simulated_css, n = n) |> # Estimated Hill parameters set_hill_params(geo_tox_data$dose_response |> fit_hill(assay = "endp", chem = "casn") |> dplyr::filter(!tp.sd.imputed, !logAC50.sd.imputed)) # Sensitivity computations can now be done age_resp <- geoTox |> compute_sensitivity() obesity_resp <- geoTox |> compute_sensitivity(vary = "obesity")
# Use a subset of the package data for demonstration purposes set.seed(2357) n <- 10 # Population size m <- 5 # Number of regions idx <- if (m < 100) sample(1:100, m) else 1:100 # Create GeoTox object and populate required fields geoTox <- GeoTox() |> # Simulate populations for each region simulate_population(age = split(geo_tox_data$age, ~FIPS)[idx], obesity = geo_tox_data$obesity[idx, ], exposure = split(geo_tox_data$exposure, ~FIPS)[idx], simulated_css = geo_tox_data$simulated_css, n = n) |> # Estimated Hill parameters set_hill_params(geo_tox_data$dose_response |> fit_hill(assay = "endp", chem = "casn") |> dplyr::filter(!tp.sd.imputed, !logAC50.sd.imputed)) # Sensitivity computations can now be done age_resp <- geoTox |> compute_sensitivity() obesity_resp <- geoTox |> compute_sensitivity(vary = "obesity")
Fit 2- or 3-parameter Hill model
fit_hill( x, conc = "logc", resp = "resp", fixed_slope = TRUE, chem = NULL, assay = NULL )
fit_hill( x, conc = "logc", resp = "resp", fixed_slope = TRUE, chem = NULL, assay = NULL )
x |
data frame of dose response data. |
conc |
column name of base-10 log scaled concentration. |
resp |
column name of response. |
fixed_slope |
if TRUE, slope is fixed at 1. |
chem |
(optional) column name of chemical identifiers. |
assay |
(optional) column name of assay identifiers. |
Optional chem
and assay
identifiers can be used to fit multiple
chemicals and/or assays. Returned columns tp
is the top asymptote and
logAC50
is the 50% response concentration. If the computation of the
standard deviations of these two parameters fails, then the standard
deviation is set equal to the parameter estimate and is indicated by the
respective imputed flag being TRUE.
data frame of fit parameters.
# Multiple assays, multiple chemicals df <- geo_tox_data$dose_response fit_hill(df, assay = "endp", chem = "casn") # Single assay, multiple chemicals df <- geo_tox_data$dose_response |> dplyr::filter(endp == "TOX21_H2AX_HTRF_CHO_Agonist_ratio") fit_hill(df, chem = "casn") # Single assay, single chemical df <- geo_tox_data$dose_response |> dplyr::filter(endp == "TOX21_H2AX_HTRF_CHO_Agonist_ratio", casn == "510-15-6") fit_hill(df) # 3-parameter Hill model fit_hill(df, fixed_slope = FALSE)
# Multiple assays, multiple chemicals df <- geo_tox_data$dose_response fit_hill(df, assay = "endp", chem = "casn") # Single assay, multiple chemicals df <- geo_tox_data$dose_response |> dplyr::filter(endp == "TOX21_H2AX_HTRF_CHO_Agonist_ratio") fit_hill(df, chem = "casn") # Single assay, single chemical df <- geo_tox_data$dose_response |> dplyr::filter(endp == "TOX21_H2AX_HTRF_CHO_Agonist_ratio", casn == "510-15-6") fit_hill(df) # 3-parameter Hill model fit_hill(df, fixed_slope = FALSE)
Sample data for use in vignettes and function examples. See the Package
Data vignette, vignette("package_data", package = "GeoTox")
, for
details on how this data was gathered.
geo_tox_data
geo_tox_data
A list with items:
2019 AirToxScreen exposure concentrations for a subset of chemicals in North Carolina counties.
Subset of chemicals curated by ICE cHTS as active within a set of assays.
County population estimates for 7/1/2019 in North Carolina.
CDC PLACES obesity data for North Carolina counties in 2020.
Simulated steady-state plasma concentrations for various age groups and obesity status combinations.
County and state boundaries for North Carolina in 2019.
An S3 object that can be used to help organize the data and results of a GeoTox analysis.
GeoTox() ## S3 method for class 'GeoTox' plot(x, type = c("resp", "hill", "exposure", "sensitivity"), ...)
GeoTox() ## S3 method for class 'GeoTox' plot(x, type = c("resp", "hill", "exposure", "sensitivity"), ...)
x |
GeoTox object. |
type |
type of plot. |
... |
arguments passed to subsequent methods. |
a GeoTox S3 object
plot_resp, plot_hill, plot_exposure, plot_sensitivity
# Use a subset of the package data for demonstration purposes set.seed(2357) n <- 10 # Population size m <- 5 # Number of regions idx <- if (m < 100) sample(1:100, m) else 1:100 geoTox <- GeoTox() |> # Set region and group boundaries (for plotting) set_boundaries(region = geo_tox_data$boundaries$county, group = geo_tox_data$boundaries$state) |> # Simulate populations for each region simulate_population(age = split(geo_tox_data$age, ~FIPS)[idx], obesity = geo_tox_data$obesity[idx, ], exposure = split(geo_tox_data$exposure, ~FIPS)[idx], simulated_css = geo_tox_data$simulated_css, n = n) |> # Estimated Hill parameters set_hill_params(geo_tox_data$dose_response |> fit_hill(assay = "endp", chem = "casn") |> dplyr::filter(!tp.sd.imputed, !logAC50.sd.imputed)) |> # Calculate response calculate_response() |> # Perform sensitivity analysis sensitivity_analysis() # Print GeoTox object geoTox # Plot hill fits plot(geoTox, type = "hill") # Plot exposure data plot(geoTox, type = "exposure", ncol = 5) # Plot response data plot(geoTox) plot(geoTox, assays = "TOX21_H2AX_HTRF_CHO_Agonist_ratio") # Plot sensitivity data plot(geoTox, type = "sensitivity") plot(geoTox, type = "sensitivity", assay = "TOX21_H2AX_HTRF_CHO_Agonist_ratio")
# Use a subset of the package data for demonstration purposes set.seed(2357) n <- 10 # Population size m <- 5 # Number of regions idx <- if (m < 100) sample(1:100, m) else 1:100 geoTox <- GeoTox() |> # Set region and group boundaries (for plotting) set_boundaries(region = geo_tox_data$boundaries$county, group = geo_tox_data$boundaries$state) |> # Simulate populations for each region simulate_population(age = split(geo_tox_data$age, ~FIPS)[idx], obesity = geo_tox_data$obesity[idx, ], exposure = split(geo_tox_data$exposure, ~FIPS)[idx], simulated_css = geo_tox_data$simulated_css, n = n) |> # Estimated Hill parameters set_hill_params(geo_tox_data$dose_response |> fit_hill(assay = "endp", chem = "casn") |> dplyr::filter(!tp.sd.imputed, !logAC50.sd.imputed)) |> # Calculate response calculate_response() |> # Perform sensitivity analysis sensitivity_analysis() # Print GeoTox object geoTox # Plot hill fits plot(geoTox, type = "hill") # Plot exposure data plot(geoTox, type = "exposure", ncol = 5) # Plot response data plot(geoTox) plot(geoTox, assays = "TOX21_H2AX_HTRF_CHO_Agonist_ratio") # Plot sensitivity data plot(geoTox, type = "sensitivity") plot(geoTox, type = "sensitivity", assay = "TOX21_H2AX_HTRF_CHO_Agonist_ratio")
C_ss
Data for Fixed AgeGet C_ss
Data for Fixed Age
get_fixed_age(simulated_css, age)
get_fixed_age(simulated_css, age)
simulated_css |
list of pre-generated |
age |
list of atomic vectors containing ages. |
list of matrices containing median C_ss
values.
get_fixed_age(simulated_css = geo_tox_data$simulated_css, age = list(c(25, 35, 55), c(15, 60)))
get_fixed_age(simulated_css = geo_tox_data$simulated_css, age = list(c(25, 35, 55), c(15, 60)))
C_ss
DataGet C_ss
values for use in sensitivity_analysis and compute_sensitivity.
get_fixed_css(simulated_css, age, obesity, C_ss)
get_fixed_css(simulated_css, age, obesity, C_ss)
simulated_css |
list of pre-generated |
age |
list of atomic vectors containing ages. |
obesity |
list of atomic vectors containing obesity status. |
C_ss |
list of matrices containing |
list of matrices or atomic vectors containing C_ss
values.
# Define inputs age <- list(c(25, 35, 55), c(15, 60)) obesity <- list(c("Obese", "Normal", "Obese"), c("Normal", "Normal")) C_ss <- sample_Css(simulated_css = geo_tox_data$simulated_css, age = age, obesity = obesity) # Get fixed C_ss data get_fixed_css(simulated_css = geo_tox_data$simulated_css, age = age, obesity = obesity, C_ss = C_ss)
# Define inputs age <- list(c(25, 35, 55), c(15, 60)) obesity <- list(c("Obese", "Normal", "Obese"), c("Normal", "Normal")) C_ss <- sample_Css(simulated_css = geo_tox_data$simulated_css, age = age, obesity = obesity) # Get fixed C_ss data get_fixed_css(simulated_css = geo_tox_data$simulated_css, age = age, obesity = obesity, C_ss = C_ss)
C_ss
Data for Fixed Obesity StatusGet C_ss
Data for Fixed Obesity Status
get_fixed_obesity(simulated_css, obesity)
get_fixed_obesity(simulated_css, obesity)
simulated_css |
list of pre-generated |
obesity |
list of atomic vectors containing obesity status. |
list of matrices containing median C_ss
values.
get_fixed_obesity(simulated_css = geo_tox_data$simulated_css, obesity = list(c("Obese", "Normal", "Obese"), c("Normal", "Normal")))
get_fixed_obesity(simulated_css = geo_tox_data$simulated_css, obesity = list(c("Obese", "Normal", "Obese"), c("Normal", "Normal")))
C_ss
ValuesGet median C_ss
Values
get_fixed_other(C_ss)
get_fixed_other(C_ss)
C_ss |
list of matrices containing |
list of atomic vectors containing median C_ss
values.
# Generate input C_ss data age <- list(c(25, 35, 55), c(15, 60)) obesity <- list(c("Obese", "Normal", "Obese"), c("Normal", "Normal")) C_ss <- sample_Css(simulated_css = geo_tox_data$simulated_css, age = age, obesity = obesity) # Get median C_ss values get_fixed_other(C_ss)
# Generate input C_ss data age <- list(c(25, 35, 55), c(15, 60)) obesity <- list(c("Obese", "Normal", "Obese"), c("Normal", "Normal")) C_ss <- sample_Css(simulated_css = geo_tox_data$simulated_css, age = age, obesity = obesity) # Get median C_ss values get_fixed_other(C_ss)
C_ss
Data for Fixed C_ss
Generation ParametersGet C_ss
Data for Fixed C_ss
Generation Parameters
get_fixed_params(simulated_css, age)
get_fixed_params(simulated_css, age)
simulated_css |
list of pre-generated |
age |
list of atomic vectors containing ages. |
list of matrices containing C_ss
values.
get_fixed_params(simulated_css = geo_tox_data$simulated_css, age = list(c(25, 35, 55), c(15, 60)))
get_fixed_params(simulated_css = geo_tox_data$simulated_css, age = list(c(25, 35, 55), c(15, 60)))
Calculate the concentration in regular space for a given response value.
hill_conc(resp, max, AC50, n)
hill_conc(resp, max, AC50, n)
resp |
response value |
max |
maximal (asymptotic) response |
AC50 |
concentration of half-maximal response |
n |
Hill coefficient (slope) |
This is a regular space version of tcpl::tcplHillConc().
The concentration is computed as:
concentration in regular space
hill_conc(c(0.2, 0.5, 0.75), 1, 0.01, 1) hill_conc(c(0.2, 0.5, 0.9), 1, c(0.1, 0.01, 0.001), 2)
hill_conc(c(0.2, 0.5, 0.75), 1, 0.01, 1) hill_conc(c(0.2, 0.5, 0.9), 1, c(0.1, 0.01, 0.001), 2)
Calculate the response for a given concentration in regular space.
hill_val(conc, max, AC50, n)
hill_val(conc, max, AC50, n)
conc |
concentration in regular space |
max |
maximal (asymptotic) response |
AC50 |
concentration of half-maximal response |
n |
Hill coefficient (slope) |
This is a regular space version of tcpl::tcplHillVal().
The Hill model is defined as:
response value
hill_val(c(0.0025, 0.01, 0.03), 1, 0.01, 1) hill_val(c(0.05, 0.01, 0.003), 1, c(0.1, 0.01, 0.001), 2)
hill_val(c(0.0025, 0.01, 0.03), 1, 0.01, 1) hill_val(c(0.05, 0.01, 0.003), 1, c(0.1, 0.01, 0.001), 2)
Plot exposure data.
plot_exposure( exposure, region_boundary, group_boundary = NULL, chem_label = "chnm", ncol = 2 )
plot_exposure( exposure, region_boundary, group_boundary = NULL, chem_label = "chnm", ncol = 2 )
exposure |
list of exposure data named by region label. |
region_boundary |
"sf" data.frame mapping features to a "geometry" column. Used to color regions. |
group_boundary |
(optional) "sf" data.frame containing a "geometry" column. Used to draw outlines. |
chem_label |
label for facet_wrap. |
ncol |
number of columns to wrap. |
ggplot2 object.
# Load package data exposure <- split(geo_tox_data$exposure, ~FIPS) region_boundary <- geo_tox_data$boundaries$county group_boundary <- geo_tox_data$boundaries$state # Plot county exposure data # Use CASN as label to avoid long chemical names plot_exposure(exposure, region_boundary, chem_label = "casn", ncol = 5) # Add state boundaries plot_exposure(exposure, region_boundary, group_boundary = group_boundary, chem_label = "casn", ncol = 5)
# Load package data exposure <- split(geo_tox_data$exposure, ~FIPS) region_boundary <- geo_tox_data$boundaries$county group_boundary <- geo_tox_data$boundaries$state # Plot county exposure data # Use CASN as label to avoid long chemical names plot_exposure(exposure, region_boundary, chem_label = "casn", ncol = 5) # Add state boundaries plot_exposure(exposure, region_boundary, group_boundary = group_boundary, chem_label = "casn", ncol = 5)
Plot Hill equation fits.
plot_hill(hill_params, xlim = c(-1, 4))
plot_hill(hill_params, xlim = c(-1, 4))
hill_params |
output from |
xlim |
log-10 scaled concentration limits. |
ggplot2 object.
# Multiple assays, multiple chemicals df <- geo_tox_data$dose_response plot_hill(fit_hill(df, assay = "endp", chem = "casn")) # Single assay, multiple chemicals df <- geo_tox_data$dose_response |> dplyr::filter(endp == "TOX21_H2AX_HTRF_CHO_Agonist_ratio") fig <- plot_hill(fit_hill(df, chem = "casn")) fig # Modify plot fig + ggplot2::guides(color = ggplot2::guide_legend(title = "Chemical\nCASN")) # Single assay, single chemical df <- geo_tox_data$dose_response |> dplyr::filter(endp == "TOX21_H2AX_HTRF_CHO_Agonist_ratio", casn == "510-15-6") plot_hill(fit_hill(df)) # 3-parameter Hill model plot_hill(fit_hill(df, fixed_slope = FALSE))
# Multiple assays, multiple chemicals df <- geo_tox_data$dose_response plot_hill(fit_hill(df, assay = "endp", chem = "casn")) # Single assay, multiple chemicals df <- geo_tox_data$dose_response |> dplyr::filter(endp == "TOX21_H2AX_HTRF_CHO_Agonist_ratio") fig <- plot_hill(fit_hill(df, chem = "casn")) fig # Modify plot fig + ggplot2::guides(color = ggplot2::guide_legend(title = "Chemical\nCASN")) # Single assay, single chemical df <- geo_tox_data$dose_response |> dplyr::filter(endp == "TOX21_H2AX_HTRF_CHO_Agonist_ratio", casn == "510-15-6") plot_hill(fit_hill(df)) # 3-parameter Hill model plot_hill(fit_hill(df, fixed_slope = FALSE))
Plot response data
plot_resp( df, region_boundary, group_boundary = NULL, assay_quantiles = c(Median = 0.5), summary_quantiles = c(`10th percentile` = 0.1) )
plot_resp( df, region_boundary, group_boundary = NULL, assay_quantiles = c(Median = 0.5), summary_quantiles = c(`10th percentile` = 0.1) )
df |
output from resp_quantiles. |
region_boundary |
"sf" data.frame mapping features to a "geometry" column. Used to color map regions. |
group_boundary |
"sf" data.frame containing a "geometry" column. Used to draw outlines around groups of regions. |
assay_quantiles |
named numeric vector of assay quantile labels. |
summary_quantiles |
named numeric vector of summary quantile labels. |
ggplot2 object.
# Use example boundary data from package region_boundary <- geo_tox_data$boundaries$county group_boundary <- geo_tox_data$boundaries$state n <- nrow(region_boundary) # Single assay quantile df <- data.frame(id = region_boundary$FIPS, metric = "GCA.Eff", assay_quantile = 0.5, value = runif(n)^3) # Default plot plot_resp(df, region_boundary) # Add group boundary, a state border in this case plot_resp(df, region_boundary, group_boundary) # Change quantile label plot_resp(df, region_boundary, group_boundary, assay_quantiles = c("Q50" = 0.5)) # Multiple assay quantiles df <- data.frame(id = rep(region_boundary$FIPS, 2), metric = "GCA.Eff", assay_quantile = rep(c(0.25, 0.75), each = n), value = c(runif(n)^3, runif(n)^3 + 0.15)) plot_resp(df, region_boundary, group_boundary, assay_quantiles = c("Q25" = 0.25, "Q75" = 0.75)) # Summary quantiles df <- data.frame(id = rep(region_boundary$FIPS, 4), assay_quantile = rep(rep(c(0.25, 0.75), each = n), 2), summary_quantile = rep(c(0.05, 0.95), each = n * 2), metric = "GCA.Eff", value = c(runif(n)^3, runif(n)^3 + 0.15, runif(n)^3 + 0.7, runif(n)^3 + 0.85)) plot_resp(df, region_boundary, group_boundary, assay_quantiles = c("A_Q25" = 0.25, "A_Q75" = 0.75), summary_quantiles = c("S_Q05" = 0.05, "S_Q95" = 0.95))
# Use example boundary data from package region_boundary <- geo_tox_data$boundaries$county group_boundary <- geo_tox_data$boundaries$state n <- nrow(region_boundary) # Single assay quantile df <- data.frame(id = region_boundary$FIPS, metric = "GCA.Eff", assay_quantile = 0.5, value = runif(n)^3) # Default plot plot_resp(df, region_boundary) # Add group boundary, a state border in this case plot_resp(df, region_boundary, group_boundary) # Change quantile label plot_resp(df, region_boundary, group_boundary, assay_quantiles = c("Q50" = 0.5)) # Multiple assay quantiles df <- data.frame(id = rep(region_boundary$FIPS, 2), metric = "GCA.Eff", assay_quantile = rep(c(0.25, 0.75), each = n), value = c(runif(n)^3, runif(n)^3 + 0.15)) plot_resp(df, region_boundary, group_boundary, assay_quantiles = c("Q25" = 0.25, "Q75" = 0.75)) # Summary quantiles df <- data.frame(id = rep(region_boundary$FIPS, 4), assay_quantile = rep(rep(c(0.25, 0.75), each = n), 2), summary_quantile = rep(c(0.05, 0.95), each = n * 2), metric = "GCA.Eff", value = c(runif(n)^3, runif(n)^3 + 0.15, runif(n)^3 + 0.7, runif(n)^3 + 0.85)) plot_resp(df, region_boundary, group_boundary, assay_quantiles = c("A_Q25" = 0.25, "A_Q75" = 0.75), summary_quantiles = c("S_Q05" = 0.05, "S_Q95" = 0.95))
Plot results of sensitivity analysis.
plot_sensitivity( x, metric = "GCA.Eff", assay = NULL, y = "", xlab = metric, ylab = "" )
plot_sensitivity( x, metric = "GCA.Eff", assay = NULL, y = "", xlab = metric, ylab = "" )
x |
GeoTox object. |
metric |
metric to plot. Valid choices are "GCA.Eff", "IA.Eff", "GCA.HQ.10", and "IA.HQ.10". |
assay |
which assay to plot, if multiple exist. |
y |
y value or text for bottom of ridge plot. |
xlab |
x-axis label. |
ylab |
y-axis label. |
ggplot2 object.
# Required GeoTox fields are generated by first running [calculate_response] # and [sensitivity_analysis] on a GeoTox object. This will create the fields # `resp` and `sensitivity`. For this example, dummy data will be used. make_data <- function(n = 5, metric = "GCA.Eff") { list(stats::setNames(data.frame(1:n, runif(n)), c("sample", metric))) } geoTox <- GeoTox() geoTox$resp <- make_data() geoTox$sensitivity <- list(age = make_data(), obesity = make_data(), css_params = make_data(), fit_params = make_data(), C_ext = make_data()) plot_sensitivity(geoTox)
# Required GeoTox fields are generated by first running [calculate_response] # and [sensitivity_analysis] on a GeoTox object. This will create the fields # `resp` and `sensitivity`. For this example, dummy data will be used. make_data <- function(n = 5, metric = "GCA.Eff") { list(stats::setNames(data.frame(1:n, runif(n)), c("sample", metric))) } geoTox <- GeoTox() geoTox$resp <- make_data() geoTox$sensitivity <- list(age = make_data(), obesity = make_data(), css_params = make_data(), fit_params = make_data(), C_ext = make_data()) plot_sensitivity(geoTox)
Get response quantiles
resp_quantiles( resp, metric = c("GCA.Eff", "IA.Eff", "GCA.HQ.10", "IA.HQ.10"), assays = NULL, assay_summary = FALSE, assay_quantiles = c(Median = 0.5), summary_quantiles = c(`10th percentile` = 0.1) )
resp_quantiles( resp, metric = c("GCA.Eff", "IA.Eff", "GCA.HQ.10", "IA.HQ.10"), assays = NULL, assay_summary = FALSE, assay_quantiles = c(Median = 0.5), summary_quantiles = c(`10th percentile` = 0.1) )
resp |
calculated mixture response output from calc_concentration_response. |
metric |
response metric, one of "GCA.Eff", "IA.Eff", "GCA.HQ.10" or "IA.HQ.10". |
assays |
assays to summarize. If NULL and multiple assays exist, then the first assay is used. |
assay_summary |
boolean indicating whether to summarize across assays. |
assay_quantiles |
numeric vector of assay quantiles. |
summary_quantiles |
numeric vector of quantiles to compute across all assay quantiles. |
The columns of the returned data frame will vary based on the inputs. If assays is specified and assay_summary is FALSE, then the resulting data frame will have an assay column. If assay_summary is TRUE, then the data frame will have an summary_quantile column.
data frame with computed response quantiles.
# Dummy response data resp <- list( "r1" = data.frame(assay = c("a1", "a1", "a2", "a2"), sample = c(1, 2, 1, 2), GCA.Eff = c(1, 2, 3, 4), IA.Eff = c(5, 6, 7, 8), "GCA.HQ.10" = c(9, 10, 11, 12), "IA.HQ.10" = c(13, 14, 15, 16))) # Summarize single assay resp_quantiles(resp) # Specify assay resp_quantiles(resp, assays = "a1") # Specify quantiles resp_quantiles(resp, assays = "a1", assay_quantiles = c(0.25, 0.75)) # Specify metric resp_quantiles(resp, assays = "a1", metric = "IA.HQ.10") # Summarize across assays resp_quantiles(resp, assay_summary = TRUE) # Specify quantiles suppressWarnings( resp_quantiles(resp, assay_summary = TRUE, assay_quantiles = c(0.25, 0.75), summary_quantiles = c(0.1, 0.9)) )
# Dummy response data resp <- list( "r1" = data.frame(assay = c("a1", "a1", "a2", "a2"), sample = c(1, 2, 1, 2), GCA.Eff = c(1, 2, 3, 4), IA.Eff = c(5, 6, 7, 8), "GCA.HQ.10" = c(9, 10, 11, 12), "IA.HQ.10" = c(13, 14, 15, 16))) # Summarize single assay resp_quantiles(resp) # Specify assay resp_quantiles(resp, assays = "a1") # Specify quantiles resp_quantiles(resp, assays = "a1", assay_quantiles = c(0.25, 0.75)) # Specify metric resp_quantiles(resp, assays = "a1", metric = "IA.HQ.10") # Summarize across assays resp_quantiles(resp, assay_summary = TRUE) # Specify quantiles suppressWarnings( resp_quantiles(resp, assay_summary = TRUE, assay_quantiles = c(0.25, 0.75), summary_quantiles = c(0.1, 0.9)) )
C_ss
dataSample from pre-generated C_ss
data
sample_Css(simulated_css, age, obesity)
sample_Css(simulated_css, age, obesity)
simulated_css |
list of pre-generated |
age |
list or atomic vector of ages. |
obesity |
list or atomic vector of obesity status. |
list of matrices containing C_ss
values. Columns are sorted to have
consistent order across functions.
# Vector inputs sample_Css(geo_tox_data$simulated_css, c(15, 25, 35), c("Normal", "Obese", "Normal")) # List inputs sample_Css(geo_tox_data$simulated_css, list(c(34, 29), 55), list(c("Obese", "Normal"), "Normal"))
# Vector inputs sample_Css(geo_tox_data$simulated_css, c(15, 25, 35), c("Normal", "Obese", "Normal")) # List inputs sample_Css(geo_tox_data$simulated_css, list(c(34, 29), 55), list(c("Obese", "Normal"), "Normal"))
Perform sensitivity analysis
sensitivity_analysis(x, max_mult = list(NULL, NULL, NULL, 1.2, NULL))
sensitivity_analysis(x, max_mult = list(NULL, NULL, NULL, 1.2, NULL))
x |
GeoTox object. |
max_mult |
numeric list of length 5 for each step of the sensitivity analysis. |
This wrapper function will sequentially call the compute_sensitivity
function with inputs age
, obesity
, css_params
, fit_params
, and
C_ext
. The results will be returned as a named list and stored in the
sensitivity
field of the input GeoTox object.
Values of NULL
in the max_mult
input will use the default value stored
in the GeoTox
object (x$par$resp$max_mult
). When a GeoTox
object is
created this is initialized at 1.5
, but can be changed via the
calculate_response function or directly in the object.
The same GeoTox object with added sensitivity
field.
# Use a subset of the package data for demonstration purposes set.seed(2357) n <- 10 # Population size m <- 5 # Number of regions idx <- if (m < 100) sample(1:100, m) else 1:100 # Create GeoTox object and populate required fields geoTox <- GeoTox() |> # Simulate populations for each region simulate_population(age = split(geo_tox_data$age, ~FIPS)[idx], obesity = geo_tox_data$obesity[idx, ], exposure = split(geo_tox_data$exposure, ~FIPS)[idx], simulated_css = geo_tox_data$simulated_css, n = n) |> # Estimated Hill parameters set_hill_params(geo_tox_data$dose_response |> fit_hill(assay = "endp", chem = "casn") |> dplyr::filter(!tp.sd.imputed, !logAC50.sd.imputed)) # Sensitivity analysis can now be done geoTox <- geoTox |> sensitivity_analysis()
# Use a subset of the package data for demonstration purposes set.seed(2357) n <- 10 # Population size m <- 5 # Number of regions idx <- if (m < 100) sample(1:100, m) else 1:100 # Create GeoTox object and populate required fields geoTox <- GeoTox() |> # Simulate populations for each region simulate_population(age = split(geo_tox_data$age, ~FIPS)[idx], obesity = geo_tox_data$obesity[idx, ], exposure = split(geo_tox_data$exposure, ~FIPS)[idx], simulated_css = geo_tox_data$simulated_css, n = n) |> # Estimated Hill parameters set_hill_params(geo_tox_data$dose_response |> fit_hill(assay = "endp", chem = "casn") |> dplyr::filter(!tp.sd.imputed, !logAC50.sd.imputed)) # Sensitivity analysis can now be done geoTox <- geoTox |> sensitivity_analysis()
Set GeoTox boundaries
set_boundaries(x, region = NULL, group = NULL)
set_boundaries(x, region = NULL, group = NULL)
x |
GeoTox object. |
region |
"sf" data.frame mapping features to a "geometry" column. Used when coloring map regions. |
group |
"sf" data.frame containing a "geometry" column. Used to draw outlines around groups of regions. |
same GeoTox object with boundaries set.
geoTox <- GeoTox() |> set_boundaries(region = geo_tox_data$boundaries$county, group = geo_tox_data$boundaries$state)
geoTox <- GeoTox() |> set_boundaries(region = geo_tox_data$boundaries$county, group = geo_tox_data$boundaries$state)
Set Hill parameters for a GeoTox object.
set_hill_params(x, hill_params)
set_hill_params(x, hill_params)
x |
GeoTox object. |
hill_params |
output of fit_hill. |
same GeoTox object with Hill parameters set.
hill_params <- geo_tox_data$dose_response |> fit_hill(chem = "casn", assay = "endp") |> dplyr::filter(!tp.sd.imputed, !logAC50.sd.imputed) geoTox <- GeoTox() |> set_hill_params(hill_params)
hill_params <- geo_tox_data$dose_response |> fit_hill(chem = "casn", assay = "endp") |> dplyr::filter(!tp.sd.imputed, !logAC50.sd.imputed) geoTox <- GeoTox() |> set_hill_params(hill_params)
Simulate ages
simulate_age(x, n = 1000)
simulate_age(x, n = 1000)
x |
data frame or list of data frames containing population data for age groups. Each data frame must contain columns "AGEGRP" and "TOT_POP". |
n |
simulated sample size. |
Each data frame must contain 19 rows. The first row represents the total population of all age groups while the next 18 rows represent age groups from 0 to 89 in increments of 5 years.
List of arrays containing simulated ages.
# Single data frame x <- data.frame(AGEGRP = 0:18, TOT_POP = 0) # populate only age range 40-44, set population total of all ages x$TOT_POP[c(1, 10)] <- 100 simulate_age(x, 5) # List of 2 data frames y <- data.frame(AGEGRP = 0:18, TOT_POP = 0) # populate age ranges 5-9 and 50-54 y$TOT_POP[c(3, 12)] <- 10 # set population total for all age groups y$TOT_POP[1] <- sum(y$TOT_POP) simulate_age(list(x = x, y = y), 15)
# Single data frame x <- data.frame(AGEGRP = 0:18, TOT_POP = 0) # populate only age range 40-44, set population total of all ages x$TOT_POP[c(1, 10)] <- 100 simulate_age(x, 5) # List of 2 data frames y <- data.frame(AGEGRP = 0:18, TOT_POP = 0) # populate age ranges 5-9 and 50-54 y$TOT_POP[c(3, 12)] <- 10 # set population total for all age groups y$TOT_POP[1] <- sum(y$TOT_POP) simulate_age(list(x = x, y = y), 15)
Simulate external exposure
simulate_exposure( x, expos_mean = "mean", expos_sd = "sd", expos_label = "casn", n = 1000 )
simulate_exposure( x, expos_mean = "mean", expos_sd = "sd", expos_label = "casn", n = 1000 )
x |
data frame or list of data frames containing exposure data. |
expos_mean |
column name of mean values. |
expos_sd |
column name of standard deviations. |
expos_label |
column name of labeling term, required if |
n |
simulated sample size. |
list of matrices containing inhalation rates. Matrix columns are
named using the values in the expos_label
column for more than one data
frame row. Columns are sorted to have consistent order across functions.
# Single data frame x <- data.frame(mean = 1:3, sd = (1:3) / 10, casn = letters[1:3]) simulate_exposure(x, n = 5) # List of 2 data frames y <- data.frame(mean = 4:6, sd = 0.1, casn = letters[1:3]) simulate_exposure(list(loc1 = x, loc2 = y), n = 5) # Input has custom column names z <- data.frame(ave = 1:3, stdev = (1:3) / 10, chnm = letters[1:3]) simulate_exposure(z, expos_mean = "ave", expos_sd = "stdev", expos_label = "chnm", n = 5)
# Single data frame x <- data.frame(mean = 1:3, sd = (1:3) / 10, casn = letters[1:3]) simulate_exposure(x, n = 5) # List of 2 data frames y <- data.frame(mean = 4:6, sd = 0.1, casn = letters[1:3]) simulate_exposure(list(loc1 = x, loc2 = y), n = 5) # Input has custom column names z <- data.frame(ave = 1:3, stdev = (1:3) / 10, chnm = letters[1:3]) simulate_exposure(z, expos_mean = "ave", expos_sd = "stdev", expos_label = "chnm", n = 5)
Simulate inhalation rates
simulate_inhalation_rate(x, IR_params = NULL)
simulate_inhalation_rate(x, IR_params = NULL)
x |
atomic vector or list of atomic vectors containing ages. |
IR_params |
(optional) data frame with columns "age", "mean" and "sd". See details for more information. |
The age column of the optional IR_params
data frame should be in ascending
order and represent the lower value of age groups for the corresponding mean
and sd values. When not provided, the default values will come from Table 6.7
of EPA's 2011 Exposure Factors Handbook using the mean of male and female
values.
List of atomic vectors containing inhalation rates.
# Single atomic vector ages <- sample(1:100, 6, replace = TRUE) simulate_inhalation_rate(ages) # List of atomic vectors ages <- list( sample(1:100, 5, replace = TRUE), sample(1:100, 3, replace = TRUE) ) simulate_inhalation_rate(ages) # Custom IR_params IR_params <- data.frame("age" = c(0, 20, 50), "mean" = c(0.5, 0.3, 0.2), "sd" = c(0.1, 0.06, 0.03)) simulate_inhalation_rate(c(15, 30, 65), IR_params)
# Single atomic vector ages <- sample(1:100, 6, replace = TRUE) simulate_inhalation_rate(ages) # List of atomic vectors ages <- list( sample(1:100, 5, replace = TRUE), sample(1:100, 3, replace = TRUE) ) simulate_inhalation_rate(ages) # Custom IR_params IR_params <- data.frame("age" = c(0, 20, 50), "mean" = c(0.5, 0.3, 0.2), "sd" = c(0.1, 0.06, 0.03)) simulate_inhalation_rate(c(15, 30, 65), IR_params)
Simulate obesity status
simulate_obesity( x, obes_prev = "OBESITY_CrudePrev", obes_sd = "OBESITY_SD", obes_label = "FIPS", n = 1000 )
simulate_obesity( x, obes_prev = "OBESITY_CrudePrev", obes_sd = "OBESITY_SD", obes_label = "FIPS", n = 1000 )
x |
data frame containing obesity data as a percentage from 0 to 100. |
obes_prev |
column name of prevalence. |
obes_sd |
column name of standard deviation. |
obes_label |
column name of labeling term, required if |
n |
simulated sample size. |
List of arrays containing simulated obesity status.
# Input has default column names df <- data.frame(OBESITY_CrudePrev = c(20, 50, 80), OBESITY_SD = c(5, 5, 5), FIPS = letters[1:3]) simulate_obesity(df, n = 5) # Input has custom column names df <- data.frame(prev = c(20, 50, 80), sd = c(5, 5, 5), label = letters[1:3]) simulate_obesity(df, obes_prev = "prev", obes_sd = "sd", obes_label = "label", n = 5)
# Input has default column names df <- data.frame(OBESITY_CrudePrev = c(20, 50, 80), OBESITY_SD = c(5, 5, 5), FIPS = letters[1:3]) simulate_obesity(df, n = 5) # Input has custom column names df <- data.frame(prev = c(20, 50, 80), sd = c(5, 5, 5), label = letters[1:3]) simulate_obesity(df, obes_prev = "prev", obes_sd = "sd", obes_label = "label", n = 5)
Simulate population data for given input fields
simulate_population( x, age = NULL, obesity = NULL, exposure = NULL, simulated_css = NULL, ... )
simulate_population( x, age = NULL, obesity = NULL, exposure = NULL, simulated_css = NULL, ... )
x |
GeoTox object. |
age |
input |
obesity |
input |
exposure |
input |
simulated_css |
input |
... |
additional arguments passed to other functions. See details. |
Additional parameters include n
for sample size,
IR_params
for simulate_inhalation_rate,
obes_prev
, obes_sd
, and obes_label
for simulate_obesity,
and expos_mean
, expos_sd
, and expos_label
for simulate_exposure.
The same object with simulated fields added.
# Use a subset of the package data for demonstration purposes set.seed(2357) n <- 10 # Population size m <- 5 # Number of regions idx <- if (m < 100) sample(1:100, m) else 1:100 # Create GeoTox object geoTox <- GeoTox() |> # Simulate populations for each region simulate_population(age = split(geo_tox_data$age, ~FIPS)[idx], obesity = geo_tox_data$obesity[idx, ], exposure = split(geo_tox_data$exposure, ~FIPS)[idx], simulated_css = geo_tox_data$simulated_css, n = n)
# Use a subset of the package data for demonstration purposes set.seed(2357) n <- 10 # Population size m <- 5 # Number of regions idx <- if (m < 100) sample(1:100, m) else 1:100 # Create GeoTox object geoTox <- GeoTox() |> # Simulate populations for each region simulate_population(age = split(geo_tox_data$age, ~FIPS)[idx], obesity = geo_tox_data$obesity[idx, ], exposure = split(geo_tox_data$exposure, ~FIPS)[idx], simulated_css = geo_tox_data$simulated_css, n = n)