Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## New features

* Updating density diagnostic function (#71)
* Changes to `run_mod()` (#79):
- `jags.post` now optionally included in output, as specified by argument
`with_post`
Expand Down
13 changes: 9 additions & 4 deletions R/plot_jags_densitydx.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#' - `y1` = posterior estimate of peak antibody concentration
#' @param strat Specify [character] string to produce plots of specific
#' stratification entered in quotes.
#' @return A [base::list()] of [ggplot2::ggplot()] objects producing density
#' @return A [list] of [ggplot2::ggplot] objects producing density
#' plots for all the specified input.
#' @export
#' @example inst/examples/examples-plot_jags_densitydx.R
Expand Down Expand Up @@ -61,18 +61,23 @@
# Changing parameter name to reflect the input
dplyr::mutate(Parameter = paste0("iso = ", j, ", parameter = ",
.data$Parameter_sub, ", strat = ",
i),
value = log(.data$value))
i))
# Assigning attributes, which are needed to run ggs_density
attributes(visualize_jags_plot) <- c(attributes(visualize_jags_plot),
attributes_jags)
# Creating density plot
densplot <- ggmcmc::ggs_density(visualize_jags_plot) +
ggplot2::theme_bw() +
ggplot2::labs(x = "log(value)")
ggplot2::labs(x = "parameter value") +
ggplot2::scale_x_log10(labels = scales::label_comma())
density_out[[j]] <- densplot
}

dens_strat_list[[i]] <- density_out
}
#Printing only one plot if only one exists.
if (length(dens_strat_list) == 1) {
dens_strat_list <- dens_strat_list[[1]][[iso]]

Check warning on line 80 in R/plot_jags_densitydx.R

View check run for this annotation

Codecov / codecov/patch

R/plot_jags_densitydx.R#L80

Added line #L80 was not covered by tests
}
dens_strat_list
}
2 changes: 1 addition & 1 deletion inst/examples/examples-plot_jags_densitydx.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


data <- serodynamics::nepal_sees_jags_output

# Specifying isotype and stratification for traceplot.
plot_jags_dens(
data = data,
iso = "HlyE_IgA",
Expand Down
4 changes: 2 additions & 2 deletions man/plot_jags_dens.Rd

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

297 changes: 146 additions & 151 deletions tests/testthat/_snaps/plot_jags_densitydx/typhoid-plot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 1 addition & 4 deletions tests/testthat/test-plot_jags_densitydx.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ test_that(
desc = "results are consistent with ggplot output",
code = {
skip_if(getRversion() < "4.4.1") # 4.3.3 had issues
library(runjags)
library(dplyr)

data <- serodynamics::nepal_sees_jags_output |>
suppressWarnings()
data <- serodynamics::nepal_sees_jags_output

# Testing for any errors:
results <- plot_jags_dens(data) |> expect_no_error()
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-run_mod.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test_that(
sim_case_data(n = 100,
antigen_isos = "HlyE_IgA") |>
mutate(strat = "stratum 1")
dataset <- bind_rows(strat1, strat2)
dataset <- dplyr::bind_rows(strat1, strat2)
withr::with_seed(
1,
code = {
Expand Down
Loading