From d31950e35a75370a47227141449ee0fac97aee2a Mon Sep 17 00:00:00 2001 From: yilong zhang Date: Sat, 30 Dec 2023 21:24:43 +0000 Subject: [PATCH] inherit paramter_term from all parameters of a metadata by default. (#20) --- R/ae_forestly.R | 5 +++-- R/format_ae_forestly.R | 5 +++-- R/meta_forestly.R | 7 ++++--- R/prepare_ae_forestly.R | 15 +++++++++++---- man/ae_forestly.Rd | 5 +++-- man/format_ae_forestly.Rd | 5 +++-- man/meta_forestly.Rd | 11 ++++++----- man/prepare_ae_forestly.Rd | 7 ++++--- vignettes/forestly.Rmd | 8 +++++--- vignettes/layout.Rmd | 6 +++--- 10 files changed, 45 insertions(+), 29 deletions(-) diff --git a/R/ae_forestly.R b/R/ae_forestly.R index 46af201..6a39f48 100644 --- a/R/ae_forestly.R +++ b/R/ae_forestly.R @@ -34,9 +34,10 @@ #' dataset_adsl = adsl, #' dataset_adae = adae, #' population_term = "apat", -#' observation_term = "wk12" +#' observation_term = "wk12", +#' parameter = "any;rel" #' ) |> -#' prepare_ae_forestly(parameter = "any;rel") |> +#' prepare_ae_forestly() |> #' format_ae_forestly() |> #' ae_forestly() #' } diff --git a/R/format_ae_forestly.R b/R/format_ae_forestly.R index 528fdfa..321e88e 100644 --- a/R/format_ae_forestly.R +++ b/R/format_ae_forestly.R @@ -48,9 +48,10 @@ #' dataset_adsl = adsl, #' dataset_adae = adae, #' population_term = "apat", -#' observation_term = "wk12" +#' observation_term = "wk12", +#' parameter = "any;rel" #' ) |> -#' prepare_ae_forestly(parameter = "any;rel")|> +#' prepare_ae_forestly()|> #' format_ae_forestly() format_ae_forestly <- function( outdata, diff --git a/R/meta_forestly.R b/R/meta_forestly.R index f904f0f..956f88b 100644 --- a/R/meta_forestly.R +++ b/R/meta_forestly.R @@ -38,17 +38,18 @@ #' forestly_adsl, #' forestly_adae, #' population_term = "apat", -#' observation_term = "wk12" +#' observation_term = "wk12", +#' parameter_term = "any;rel" #' ) meta_forestly <- function( dataset_adsl, dataset_adae, population_term, observation_term, + parameter_term = "any;rel", population_subset = SAFFL == "Y", observation_subset = SAFFL == "Y", - treatment_group = "TRTA", - parameter_term = "any;rel;ser") { + treatment_group = "TRTA") { meta <- metalite::meta_adam( population = as.data.frame(dataset_adsl), observation = as.data.frame(dataset_adae) diff --git a/R/prepare_ae_forestly.R b/R/prepare_ae_forestly.R index 9df490c..2059edb 100644 --- a/R/prepare_ae_forestly.R +++ b/R/prepare_ae_forestly.R @@ -33,20 +33,21 @@ #' dataset_adsl = adsl, #' dataset_adae = adae, #' population_term = "apat", -#' observation_term = "wk12" +#' observation_term = "wk12", +#' parameter = "any;rel" #' ) |> -#' prepare_ae_forestly(parameter = "any;rel") +#' prepare_ae_forestly() prepare_ae_forestly <- function( meta, population = NULL, observation = NULL, - parameter, + parameter = NULL, reference_group = NULL, ae_listing_display = c( "SEX", "RACE", "AGE", "ASTDY", "AESEV", "AESER", "AEREL", "AEACN", "AEOUT", "SITEID", "ADURN", "ADURU" )) { - parameters <- unlist(strsplit(parameter, ";")) + if (is.null(population)) { if (length(meta$population) == 1) { @@ -64,6 +65,12 @@ prepare_ae_forestly <- function( } } + if( is.null(parameter)){ + parameters <- names(meta$parameter) + }else{ + parameters <- unlist(strsplit(parameter, ";")) + } + res <- lapply(parameters, function(x) { # print(x) metalite.ae::prepare_ae_specific(meta, diff --git a/man/ae_forestly.Rd b/man/ae_forestly.Rd index ef59041..ff34e4a 100644 --- a/man/ae_forestly.Rd +++ b/man/ae_forestly.Rd @@ -27,9 +27,10 @@ if (interactive()) { dataset_adsl = adsl, dataset_adae = adae, population_term = "apat", - observation_term = "wk12" + observation_term = "wk12", + parameter = "any;rel" ) |> - prepare_ae_forestly(parameter = "any;rel") |> + prepare_ae_forestly() |> format_ae_forestly() |> ae_forestly() } diff --git a/man/format_ae_forestly.Rd b/man/format_ae_forestly.Rd index 7c4d442..d58ec7c 100644 --- a/man/format_ae_forestly.Rd +++ b/man/format_ae_forestly.Rd @@ -65,8 +65,9 @@ meta_forestly( dataset_adsl = adsl, dataset_adae = adae, population_term = "apat", - observation_term = "wk12" + observation_term = "wk12", + parameter = "any;rel" ) |> - prepare_ae_forestly(parameter = "any;rel")|> + prepare_ae_forestly()|> format_ae_forestly() } diff --git a/man/meta_forestly.Rd b/man/meta_forestly.Rd index 95b27f3..2db8ca5 100644 --- a/man/meta_forestly.Rd +++ b/man/meta_forestly.Rd @@ -9,10 +9,10 @@ meta_forestly( dataset_adae, population_term, observation_term, + parameter_term = "any;rel", population_subset = SAFFL == "Y", observation_subset = SAFFL == "Y", - treatment_group = "TRTA", - parameter_term = "any;rel;ser" + treatment_group = "TRTA" ) } \arguments{ @@ -24,6 +24,8 @@ meta_forestly( \item{observation_term}{A character value of observation term name.} +\item{parameter_term}{A character value of parameter term name.} + \item{population_subset}{An unquoted condition for selecting the populations from ADSL dataset.} @@ -31,8 +33,6 @@ populations from ADSL dataset.} observations from ADAE dataset.} \item{treatment_group}{A character value of treatment group name.} - -\item{parameter_term}{A character value of parameter term name.} } \value{ A metalite object. @@ -45,6 +45,7 @@ meta_forestly( forestly_adsl, forestly_adae, population_term = "apat", - observation_term = "wk12" + observation_term = "wk12", + parameter_term = "any;rel" ) } diff --git a/man/prepare_ae_forestly.Rd b/man/prepare_ae_forestly.Rd index 64392d7..edca2bf 100644 --- a/man/prepare_ae_forestly.Rd +++ b/man/prepare_ae_forestly.Rd @@ -8,7 +8,7 @@ prepare_ae_forestly( meta, population = NULL, observation = NULL, - parameter, + parameter = NULL, reference_group = NULL, ae_listing_display = c("SEX", "RACE", "AGE", "ASTDY", "AESEV", "AESER", "AEREL", "AEACN", "AEOUT", "SITEID", "ADURN", "ADURU") @@ -45,7 +45,8 @@ meta_forestly( dataset_adsl = adsl, dataset_adae = adae, population_term = "apat", - observation_term = "wk12" + observation_term = "wk12", + parameter = "any;rel" ) |> - prepare_ae_forestly(parameter = "any;rel") + prepare_ae_forestly() } diff --git a/vignettes/forestly.Rmd b/vignettes/forestly.Rmd index a6c8a07..e954446 100644 --- a/vignettes/forestly.Rmd +++ b/vignettes/forestly.Rmd @@ -51,9 +51,10 @@ meta_forestly( dataset_adsl = forestly_adsl, dataset_adae = forestly_adae, population_term = "apat", - observation_term = "wk12" + observation_term = "wk12", + parameter_term = "any;rel;ser" ) |> - prepare_ae_forestly(parameter = "any;rel;ser") |> + prepare_ae_forestly() |> format_ae_forestly() |> ae_forestly() ``` @@ -89,7 +90,8 @@ meta_forestly( dataset_adsl = forestly_adsl, dataset_adae = forestly_adae, population_term = "apat", - observation_term = "wk12" + observation_term = "wk12", + parameter_term = "any;rel;ser" ) ``` diff --git a/vignettes/layout.Rmd b/vignettes/layout.Rmd index 40c75b1..0344f13 100644 --- a/vignettes/layout.Rmd +++ b/vignettes/layout.Rmd @@ -41,10 +41,11 @@ metadata <- meta_forestly( dataset_adsl = forestly_adsl_3grp, dataset_adae = forestly_adae_3grp, population_term = "apat", - observation_term = "wk12" + observation_term = "wk12", + parameter_term = "any;rel;ser" ) -outdata <- metadata |> prepare_ae_forestly(parameter = "any;rel;ser") +outdata <- metadata |> prepare_ae_forestly() outdata ``` @@ -121,7 +122,6 @@ listing_var <- c( metadata |> prepare_ae_forestly( - parameter = "any;rel;ser", ae_listing_display = listing_var ) |> format_ae_forestly() |>