Skip to content

Commit

Permalink
adress comments (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
erblast authored Feb 24, 2023
1 parent 67deb89 commit 5ba195e
Show file tree
Hide file tree
Showing 52 changed files with 775 additions and 474 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
^\.git
^cran-comments\.md$
^data-raw$
^CRAN-SUBMISSION$
20 changes: 12 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
Package: simaerep
Title: Simulate Adverse Event Reporting in Clinical Trials with the Goal of Detecting under-Reporting Sites
Title: Find Clinical Trial Sites Under-Reporting Adverse Events
Version: 0.4.2
Authors@R:
Authors@R: c(
person(given = "Bjoern",
family = "Koneswarakantha",
role = c("aut", "cre"),
role = c("aut", "cre", "cph"),
email = "[email protected]",
comment = c(ORCID = "0000-0003-4585-7799"))
Description: This can detect clinical trial sites that are under-reporting adverse events (AE).
Bootstrap-based simulations are used to simulate AE reporting and to assign an AE
under-reporting probability to each site in a clinical trial (Koneswarakantha 2021
<doi:10.1007/s40264-020-01011-5>).
comment = c(ORCID = "0000-0003-4585-7799")),
person("F. Hoffmann-La Roche Ltd",
role = c("cph"))
)
Description: Monitoring of Adverse Event (AE) reporting in clinical trials is
important for patient safety. Sites that are under-reporting AEs can be detected
using Bootstrap-based simulations that simulate overall AE reporting. Based on the
simulation an AE under-reporting probability is assigned to each site in a
given trial (Koneswarakantha 2021 <doi:10.1007/s40264-020-01011-5>).
URL: https://openpharma.github.io/simaerep/, https://github.com/openpharma/simaerep
License: MIT + file LICENSE
Encoding: UTF-8
Expand Down
2 changes: 1 addition & 1 deletion R/S3_simaerep.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ simaerep <- function(df_visit,
#' @details see [plot_study()][plot_study] and
#' [plot_visit_med75()][plot_visit_med75]
#' @examples
#' \dontrun{
#' \donttest{
#' df_visit <- sim_test_data_study(
#' n_pat = 100,
#' n_sites = 5,
Expand Down
7 changes: 4 additions & 3 deletions R/lint.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
#' cyclocomp_linter = lintr::cyclocomp_linter(25)
#' @param path character
#' @inheritParams lintr::lint_package
#' @return " "
#' @return No return value, called for side effects
#' @seealso \code{\link[lintr]{lint_package}}
#' @rdname lint_package
#' @noRd
lint_package <- function(path = ".", ...) {

lint_results <- lintr::lint_package(path = path,
Expand All @@ -21,9 +22,9 @@ lint_package <- function(path = ".", ...) {
...)

if (length(lint_results) > 0) {
print(lint_results) # does not work wit cat()
message(lint_results) # does not work wit cat()
stop(paste(lint_results))
} else {
print("no lint violations")
message("no lint violations")
}
}
13 changes: 8 additions & 5 deletions R/progress.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' @title Execute a purrr or furrr function with a progress
#' bar.
#' @description Internal utility function.
#' @details Call still needs to be wrapped in \code{\link[progressr]{with_progress}}
#' @details Call still needs to be wrapped in \code{\link[progressr]{with_progress}}
#' or [with_progress_cnd()][with_progress_cnd()]
#' @param .purrr purrr or furrr function
#' @param ... iterable arguments passed to .purrr
Expand All @@ -17,7 +17,7 @@
#' purrr_bar(rep(0.25, 5), .purrr = purrr::map, .f = Sys.sleep, .steps = 5)
#' )
#'
#'\dontrun{
#'\donttest{
#' # purrr::walk
#' progressr::with_progress(
#' purrr_bar(rep(0.25, 5), .purrr = purrr::walk,.f = Sys.sleep, .steps = 5)
Expand Down Expand Up @@ -67,10 +67,11 @@
#'
#' # with mutate
#' progressr::with_progress(
#' tibble(x = rep(0.25, 5)) %>%
#' mutate(x = purrr_bar(x, .purrr = purrr::map, .f = Sys.sleep, .steps = 5))
#' tibble::tibble(x = rep(0.25, 5)) %>%
#' dplyr::mutate(x = purrr_bar(x, .purrr = purrr::map, .f = Sys.sleep, .steps = 5))
#' )
#'}
#' @return result of function passed to .f
#' @rdname purrr_bar
#' @export
purrr_bar <- function(...,
Expand Down Expand Up @@ -116,7 +117,8 @@ purrr_bar <- function(...,
#'@param ex expression
#'@param progress logical, Default: TRUE
#'@details This wrapper adds a progress parameter to \code{\link[progressr]{with_progress}}
#' so that we can control the progress bar in the user facing functions.
#' so that we can control the progress bar in the user facing functions. The progressbar
#' only shows in interactive mode.
#' @examples
#' if (interactive()) {
#'
Expand Down Expand Up @@ -155,6 +157,7 @@ purrr_bar <- function(...,
#' )
#' )
#'}
#'@return No return value, called for side effects
#'@seealso \code{\link[progressr]{with_progress}}
#'@rdname with_progress_cnd
#'@export
Expand Down
5 changes: 3 additions & 2 deletions R/simaerep.R
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ get_pat_pool_config <- function(df_visit, df_site, min_n_pat_with_med75 = 1) {
#' are calculated.
#' @return dataframe
#' @examples
#' \dontrun{
#' \donttest{
#' df_visit1 <- sim_test_data_study(n_pat = 100, n_sites = 5,
#' frac_site_with_ur = 0.4, ur_rate = 0.6)
#'
Expand All @@ -1046,7 +1046,8 @@ get_pat_pool_config <- function(df_visit, df_site, min_n_pat_with_med75 = 1) {
#' df_site <- site_aggr(df_visit)
#'
#' sim_studies(df_visit, df_site, r = 3, keep_ae = TRUE)
#'
#'}
#' \dontrun{
#' # parallel processing -------------------------
#' library(future)
#' future::plan(multiprocess)
Expand Down
15 changes: 9 additions & 6 deletions R/simaerep_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ plot_dots <- function(df,
#' @param color_low character, hex color value, Default: '#25A69A'
#' @param title logical, include title, Default: T
#' @param legend logical, include legend, Default: T
#' @param seed pass seed for simulations Default: 5
#' @return ggplot
#' @details uses [plot_dots()][plot_dots()] and adds 2 simulation panels, uses made-up
#' site config with three sites A,B,C simulating site C
#' @examples
#' \dontrun{
#' \donttest{
#' plot_sim_example(size_dots = 5)
#' }
#' @seealso
Expand All @@ -158,8 +159,9 @@ plot_sim_example <- function(substract_ae_per_pat = 0,
color_high = "#00695C",
color_low = "#25A69A",
title = TRUE,
legend = TRUE) {
set.seed(5)
legend = TRUE,
seed = 5) {
set.seed(seed)

study <- tibble(
site = LETTERS[1:3],
Expand Down Expand Up @@ -292,13 +294,14 @@ plot_sim_example <- function(substract_ae_per_pat = 0,
#' @param ... parameters passed to plot_sim_example()
#' @details This function is a wrapper for plot_sim_example()
#' @examples
#' \dontrun{
#' \donttest{
#' plot_sim_examples(size_dot = 3, size_raster_label = 10)
#' plot_sim_examples()
#' }
#' @seealso
#' \code{\link[cowplot]{ggdraw}},\code{\link[cowplot]{draw_label}},\code{\link[cowplot]{plot_grid}}
#' @rdname plot_sim_examples
#' @return ggplot
#' @export

plot_sim_examples <- function(substract_ae_per_pat = c(0, 1, 3), ...) {
Expand Down Expand Up @@ -403,7 +406,7 @@ plot_sim_examples <- function(substract_ae_per_pat = c(0, 1, 3), ...) {
#' number of patients. Patients that have not been on the study long enough to
#' reach the evaluation point (visit_med75) will be ignored.
#' @examples
#' \dontrun{
#' \donttest{
#' df_visit <- sim_test_data_study(n_pat = 1000, n_sites = 10,
#' frac_site_with_ur = 0.2, ur_rate = 0.15, max_visit_sd = 8)
#'
Expand Down Expand Up @@ -682,7 +685,7 @@ plot_study <- function(df_visit,
labs(y = "Mean Cumulative AE Count per Site")

if (length(sites_ordered) == 0) {
print("no sites with P/FP ratio > 1")
message("no sites with P/FP ratio > 1")
return(p_study)
}

Expand Down
28 changes: 14 additions & 14 deletions R/simulate_test_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ sim_scenario <- function(n_ae_site, n_ae_study, frac_pat_with_ur, ur_rate) {
#' run. For this to work we need to specify the plan for how the code should
#' run, e.g. plan(multisession, workers = 18)
#' @examples
#' if (interactive()) {
#' \donttest{
#' df_visit1 <- sim_test_data_study(n_pat = 100, n_sites = 10,
#' frac_site_with_ur = 0.4, ur_rate = 0.6)
#'
Expand All @@ -200,8 +200,8 @@ sim_scenario <- function(n_ae_site, n_ae_study, frac_pat_with_ur, ur_rate) {
#' df_visit <- dplyr::bind_rows(df_visit1, df_visit2)
#'
#' df_site_max <- df_visit %>%
#' group_by(study_id, site_number, patnum) %>%
#' summarise(max_visit = max(visit),
#' dplyr::group_by(study_id, site_number, patnum) %>%
#' dplyr::summarise(max_visit = max(visit),
#' max_ae = max(n_ae),
#' .groups = "drop")
#'
Expand Down Expand Up @@ -406,7 +406,7 @@ sim_ur_scenarios <- function(df_portf,
#' run. For this to work we need to specify the plan for how the code should
#' run, e.g. `plan(multisession, workers = 3)
#' @examples
#' if (interactive()) {
#' \donttest{
#' df_visit1 <- sim_test_data_study(n_pat = 100, n_sites = 10,
#' frac_site_with_ur = 0.4, ur_rate = 0.6)
#'
Expand All @@ -420,8 +420,8 @@ sim_ur_scenarios <- function(df_portf,
#' df_visit <- dplyr::bind_rows(df_visit1, df_visit2)
#'
#' df_site_max <- df_visit %>%
#' group_by(study_id, site_number, patnum) %>%
#' summarise(max_visit = max(visit),
#' dplyr::group_by(study_id, site_number, patnum) %>%
#' dplyr::summarise(max_visit = max(visit),
#' max_ae = max(n_ae),
#' .groups = "drop")
#'
Expand Down Expand Up @@ -559,22 +559,22 @@ sim_test_data_portfolio <- function(df_config, parallel = FALSE, progress = TRUE
#' site} \item{**max_visit_mean**}{mean of maximum patient visits per site}
#' \item{**n_pat**}{number of patients} }
#' @examples
#' if (interactive()) {
#' \donttest{
#' df_visit1 <- sim_test_data_study(n_pat = 100, n_sites = 10,
#' frac_site_with_ur = 0.4, ur_rate = 0.6)
#'.
#'
#' df_visit1$study_id <- "A"
#'.
#'
#' df_visit2 <- sim_test_data_study(n_pat = 100, n_sites = 10,
#' frac_site_with_ur = 0.2, ur_rate = 0.1)
#'.
#'
#' df_visit2$study_id <- "B"
#'.
#'
#' df_visit <- dplyr::bind_rows(df_visit1, df_visit2)
#'
#' df_site_max <- df_visit %>%
#' group_by(study_id, site_number, patnum) %>%
#' summarise(max_visit = max(visit),
#' dplyr::group_by(study_id, site_number, patnum) %>%
#' dplyr::summarise(max_visit = max(visit),
#' max_ae = max(n_ae),
#' .groups = "drop")
#'
Expand Down Expand Up @@ -674,7 +674,7 @@ get_config <- function(df_site,
#' @return dataframe
#' @details DETAILS
#' @examples
#' \dontrun{
#' \donttest{
#' df_visit1 <- sim_test_data_study(n_pat = 100, n_sites = 10,
#' frac_site_with_ur = 0.4, ur_rate = 0.6)
#'
Expand Down
1 change: 1 addition & 0 deletions R/utils-pipe.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
#' @export
#' @importFrom magrittr %>%
#' @usage lhs \%>\% rhs
#' @return returns output of rhs function
NULL
3 changes: 0 additions & 3 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,3 @@ reference:
- plot_sim_examples
- plot_sim_example
- plot_dots
- title: internal
contents:
- lint_package
57 changes: 57 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
# Resubmission of simaerep

Thank you for taking the time to review my submission. I have addressed all of your
comments.

## DESCRIPTION

Please reduce the length of the title to less than 65 characters.

*done*

Please do not start the description with "This package", package name,
title or similar.
I would start with: "Detect clinical trial sites..."

*done*

Please always add all authors, contributors and copyright holders in the
Authors@R field with the appropriate roles.

*I have added Hoffmann La Roche to the Authors@R field and assigned cph*
*role to the institution and myself. This reflects our internal policy.*
*as stated in the licence file.*
*COPYRIGHT HOLDER: F. Hoffmann-La Roche Ltd and simaerep authors*
*This covers copyright interest of potential future external collaborators.*

## Examples

Please unwrap the examples if they are executable in < 5 sec, or replace
dontrun{} with \donttest{}.
*done, with one exception in the sim_studies() example show casing parallel*
*processing which makes changes to the user's environment.*

Please replace if(interactive()){} with \donttest or unwrap the
examples.
*done, with one exception, with_progress_cnd() the progressbar is only visible*
*in interactive mode*

## Console Messages

R/lint.R

*lint_package() has been declared an internal function, print() calls have been*
*exchanged for message() calls*

R/simaerep_plot.R
*print() calls have been exchanged for message() calls that inform user that*
*certain element of the plot cannot be generated*

## Seed
R/simaerep_plot.R
*seed can now be passed as parameter, fixed seed is desired so that the generated*
*plot always looks the same*




# First Submission of simaerep

## Test Results
Expand Down
Loading

0 comments on commit 5ba195e

Please sign in to comment.