From cb8f4d28dab7b4b6b1e6d02210211646e03e5f1f Mon Sep 17 00:00:00 2001 From: Douglas Ezra Morrison Date: Wed, 15 May 2024 16:57:02 -0700 Subject: [PATCH 1/8] debugging --- .Rbuildignore | 2 ++ .gitignore | 1 + R/graph.decay.curves.R | 5 ++-- man/plot_curve_params_one_ab.Rd | 48 ++++++++++++++++++++++++++++++--- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 548e44ee..d13510fd 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -21,3 +21,5 @@ allpopsamples_hlye.csv$ ^serocalculator.*\.tgz$ ^inst/extdata ^CRAN-SUBMISSION$ +^vignettes/rsconnect$ +^rsconnect$ diff --git a/.gitignore b/.gitignore index 0c6c65bd..5619a910 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ src-x64 serocalculator.Rcheck/ serocalculator*.tar.gz serocalculator*.tgz +rsconnect diff --git a/R/graph.decay.curves.R b/R/graph.decay.curves.R index 59caad30..7085c6fc 100644 --- a/R/graph.decay.curves.R +++ b/R/graph.decay.curves.R @@ -9,7 +9,7 @@ #' * 0 = fully transparent (invisible) #' * 1 = fully opaque #' @param log_x should the x-axis be on a logarithmic scale (`TRUE`) or linear scale (`FALSE`, default)? -#' @inheritParams ggplot2::geom_function +#' @inheritDotParams ggplot2::geom_function #' @returns a [ggplot2::ggplot()] object #' @details #' ## `n_curves` and `rows_to_graph` @@ -60,7 +60,8 @@ plot_curve_params_one_ab = function( alpha = alpha, # aes(color = cur_row), fun = ab0, - args = list(curve_params = cur_params)) + args = list(curve_params = cur_params), + ...) } layers = diff --git a/man/plot_curve_params_one_ab.Rd b/man/plot_curve_params_one_ab.Rd index 5eded554..642bd67c 100644 --- a/man/plot_curve_params_one_ab.Rd +++ b/man/plot_curve_params_one_ab.Rd @@ -34,10 +34,50 @@ plot_curve_params_one_ab( \item{xlim}{range of x values to graph} -\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}. These are -often aesthetics, used to set an aesthetic to a fixed value, like -\code{colour = "red"} or \code{size = 3}. They may also be parameters -to the paired geom/stat.} +\item{...}{ + Arguments passed on to \code{\link[ggplot2:geom_function]{ggplot2::geom_function}} + \describe{ + \item{\code{mapping}}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}}. If specified and +\code{inherit.aes = TRUE} (the default), it is combined with the default mapping +at the top level of the plot. You must supply \code{mapping} if there is no plot +mapping.} + \item{\code{data}}{Ignored by \code{stat_function()}, do not use.} + \item{\code{stat}}{The statistical transformation to use on the data for this layer. +When using a \verb{geom_*()} function to construct a layer, the \code{stat} +argument can be used the override the default coupling between geoms and +stats. The \code{stat} argument accepts the following: +\itemize{ +\item A \code{Stat} ggproto subclass, for example \code{StatCount}. +\item A string naming the stat. To give the stat as a string, strip the +function name of the \code{stat_} prefix. For example, to use \code{stat_count()}, +give the stat as \code{"count"}. +\item For more information and other ways to specify the stat, see the +\link[ggplot2:layer_stats]{layer stat} documentation. +}} + \item{\code{position}}{A position adjustment to use on the data for this layer. This +can be used in various ways, including to prevent overplotting and +improving the display. The \code{position} argument accepts the following: +\itemize{ +\item The result of calling a position function, such as \code{position_jitter()}. +This method allows for passing extra arguments to the position. +\item A string naming the position adjustment. To give the position as a +string, strip the function name of the \code{position_} prefix. For example, +to use \code{position_jitter()}, give the position as \code{"jitter"}. +\item For more information and other ways to specify the position, see the +\link[ggplot2:layer_positions]{layer position} documentation. +}} + \item{\code{na.rm}}{If \code{FALSE}, the default, missing values are removed with +a warning. If \code{TRUE}, missing values are silently removed.} + \item{\code{show.legend}}{logical. Should this layer be included in the legends? +\code{NA}, the default, includes if any aesthetics are mapped. +\code{FALSE} never includes, and \code{TRUE} always includes. +It can also be a named logical vector to finely select the aesthetics to +display.} + \item{\code{inherit.aes}}{If \code{FALSE}, overrides the default aesthetics, +rather than combining with them. This is most useful for helper functions +that define both data and aesthetics and shouldn't inherit behaviour from +the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.} + }} } \value{ a \code{\link[ggplot2:ggplot]{ggplot2::ggplot()}} object From d4ecd7dc4202898aa054f448e7acf41c6ecb9f37 Mon Sep 17 00:00:00 2001 From: Douglas Ezra Morrison Date: Thu, 18 Jul 2024 13:27:43 -0400 Subject: [PATCH 2/8] more work --- man/autoplot.curve_params.Rd | 2 +- man/plot_curve_params_one_ab.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/man/autoplot.curve_params.Rd b/man/autoplot.curve_params.Rd index 6c7f926a..b1a1a9e2 100644 --- a/man/autoplot.curve_params.Rd +++ b/man/autoplot.curve_params.Rd @@ -32,7 +32,7 @@ \item 1 = fully opaque }} \item{\code{log_x}}{should the x-axis be on a logarithmic scale (\code{TRUE}) or linear scale (\code{FALSE}, default)?} - \item{\code{log_y}}{should the Y-axis be on a logarithmic scale (default, \code{TRUE}) or linear scale (\code{FALSE})?} + \item{\code{log_y}}{should the y-axis be on a logarithmic scale (default, \code{TRUE}) or linear scale (\code{FALSE})?} }} } \value{ diff --git a/man/plot_curve_params_one_ab.Rd b/man/plot_curve_params_one_ab.Rd index e5739f2d..9d22c381 100644 --- a/man/plot_curve_params_one_ab.Rd +++ b/man/plot_curve_params_one_ab.Rd @@ -34,7 +34,7 @@ plot_curve_params_one_ab( \item{log_x}{should the x-axis be on a logarithmic scale (\code{TRUE}) or linear scale (\code{FALSE}, default)?} -\item{log_y}{should the Y-axis be on a logarithmic scale (default, \code{TRUE}) or linear scale (\code{FALSE})?} +\item{log_y}{should the y-axis be on a logarithmic scale (default, \code{TRUE}) or linear scale (\code{FALSE})?} \item{rows_to_graph}{which rows of \code{curve_params} to plot (overrides \code{n_curves}).} From c1bb4ae2263c23e48d887959689f1d12e7740bfd Mon Sep 17 00:00:00 2001 From: Douglas Ezra Morrison Date: Thu, 18 Jul 2024 13:28:31 -0400 Subject: [PATCH 3/8] formatting --- R/graph.decay.curves.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/R/graph.decay.curves.R b/R/graph.decay.curves.R index a2e6fe08..91c0db99 100644 --- a/R/graph.decay.curves.R +++ b/R/graph.decay.curves.R @@ -71,12 +71,12 @@ plot_curve_params_one_ab = function( layer_function <- function(cur_row) { cur_params <- object[cur_row, ] ggplot2::geom_function( - alpha = alpha, - # aes(color = cur_row), - fun = ab0, - n = n_points, - args = list(curve_params = cur_params), - ...) + alpha = alpha, + # aes(color = cur_row), + fun = ab0, + n = n_points, + args = list(curve_params = cur_params), + ...) } layers <- From 68844ed345226b1b9bc88a8400bbb141d041a5e4 Mon Sep 17 00:00:00 2001 From: Douglas Ezra Morrison Date: Thu, 18 Jul 2024 13:29:02 -0400 Subject: [PATCH 4/8] keeping it simple --- R/graph.decay.curves.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/graph.decay.curves.R b/R/graph.decay.curves.R index 91c0db99..2e37e127 100644 --- a/R/graph.decay.curves.R +++ b/R/graph.decay.curves.R @@ -74,8 +74,8 @@ plot_curve_params_one_ab = function( alpha = alpha, # aes(color = cur_row), fun = ab0, - n = n_points, args = list(curve_params = cur_params), + n = n_points, ...) } From a9b952cd11138d2b848847e3128da11bd424e630 Mon Sep 17 00:00:00 2001 From: Douglas Ezra Morrison Date: Thu, 18 Jul 2024 13:30:18 -0400 Subject: [PATCH 5/8] export but keep internal --- R/graph.decay.curves.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/graph.decay.curves.R b/R/graph.decay.curves.R index 2e37e127..830de2cf 100644 --- a/R/graph.decay.curves.R +++ b/R/graph.decay.curves.R @@ -25,8 +25,9 @@ #' #' load_curve_params("https://osf.io/download/rtw5k/") %>% #' dplyr::filter(antigen_iso == "HlyE_IgG") %>% -#' serocalculator:::plot_curve_params_one_ab() -#' +#' serocalculator::plot_curve_params_one_ab() +#' @export +#' @keywords internal plot_curve_params_one_ab = function( object, verbose = FALSE, From 6d69954e333a23ecad1ebb8945ea08f5ead82f27 Mon Sep 17 00:00:00 2001 From: Douglas Ezra Morrison Date: Thu, 18 Jul 2024 13:33:15 -0400 Subject: [PATCH 6/8] keep internal --- NAMESPACE | 1 + R/graph.decay.curves.R | 4 ++-- man/plot_curve_params_one_ab.Rd | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 9620f8fb..51e4b536 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -44,6 +44,7 @@ export(load_curve_params) export(load_noise_params) export(load_pop_data) export(log_likelihood) +export(plot_curve_params_one_ab) export(sim.cs) export(sim.cs.multi) importFrom(Rcpp,sourceCpp) diff --git a/R/graph.decay.curves.R b/R/graph.decay.curves.R index 830de2cf..09e790ae 100644 --- a/R/graph.decay.curves.R +++ b/R/graph.decay.curves.R @@ -25,8 +25,8 @@ #' #' load_curve_params("https://osf.io/download/rtw5k/") %>% #' dplyr::filter(antigen_iso == "HlyE_IgG") %>% -#' serocalculator::plot_curve_params_one_ab() -#' @export +#' serocalculator:::plot_curve_params_one_ab() +#' @noRd #' @keywords internal plot_curve_params_one_ab = function( object, diff --git a/man/plot_curve_params_one_ab.Rd b/man/plot_curve_params_one_ab.Rd index 9d22c381..a9b4f5a4 100644 --- a/man/plot_curve_params_one_ab.Rd +++ b/man/plot_curve_params_one_ab.Rd @@ -107,6 +107,6 @@ library(dplyr) # loads the `\%>\%` operator and `dplyr::filter()` load_curve_params("https://osf.io/download/rtw5k/") \%>\% dplyr::filter(antigen_iso == "HlyE_IgG") \%>\% - serocalculator:::plot_curve_params_one_ab() - + serocalculator::plot_curve_params_one_ab() } +\keyword{internal} From 7e15ae31bc5ea7ad761df0e9928c0fcdaefbdfba Mon Sep 17 00:00:00 2001 From: Douglas Ezra Morrison Date: Thu, 18 Jul 2024 13:35:34 -0400 Subject: [PATCH 7/8] cleanup --- R/autoplot.curve_params.R | 14 ++++++++++++-- R/graph.decay.curves.R | 4 ++-- man/autoplot.curve_params.Rd | 14 ++++++++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/R/autoplot.curve_params.R b/R/autoplot.curve_params.R index 2aa8024a..76d2c452 100644 --- a/R/autoplot.curve_params.R +++ b/R/autoplot.curve_params.R @@ -6,7 +6,17 @@ #' @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`. +#' 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`. #' @return a [ggplot2::ggplot()] object #' @export #' @examples @@ -15,7 +25,7 @@ #' #' 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 the purposes of this example #' autoplot() #' #' curve diff --git a/R/graph.decay.curves.R b/R/graph.decay.curves.R index 09e790ae..830de2cf 100644 --- a/R/graph.decay.curves.R +++ b/R/graph.decay.curves.R @@ -25,8 +25,8 @@ #' #' load_curve_params("https://osf.io/download/rtw5k/") %>% #' dplyr::filter(antigen_iso == "HlyE_IgG") %>% -#' serocalculator:::plot_curve_params_one_ab() -#' @noRd +#' serocalculator::plot_curve_params_one_ab() +#' @export #' @keywords internal plot_curve_params_one_ab = function( object, diff --git a/man/autoplot.curve_params.Rd b/man/autoplot.curve_params.Rd index b1a1a9e2..bbf2af46 100644 --- a/man/autoplot.curve_params.Rd +++ b/man/autoplot.curve_params.Rd @@ -44,7 +44,17 @@ 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}. +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}. } } \examples{ @@ -53,7 +63,7 @@ library(ggplot2) 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 the purposes of this example autoplot() curve From f37682604d71bffb0332e25c268ee4e61687137c Mon Sep 17 00:00:00 2001 From: Douglas Ezra Morrison Date: Mon, 23 Sep 2024 23:08:21 -0700 Subject: [PATCH 8/8] Increment version number to 1.2.0.9003 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index bda12109..72e5e73e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: serocalculator Type: Package Title: Estimating Infection Rates from Serological Data -Version: 1.2.0.9002 +Version: 1.2.0.9003 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")),