diff --git a/DESCRIPTION b/DESCRIPTION index ae1bc04d..84a3e69e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: serocalculator Type: Package Title: Estimating Infection Rates from Serological Data -Version: 1.3.0 +Version: 1.2.0.9002 Authors@R: c( person(given = "Peter", family = "Teunis", email = "p.teunis@emory.edu", role = c("aut", "cph"), comment = "Author of the method and original code."), person(given = "Kristina", family = "Lai", email = "kwlai@ucdavis.edu", role = c("aut", "cre")), diff --git a/R/autoplot.curve_params.R b/R/autoplot.curve_params.R index 2aa8024a..f1040419 100644 --- a/R/autoplot.curve_params.R +++ b/R/autoplot.curve_params.R @@ -2,27 +2,37 @@ #' #' @inheritParams plot_curve_params_one_ab #' @inheritDotParams plot_curve_params_one_ab -#' @param antigen_isos antigen isotypes to analyze (can be used to subset `curve_params`) +#' @param antigen_isos antigen isotypes to analyze (can subset `curve_params`) #' @param ncol how many columns of subfigures to use in panel plot #' @details #' ## `rows_to_graph` -#' Note that if you directly specify `rows_to_graph` when calling this function, the row numbers are enumerated separately for each antigen isotype; in other words, for the purposes of this argument, row numbers start over at 1 for each antigen isotype. There is currently no way to specify different row numbers for different antigen isotypes; if you want to do that, you will could call [plot_curve_params_one_ab()] directly for each antigen isotype and combine the resulting panels yourself. Or you could subset `curve_params` manually, before passing it to this function, and set the `n_curves` argument to `Inf`. +#' Note that if you directly specify `rows_to_graph` when calling this function, +#' the row numbers are enumerated separately for each antigen isotype; +#' in other words, for the purposes of this argument, +#' row numbers start over at 1 for each antigen isotype. There is currently +#' no way to specify different row numbers for different antigen isotypes; +#' if you want to do that, you could call [plot_curve_params_one_ab()] +#' directly for each antigen isotype and combine the resulting panels yourself. +#' Or you could subset `curve_params` manually, before passing it to this +#' function, and set the `n_curves` argument to `Inf`. #' @return a [ggplot2::ggplot()] object #' @export #' @examples +#' \donttest{ #' library(dplyr) #' library(ggplot2) +#' library(magrittr) #' #' curve = load_curve_params("https://osf.io/download/rtw5k/") %>% #' filter(antigen_iso %in% c("HlyE_IgA", "HlyE_IgG")) %>% -#' slice(1:100, .by = antigen_iso) %>% # Reduce dataset for the purposes of this example +#' slice(1:100, .by = antigen_iso) %>% # Reduce dataset for this example #' autoplot() #' #' curve -#' -autoplot.curve_params = function( +#'} +autoplot.curve_params <- function( object, - antigen_isos = object$antigen_iso %>% unique(), + antigen_isos = unique(object$antigen_iso), ncol = min(3, length(antigen_isos)), ...) { split_data <- object %>% @@ -34,8 +44,7 @@ autoplot.curve_params = function( figs <- split_data %>% lapply(FUN = plot_curve_params_one_ab, ...) - for (i in 1:length(figs)) - { + for (i in seq_along(figs)) { figs[[i]] <- figs[[i]] + ggplot2::ggtitle(labels[i]) } diff --git a/man/autoplot.curve_params.Rd b/man/autoplot.curve_params.Rd index 6c7f926a..e32c4fde 100644 --- a/man/autoplot.curve_params.Rd +++ b/man/autoplot.curve_params.Rd @@ -6,7 +6,7 @@ \usage{ \method{autoplot}{curve_params}( object, - antigen_isos = object$antigen_iso \%>\% unique(), + antigen_isos = unique(object$antigen_iso), ncol = min(3, length(antigen_isos)), ... ) @@ -14,7 +14,7 @@ \arguments{ \item{object}{a \code{\link[=data.frame]{data.frame()}} of curve parameters (one or more MCMC samples)} -\item{antigen_isos}{antigen isotypes to analyze (can be used to subset \code{curve_params})} +\item{antigen_isos}{antigen isotypes to analyze (can subset \code{curve_params})} \item{ncol}{how many columns of subfigures to use in panel plot} @@ -44,18 +44,28 @@ graph antibody decay curves by antigen isotype \details{ \subsection{\code{rows_to_graph}}{ -Note that if you directly specify \code{rows_to_graph} when calling this function, the row numbers are enumerated separately for each antigen isotype; in other words, for the purposes of this argument, row numbers start over at 1 for each antigen isotype. There is currently no way to specify different row numbers for different antigen isotypes; if you want to do that, you will could call \code{\link[=plot_curve_params_one_ab]{plot_curve_params_one_ab()}} directly for each antigen isotype and combine the resulting panels yourself. Or you could subset \code{curve_params} manually, before passing it to this function, and set the \code{n_curves} argument to \code{Inf}. +Note that if you directly specify \code{rows_to_graph} when calling this function, +the row numbers are enumerated separately for each antigen isotype; +in other words, for the purposes of this argument, +row numbers start over at 1 for each antigen isotype. There is currently +no way to specify different row numbers for different antigen isotypes; +if you want to do that, you could call \code{\link[=plot_curve_params_one_ab]{plot_curve_params_one_ab()}} +directly for each antigen isotype and combine the resulting panels yourself. +Or you could subset \code{curve_params} manually, before passing it to this +function, and set the \code{n_curves} argument to \code{Inf}. } } \examples{ +\donttest{ library(dplyr) library(ggplot2) +library(magrittr) curve = load_curve_params("https://osf.io/download/rtw5k/") \%>\% filter(antigen_iso \%in\% c("HlyE_IgA", "HlyE_IgG")) \%>\% - slice(1:100, .by = antigen_iso) \%>\% # Reduce dataset for the purposes of this example + slice(1:100, .by = antigen_iso) \%>\% # Reduce dataset for this example autoplot() curve - +} }