From c03c2beacdba4de914d5fd50213c7844f7191254 Mon Sep 17 00:00:00 2001 From: LittleBeannie Date: Mon, 10 Aug 2026 10:52:58 -0400 Subject: [PATCH 1/6] Update the R files --- R/boxly.R | 48 ++++++++++++++++--- R/meta_boxly.R | 116 ---------------------------------------------- R/prepare_boxly.R | 49 +++++++++++++++++--- 3 files changed, 84 insertions(+), 129 deletions(-) delete mode 100644 R/meta_boxly.R diff --git a/R/boxly.R b/R/boxly.R index bd49b5d..a5073b8 100644 --- a/R/boxly.R +++ b/R/boxly.R @@ -41,14 +41,50 @@ #' @examples #' # Only run this example in interactive R sessions #' if (interactive()) { -#' library(metalite) +#' analysis_plan <- metalite::plan( +#' analysis = "boxly", +#' population = "apat", +#' observation = "wk12", +#' parameter = "SODIUM;BILI" +#' ) #' -#' meta_boxly( -#' boxly_adsl, -#' boxly_adlb, -#' population_term = "apat", -#' observation_term = "wk12" +#' meta <- metalite::meta_adam( +#' population = boxly_adsl, +#' observation = boxly_adlb #' ) |> +#' metalite::define_plan(analysis_plan) |> +#' metalite::define_population( +#' name = "apat", +#' group = "TRTA", +#' subset = SAFFL == "Y", +#' label = "Safety Population" +#' ) |> +#' metalite::define_observation( +#' name = "wk12", +#' group = "TRTA", +#' var = "PARAM", +#' subset = AVISITN <= 12 & !is.na(CHG), +#' label = "Weeks 0 to 12" +#' ) |> +#' metalite::define_parameter( +#' name = "SODIUM", +#' label = "Sodium (mmol/L)", +#' subset = PARAMCD == "SODIUM" +#' ) |> +#' metalite::define_parameter( +#' name = "BILI", +#' label = "Bilirubin (mg/dL)", +#' subset = PARAMCD == "BILI" +#' ) |> +#' metalite::define_analysis( +#' name = "boxly", +#' label = "Interactive Box Plot", +#' x = "AVISITN", +#' y = "CHG" +#' ) |> +#' metalite::meta_build() +#' +#' meta |> #' prepare_boxly() |> #' boxly() #' } diff --git a/R/meta_boxly.R b/R/meta_boxly.R deleted file mode 100644 index 09e8201..0000000 --- a/R/meta_boxly.R +++ /dev/null @@ -1,116 +0,0 @@ -# Copyright (c) 2023 Merck & Co., Inc., Rahway, NJ, USA and its affiliates. -# All rights reserved. -# -# This file is part of the boxly program. -# -# boxly is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -#' Create an example metadata object -#' -#' @param dataset_adsl ADSL source dataset. -#' @param dataset_param Observation level source dataset for boxplot. -#' @param population_term A character value of population term name. -#' @param population_subset An unquoted condition for selecting the -#' populations from ADSL dataset. -#' @param observation_term A character value of observation term name. -#' @param observation_subset An unquoted condition for selecting the -#' observations from `dataset_param` dataset. -#' @param parameters A chracter vector of parameters defined in `dataset_param$PARAMCD` -#' -#' @return A metalite object. -#' -#' @export -#' -#' @examples -#' -#' meta_boxly( -#' boxly_adsl, -#' boxly_adlb, -#' population_term = "apat", -#' observation_term = "wk12" -#' ) -meta_boxly <- function( - dataset_adsl, - dataset_param, - population_term, - population_subset = SAFFL == "Y", - observation_term, - observation_subset = SAFFL == "Y", - parameters = unique(dataset_param$PARAMCD) -) { - # Input Checking - require_param <- c("PARAM", "PARAMCD", "AVISITN", "CHG") - - if (!all(require_param %in% names(dataset_param))) { - dataset_param_diff <- paste(setdiff(names(dataset_param), require_param), collapse = ";") - stop("Missing Standard Variable in dataset_param: ", dataset_param_diff) - } - - if (!all(parameters %in% dataset_param$PARAMCD)) { - param_diff <- paste(setdiff(parameters, unique(dataset_param$PARAMCD)), collapse = ";") - stop("Mismatch parameters in dataset_param$PARAMCD: ", param_diff) - } - - # Analysis Plan - parameter_term <- paste(parameters, collapse = ";") - - plan <- metalite::plan( - analysis = "boxly", - population = population_term, - observation = observation_term, - parameter = parameter_term - ) - - # Define metalite object - meta <- metalite::meta_adam( - population = dataset_adsl, - observation = dataset_param - ) |> - metalite::define_plan(plan = plan) |> - metalite::define_population( - name = population_term, - group = "TRTA", - subset = !!rlang::enquo(population_subset), - label = "" - ) |> - metalite::define_observation( - name = observation_term, - group = "TRTA", - var = "PARAM", - subset = !!rlang::enquo(observation_subset), - label = "" - ) |> - metalite::define_analysis( - name = "boxly", - label = "Interactive Box Plot", - x = "AVISITN", - y = "CHG" - ) - - # Add parameter definition - u_param <- unique(dataset_param[, c("PARAM", "PARAMCD")]) - u_param <- u_param[u_param[["PARAMCD"]] %in% parameters, ] - - for (i in seq(parameters)) { - term <- paste0("PARAMCD == '", u_param[["PARAMCD"]][i], "'") - meta <- meta |> - metalite::define_parameter( - name = u_param[["PARAMCD"]][i], - label = u_param[["PARAM"]][i], - subset = str2lang(term) - ) - } - - metalite::meta_build(meta) -} diff --git a/R/prepare_boxly.R b/R/prepare_boxly.R index 15f6ea9..4f77dbd 100644 --- a/R/prepare_boxly.R +++ b/R/prepare_boxly.R @@ -34,14 +34,49 @@ #' @export #' #' @examples -#' library(metalite) -#' -#' meta <- meta_boxly( -#' boxly_adsl, -#' boxly_adlb, -#' population_term = "apat", -#' observation_term = "wk12" +#' analysis_plan <- metalite::plan( +#' analysis = "boxly", +#' population = "apat", +#' observation = "wk12", +#' parameter = "SODIUM;BILI" #' ) +#' +#' meta <- metalite::meta_adam( +#' population = boxly_adsl, +#' observation = boxly_adlb +#' ) |> +#' metalite::define_plan(analysis_plan) |> +#' metalite::define_population( +#' name = "apat", +#' group = "TRTA", +#' subset = SAFFL == "Y", +#' label = "Safety Population" +#' ) |> +#' metalite::define_observation( +#' name = "wk12", +#' group = "TRTA", +#' var = "PARAM", +#' subset = AVISITN <= 12 & !is.na(CHG), +#' label = "Weeks 0 to 12" +#' ) |> +#' metalite::define_parameter( +#' name = "SODIUM", +#' label = "Sodium (mmol/L)", +#' subset = PARAMCD == "SODIUM" +#' ) |> +#' metalite::define_parameter( +#' name = "BILI", +#' label = "Bilirubin (mg/dL)", +#' subset = PARAMCD == "BILI" +#' ) |> +#' metalite::define_analysis( +#' name = "boxly", +#' label = "Interactive Box Plot", +#' x = "AVISITN", +#' y = "CHG" +#' ) |> +#' metalite::meta_build() +#' #' prepare_boxly(meta) #' #' @return Metadata list with plotting dataset From 188e5f368cf4532e2dfd9e7186487215fdf4749b Mon Sep 17 00:00:00 2001 From: LittleBeannie Date: Mon, 10 Aug 2026 10:53:14 -0400 Subject: [PATCH 2/6] Update the testthat files --- tests/testthat/helper-meta_boxly.R | 54 +++++++++++++++++++ .../test-independant-testing-prepare_boxly.R | 5 +- .../testthat/test-independent-testing-boxly.R | 10 ++-- .../test-independent-testing-meta_boxly.R | 35 ------------ 4 files changed, 60 insertions(+), 44 deletions(-) create mode 100644 tests/testthat/helper-meta_boxly.R delete mode 100644 tests/testthat/test-independent-testing-meta_boxly.R diff --git a/tests/testthat/helper-meta_boxly.R b/tests/testthat/helper-meta_boxly.R new file mode 100644 index 0000000..e37b7fc --- /dev/null +++ b/tests/testthat/helper-meta_boxly.R @@ -0,0 +1,54 @@ +meta_boxly_test <- function( + dataset_adsl, + dataset_param, + population_term, + observation_term, + parameters = unique(dataset_param$PARAMCD) +) { + analysis_plan <- metalite::plan( + analysis = "boxly", + population = population_term, + observation = observation_term, + parameter = paste(parameters, collapse = ";") + ) + + meta <- metalite::meta_adam( + population = dataset_adsl, + observation = dataset_param + ) |> + metalite::define_plan(plan = analysis_plan) |> + metalite::define_population( + name = population_term, + group = "TRTA", + subset = SAFFL == "Y", + label = "" + ) |> + metalite::define_observation( + name = observation_term, + group = "TRTA", + var = "PARAM", + subset = AVISITN <= 12 & !is.na(CHG), + label = "" + ) |> + metalite::define_analysis( + name = "boxly", + label = "Interactive Box Plot", + x = "AVISITN", + y = "CHG" + ) + + parameter_data <- unique(dataset_param[, c("PARAM", "PARAMCD")]) + parameter_data <- parameter_data[parameter_data[["PARAMCD"]] %in% parameters, ] + + for (index in seq(parameters)) { + term <- paste0("PARAMCD == '", parameter_data[["PARAMCD"]][index], "'") + meta <- meta |> + metalite::define_parameter( + name = parameter_data[["PARAMCD"]][index], + label = parameter_data[["PARAM"]][index], + subset = str2lang(term) + ) + } + + metalite::meta_build(meta) +} \ No newline at end of file diff --git a/tests/testthat/test-independant-testing-prepare_boxly.R b/tests/testthat/test-independant-testing-prepare_boxly.R index 79485a2..975284d 100644 --- a/tests/testthat/test-independant-testing-prepare_boxly.R +++ b/tests/testthat/test-independant-testing-prepare_boxly.R @@ -17,12 +17,11 @@ # along with this program. If not, see . test_that("Its class is 'outdata'", { - meta <- meta_boxly( + meta <- meta_boxly_test( boxly_adsl, boxly_adlb, population_term = "apat", - observation_term = "wk12", - observation_subset = AVISITN <= 12 & !is.na(CHG) + observation_term = "wk12" ) output <- suppressMessages(prepare_boxly(meta)) diff --git a/tests/testthat/test-independent-testing-boxly.R b/tests/testthat/test-independent-testing-boxly.R index 3f8c857..01cae63 100644 --- a/tests/testthat/test-independent-testing-boxly.R +++ b/tests/testthat/test-independent-testing-boxly.R @@ -17,12 +17,11 @@ # along with this program. If not, see . test_that("validation of boxly plot Case 1", { - meta <- meta_boxly( + meta <- meta_boxly_test( boxly_adsl, boxly_adlb, population_term = "apat", - observation_term = "wk12", - observation_subset = AVISITN <= 12 & !is.na(CHG) + observation_term = "wk12" ) x <- suppressMessages(prepare_boxly(meta)) @@ -57,12 +56,11 @@ test_that("validation of boxly plot Case 1", { }) test_that("validation of boxly plot Case 2", { - meta <- meta_boxly( + meta <- meta_boxly_test( boxly_adsl, boxly_adlb, population_term = "apat", - observation_term = "wk12", - observation_subset = AVISITN <= 12 & !is.na(CHG) + observation_term = "wk12" ) x <- suppressMessages(prepare_boxly(meta)) diff --git a/tests/testthat/test-independent-testing-meta_boxly.R b/tests/testthat/test-independent-testing-meta_boxly.R deleted file mode 100644 index 2f45f72..0000000 --- a/tests/testthat/test-independent-testing-meta_boxly.R +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (c) 2023 Merck & Co., Inc., Rahway, NJ, USA and its affiliates. -# All rights reserved. -# -# This file is part of the boxly program. -# -# boxly is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -test_that("meta_boxly() structure", { - x <- meta_boxly( - boxly_adsl, - boxly_adlb, - population_term = "apat", - observation_term = "wk12", - observation_subset = AVISITN <= 12 & !is.na(CHG) - ) - - expect_equal(class(x), "meta_adam") - expect_equal(class(x$data_population), "data.frame") - expect_equal(class(x$data_observation), c("tbl_df", "tbl", "data.frame")) - expect_equal(class(x$population), "list") - expect_equal(class(x$observation), "list") - expect_equal(class(x$parameter), "list") - expect_equal(class(x$analysis), "list") -}) From 409e710cccf7ee1e8dd5d4dd3853ebcae0aa519f Mon Sep 17 00:00:00 2001 From: LittleBeannie Date: Mon, 10 Aug 2026 10:53:32 -0400 Subject: [PATCH 3/6] Update the Rmd files --- man/prepare_boxly.Rd | 49 +++++++++-- vignettes/boxly-cran.Rmd | 49 +++++++++-- vignettes/boxly.Rmd | 164 ++++++++++++++++++++++++++++++----- vignettes/design-pattern.Rmd | 55 ++++++++++-- vignettes/hover-label.Rmd | 130 ++++++++++++++++++++++----- 5 files changed, 389 insertions(+), 58 deletions(-) diff --git a/man/prepare_boxly.Rd b/man/prepare_boxly.Rd index 8318bb6..1050d87 100644 --- a/man/prepare_boxly.Rd +++ b/man/prepare_boxly.Rd @@ -39,14 +39,49 @@ Metadata list with plotting dataset Prepare data for interactive box plot } \examples{ -library(metalite) - -meta <- meta_boxly( - boxly_adsl, - boxly_adlb, - population_term = "apat", - observation_term = "wk12" +analysis_plan <- metalite::plan( + analysis = "boxly", + population = "apat", + observation = "wk12", + parameter = "SODIUM;BILI" ) + +meta <- metalite::meta_adam( + population = boxly_adsl, + observation = boxly_adlb +) |> + metalite::define_plan(analysis_plan) |> + metalite::define_population( + name = "apat", + group = "TRTA", + subset = SAFFL == "Y", + label = "Safety Population" + ) |> + metalite::define_observation( + name = "wk12", + group = "TRTA", + var = "PARAM", + subset = AVISITN <= 12 & !is.na(CHG), + label = "Weeks 0 to 12" + ) |> + metalite::define_parameter( + name = "SODIUM", + label = "Sodium (mmol/L)", + subset = PARAMCD == "SODIUM" + ) |> + metalite::define_parameter( + name = "BILI", + label = "Bilirubin (mg/dL)", + subset = PARAMCD == "BILI" + ) |> + metalite::define_analysis( + name = "boxly", + label = "Interactive Box Plot", + x = "AVISITN", + y = "CHG" + ) |> + metalite::meta_build() + prepare_boxly(meta) } diff --git a/vignettes/boxly-cran.Rmd b/vignettes/boxly-cran.Rmd index 833e79f..cb53cdf 100644 --- a/vignettes/boxly-cran.Rmd +++ b/vignettes/boxly-cran.Rmd @@ -12,13 +12,50 @@ Please see for the full documentation. ```{r, eval = FALSE} library("boxly") -meta_boxly( - boxly_adsl, - boxly_adlb, - population_term = "apat", - observation_term = "wk12", - observation_subset = AVISITN <= 12 & !is.na(CHG) +analysis_plan <- metalite::plan( + analysis = "boxly", + population = "apat", + observation = "wk12", + parameter = "SODIUM;BILI" +) + +meta <- metalite::meta_adam( + population = boxly_adsl, + observation = boxly_adlb ) |> + metalite::define_plan(analysis_plan) |> + metalite::define_population( + name = "apat", + group = "TRTA", + subset = SAFFL == "Y", + label = "Safety Population" + ) |> + metalite::define_observation( + name = "wk12", + group = "TRTA", + var = "PARAM", + subset = AVISITN <= 12 & !is.na(CHG), + label = "Weeks 0 to 12" + ) |> + metalite::define_parameter( + name = "SODIUM", + label = "Sodium (mmol/L)", + subset = PARAMCD == "SODIUM" + ) |> + metalite::define_parameter( + name = "BILI", + label = "Bilirubin (mg/dL)", + subset = PARAMCD == "BILI" + ) |> + metalite::define_analysis( + name = "boxly", + label = "Interactive Box Plot", + x = "AVISITN", + y = "CHG" + ) |> + metalite::meta_build() + +meta |> prepare_boxly() |> boxly() ``` diff --git a/vignettes/boxly.Rmd b/vignettes/boxly.Rmd index 50c6d9b..de0ad8d 100644 --- a/vignettes/boxly.Rmd +++ b/vignettes/boxly.Rmd @@ -42,23 +42,63 @@ Some common interactive features of the box plots include: Creating the box plot using this package involves the below steps: - - Create a list of metadata (Ex: meta) using `meta_boxly()` + - Create a metadata object using the metalite package - Call `prepare_boxly()` function to prepare the metadata as required by the user - Call `boxly()` function to create the interactive plot ## Example 1: Interactive Box Plot Using Labs Data -Step1: Create a list of metadata (Ex: meta) using `meta_boxly()` +Step 1: Create a metadata object using the metalite package ```{r} -meta <- meta_boxly( - boxly_adsl, - boxly_adlb, - population_term = "apat", - observation_term = "wk12", - observation_subset = AVISITN <= 12 & !is.na(CHG) +analysis_plan <- metalite::plan( + analysis = "boxly", + population = "apat", + observation = "wk12", + parameter = "SODIUM;K;CL" ) + +meta <- metalite::meta_adam( + population = boxly_adsl, + observation = boxly_adlb +) |> + metalite::define_plan(analysis_plan) |> + metalite::define_population( + name = "apat", + group = "TRTA", + subset = SAFFL == "Y", + label = "Safety Population" + ) |> + metalite::define_observation( + name = "wk12", + group = "TRTA", + var = "PARAM", + subset = AVISITN <= 12 & !is.na(CHG), + label = "Weeks 0 to 12" + ) |> + metalite::define_parameter( + name = "SODIUM", + label = "Sodium (mmol/L)", + subset = PARAMCD == "SODIUM" + ) |> + metalite::define_parameter( + name = "K", + label = "Potassium (mmol/L)", + subset = PARAMCD == "K" + ) |> + metalite::define_parameter( + name = "CL", + label = "Chloride (mmol/L)", + subset = PARAMCD == "CL" + ) |> + metalite::define_analysis( + name = "boxly", + label = "Interactive Box Plot", + x = "AVISITN", + y = "CHG" + ) |> + metalite::meta_build() ``` Step2: Call `prepare_boxly()` function to prepare the metadata as required by the user @@ -77,13 +117,55 @@ boxly(outdata) ## Example 2: Interactive Box Plot Using Vital Signs Data ```{r} -meta_boxly( - boxly_adsl, - boxly_advs, - population_term = "apat", - observation_term = "wk12", - observation_subset = AVISITN <= 12 & !is.na(CHG) +analysis_plan <- metalite::plan( + analysis = "boxly", + population = "apat", + observation = "wk12", + parameter = "DIABP;PULSE;SYSBP" +) + +meta <- metalite::meta_adam( + population = boxly_adsl, + observation = boxly_advs ) |> + metalite::define_plan(analysis_plan) |> + metalite::define_population( + name = "apat", + group = "TRTA", + subset = SAFFL == "Y", + label = "Safety Population" + ) |> + metalite::define_observation( + name = "wk12", + group = "TRTA", + var = "PARAM", + subset = AVISITN <= 12 & !is.na(CHG), + label = "Weeks 0 to 12" + ) |> + metalite::define_parameter( + name = "DIABP", + label = "Diastolic Blood Pressure (mmHg)", + subset = PARAMCD == "DIABP" + ) |> + metalite::define_parameter( + name = "PULSE", + label = "Pulse Rate (BEATS/MIN)", + subset = PARAMCD == "PULSE" + ) |> + metalite::define_parameter( + name = "SYSBP", + label = "Systolic Blood Pressure (mmHg)", + subset = PARAMCD == "SYSBP" + ) |> + metalite::define_analysis( + name = "boxly", + label = "Interactive Box Plot", + x = "AVISITN", + y = "CHG" + ) |> + metalite::meta_build() + +meta |> prepare_boxly() |> boxly() ``` @@ -91,13 +173,55 @@ meta_boxly( ## Example 3: Interactive Box Plot Using ECG Data ```{r} -meta_boxly( - boxly_adsl, - boxly_adeg, - population_term = "apat", - observation_term = "wk12", - observation_subset = AVISITN <= 12 & !is.na(CHG) +analysis_plan <- metalite::plan( + analysis = "boxly", + population = "apat", + observation = "wk12", + parameter = "ARATE;PR;QRS" +) + +meta <- metalite::meta_adam( + population = boxly_adsl, + observation = boxly_adeg ) |> + metalite::define_plan(analysis_plan) |> + metalite::define_population( + name = "apat", + group = "TRTA", + subset = SAFFL == "Y", + label = "Safety Population" + ) |> + metalite::define_observation( + name = "wk12", + group = "TRTA", + var = "PARAM", + subset = AVISITN <= 12 & !is.na(CHG), + label = "Weeks 0 to 12" + ) |> + metalite::define_parameter( + name = "ARATE", + label = "Atrial Rate (beats/min)", + subset = PARAMCD == "ARATE" + ) |> + metalite::define_parameter( + name = "PR", + label = "PR Interval (msec)", + subset = PARAMCD == "PR" + ) |> + metalite::define_parameter( + name = "QRS", + label = "QRS Interval (msec)", + subset = PARAMCD == "QRS" + ) |> + metalite::define_analysis( + name = "boxly", + label = "Interactive Box Plot", + x = "AVISITN", + y = "CHG" + ) |> + metalite::meta_build() + +meta |> prepare_boxly() |> boxly() ``` diff --git a/vignettes/design-pattern.Rmd b/vignettes/design-pattern.Rmd index d2e7841..6e77cad 100644 --- a/vignettes/design-pattern.Rmd +++ b/vignettes/design-pattern.Rmd @@ -56,15 +56,62 @@ As an interactive visualization tool, boxly contains several interactive feature # Input data structure and attributes Metadata which is generated by metalite package is required as input. -`meta_boxly()` is generated in the boxly package for illustration purpose. -Users should create metadata with similar structure. +Users should create metadata with the population, observation, parameter, and +analysis definitions required for their box plot. ```{r} library(boxly) ``` ```{r} -meta <- meta_boxly() +analysis_plan <- metalite::plan( + analysis = "lb_boxly", + population = "apat", + observation = "wk12", + parameter = "sodium;bili;urate" +) + +meta <- metalite::meta_adam( + population = boxly_adsl, + observation = boxly_adlb +) |> + metalite::define_plan(analysis_plan) |> + metalite::define_population( + name = "apat", + group = "TRTA", + subset = SAFFL == "Y", + label = "Safety Population" + ) |> + metalite::define_observation( + name = "wk12", + group = "TRTA", + var = "PARAM", + subset = AVISITN <= 12 & !is.na(CHG), + label = "Weeks 0 to 12" + ) |> + metalite::define_parameter( + name = "sodium", + label = "Sodium (mmol/L)", + subset = PARAMCD == "SODIUM" + ) |> + metalite::define_parameter( + name = "bili", + label = "Bilirubin (umol/L)", + subset = PARAMCD == "BILI" + ) |> + metalite::define_parameter( + name = "urate", + label = "Urate (umol/L)", + subset = PARAMCD == "URATE" + ) |> + metalite::define_analysis( + name = "lb_boxly", + label = "Interactive Box Plot", + x = "AVISITN", + y = "CHG" + ) |> + metalite::meta_build() + meta ``` @@ -81,7 +128,6 @@ Here is the structure for the expected output list of `prepare_boxly()`: outdata <- prepare_boxly(meta, population = "apat", observation = "wk12", - parameter = "sodium;bili;urate", analysis = "lb_boxly" ) outdata @@ -121,7 +167,6 @@ The second block is an combined interactive visualization tool which contains a p_list <- prepare_boxly(meta, population = "apat", observation = "wk12", - parameter = "sodium;bili;urate", analysis = "lb_boxly" ) |> boxly() diff --git a/vignettes/hover-label.Rmd b/vignettes/hover-label.Rmd index 104b2d7..bfea78e 100644 --- a/vignettes/hover-label.Rmd +++ b/vignettes/hover-label.Rmd @@ -79,16 +79,46 @@ In this example, we plan to add more hover labels for outliers. library(boxly) ``` -Step1: Create a list of metadata using `meta_boxly()`. Using Lab data as example. +Step 1: Create metadata using the metalite package. Using Lab data as example. ```{r} -meta <- meta_boxly( - boxly_adsl, - boxly_adlb, - population_term = "apat", - observation_term = "wk12", - observation_subset = AVISITN <= 12 & !is.na(CHG) +analysis_plan <- metalite::plan( + analysis = "boxly", + population = "apat", + observation = "wk12", + parameter = "SODIUM" ) + +meta <- metalite::meta_adam( + population = boxly_adsl, + observation = boxly_adlb +) |> + metalite::define_plan(analysis_plan) |> + metalite::define_population( + name = "apat", + group = "TRTA", + subset = SAFFL == "Y", + label = "Safety Population" + ) |> + metalite::define_observation( + name = "wk12", + group = "TRTA", + var = "PARAM", + subset = AVISITN <= 12 & !is.na(CHG), + label = "Weeks 0 to 12" + ) |> + metalite::define_parameter( + name = "SODIUM", + label = "Sodium (mmol/L)", + subset = PARAMCD == "SODIUM" + ) |> + metalite::define_analysis( + name = "boxly", + label = "Interactive Box Plot", + x = "AVISITN", + y = "CHG" + ) |> + metalite::meta_build() ``` Step2: Call `prepare_boxly()` function to prepare the metadata as required by the user. In this example, we plan to add Baseline Value and Analysis Date, so besides the default "USUBJID" and "CHG"(as y axis label collected from meta mapping object),"BASE" and "ADT" are also included in the `hover_var_outlier`. @@ -124,16 +154,46 @@ Here, you will notice "Participant ID", "Parameter value","Base Value"and "Analy In this example, we plan to only display number of participant, Q1, mean, median, Q3 for the hover label of box. -Step1: Create a list of metadata using `meta_boxly()`. Using Vital Sign data as example. +Step 1: Create metadata using the metalite package. Using Vital Sign data as example. ```{r} -meta_boxly( - boxly_adsl, - boxly_advs, - population_term = "apat", - observation_term = "wk12", - observation_subset = AVISITN <= 12 & !is.na(CHG) +analysis_plan <- metalite::plan( + analysis = "boxly", + population = "apat", + observation = "wk12", + parameter = "PULSE" ) + +meta <- metalite::meta_adam( + population = boxly_adsl, + observation = boxly_advs +) |> + metalite::define_plan(analysis_plan) |> + metalite::define_population( + name = "apat", + group = "TRTA", + subset = SAFFL == "Y", + label = "Safety Population" + ) |> + metalite::define_observation( + name = "wk12", + group = "TRTA", + var = "PARAM", + subset = AVISITN <= 12 & !is.na(CHG), + label = "Weeks 0 to 12" + ) |> + metalite::define_parameter( + name = "PULSE", + label = "Pulse Rate (BEATS/MIN)", + subset = PARAMCD == "PULSE" + ) |> + metalite::define_analysis( + name = "boxly", + label = "Interactive Box Plot", + x = "AVISITN", + y = "CHG" + ) |> + metalite::meta_build() ``` Step2: Call `prepare_boxly()` function to prepare the metadata as required by the user. In this step, we did not change `hover_var_outlier`, so the hover label for the outlier will display the default value "Participant ID" and "Parameter value" for "USUBJID" and "CHG". @@ -155,13 +215,43 @@ Here, you will notice that only number of participant, Q1, mean, median, Q3 are In this example, we plan to combine Example 1 and Example 2 to customize label of outlier and label of box at the same step. Using ECG data as example. ```{r} -meta_boxly( - boxly_adsl, - boxly_adeg, - population_term = "apat", - observation_term = "wk12", - observation_subset = AVISITN <= 12 & !is.na(CHG) +analysis_plan <- metalite::plan( + analysis = "boxly", + population = "apat", + observation = "wk12", + parameter = "QTCF" ) + +meta <- metalite::meta_adam( + population = boxly_adsl, + observation = boxly_adeg +) |> + metalite::define_plan(analysis_plan) |> + metalite::define_population( + name = "apat", + group = "TRTA", + subset = SAFFL == "Y", + label = "Safety Population" + ) |> + metalite::define_observation( + name = "wk12", + group = "TRTA", + var = "PARAM", + subset = AVISITN <= 12 & !is.na(CHG), + label = "Weeks 0 to 12" + ) |> + metalite::define_parameter( + name = "QTCF", + label = "QTc Interval Fridericia (msec)", + subset = PARAMCD == "QTCF" + ) |> + metalite::define_analysis( + name = "boxly", + label = "Interactive Box Plot", + x = "AVISITN", + y = "CHG" + ) |> + metalite::meta_build() ``` ```{r} From 6f15f456970278800ba31fe8e13757e556e721f1 Mon Sep 17 00:00:00 2001 From: LittleBeannie Date: Mon, 10 Aug 2026 10:53:43 -0400 Subject: [PATCH 4/6] Update the Rd files --- man/boxly.Rd | 48 +++++++++++++++++++++++++++++++++++++++++------ man/meta_boxly.Rd | 48 ----------------------------------------------- 2 files changed, 42 insertions(+), 54 deletions(-) delete mode 100644 man/meta_boxly.Rd diff --git a/man/boxly.Rd b/man/boxly.Rd index 56cd912..78e1f35 100644 --- a/man/boxly.Rd +++ b/man/boxly.Rd @@ -43,14 +43,50 @@ Create an interactive box plot \examples{ # Only run this example in interactive R sessions if (interactive()) { - library(metalite) + analysis_plan <- metalite::plan( + analysis = "boxly", + population = "apat", + observation = "wk12", + parameter = "SODIUM;BILI" + ) - meta_boxly( - boxly_adsl, - boxly_adlb, - population_term = "apat", - observation_term = "wk12" + meta <- metalite::meta_adam( + population = boxly_adsl, + observation = boxly_adlb ) |> + metalite::define_plan(analysis_plan) |> + metalite::define_population( + name = "apat", + group = "TRTA", + subset = SAFFL == "Y", + label = "Safety Population" + ) |> + metalite::define_observation( + name = "wk12", + group = "TRTA", + var = "PARAM", + subset = AVISITN <= 12 & !is.na(CHG), + label = "Weeks 0 to 12" + ) |> + metalite::define_parameter( + name = "SODIUM", + label = "Sodium (mmol/L)", + subset = PARAMCD == "SODIUM" + ) |> + metalite::define_parameter( + name = "BILI", + label = "Bilirubin (mg/dL)", + subset = PARAMCD == "BILI" + ) |> + metalite::define_analysis( + name = "boxly", + label = "Interactive Box Plot", + x = "AVISITN", + y = "CHG" + ) |> + metalite::meta_build() + + meta |> prepare_boxly() |> boxly() } diff --git a/man/meta_boxly.Rd b/man/meta_boxly.Rd deleted file mode 100644 index 426631f..0000000 --- a/man/meta_boxly.Rd +++ /dev/null @@ -1,48 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/meta_boxly.R -\name{meta_boxly} -\alias{meta_boxly} -\title{Create an example metadata object} -\usage{ -meta_boxly( - dataset_adsl, - dataset_param, - population_term, - population_subset = SAFFL == "Y", - observation_term, - observation_subset = SAFFL == "Y", - parameters = unique(dataset_param$PARAMCD) -) -} -\arguments{ -\item{dataset_adsl}{ADSL source dataset.} - -\item{dataset_param}{Observation level source dataset for boxplot.} - -\item{population_term}{A character value of population term name.} - -\item{population_subset}{An unquoted condition for selecting the -populations from ADSL dataset.} - -\item{observation_term}{A character value of observation term name.} - -\item{observation_subset}{An unquoted condition for selecting the -observations from \code{dataset_param} dataset.} - -\item{parameters}{A chracter vector of parameters defined in \code{dataset_param$PARAMCD}} -} -\value{ -A metalite object. -} -\description{ -Create an example metadata object -} -\examples{ - -meta_boxly( - boxly_adsl, - boxly_adlb, - population_term = "apat", - observation_term = "wk12" -) -} From fb72c6655583f24448c6ab67c53a9139dde21aff Mon Sep 17 00:00:00 2001 From: LittleBeannie Date: Mon, 10 Aug 2026 10:54:04 -0400 Subject: [PATCH 5/6] Update the DESCRIPTION, NAMESPACE and README --- DESCRIPTION | 1 - NAMESPACE | 1 - README.md | 47 +++++++++++++++++++++++++++++++++++++++-------- _pkgdown.yml | 1 - 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8d77c4f..5fcf565 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,7 +23,6 @@ Depends: Imports: DT, brew, - rlang, crosstalk, ggplot2, htmlwidgets, diff --git a/NAMESPACE b/NAMESPACE index 25fdeb9..8c18ee4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,7 +1,6 @@ # Generated by roxygen2: do not edit by hand export(boxly) -export(meta_boxly) export(prepare_boxly) importFrom(ggplot2,.data) importFrom(ggplot2,aes) diff --git a/README.md b/README.md index 2cae6dc..51184a4 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,7 @@ inputs and outputs. The general workflow is: -1. Use `meta_boxly()` or metalite package to construct input metadata from ADaM datasets. - For example,. +1. Use the metalite package to construct input metadata from ADaM datasets. 1. Use `prepare_boxly()` to prepare datasets for interactive box plot. 1. Use `boxly()` to generate an interactive box plot. @@ -49,13 +48,45 @@ Here is a quick example using an example dataset: ```r library("boxly") -meta_boxly( - boxly_adsl, - boxly_adlb, - population_term = "apat", - observation_term = "wk12", - observation_subset = AVISITN <= 12 & !is.na(CHG) +analysis_plan <- metalite::plan( + analysis = "boxly", + population = "apat", + observation = "wk12", + parameter = "SODIUM" +) + +meta <- metalite::meta_adam( + population = boxly_adsl, + observation = boxly_adlb ) |> + metalite::define_plan(analysis_plan) |> + metalite::define_population( + name = "apat", + group = "TRTA", + subset = SAFFL == "Y", + label = "Safety Population" + ) |> + metalite::define_observation( + name = "wk12", + group = "TRTA", + var = "PARAM", + subset = AVISITN <= 12 & !is.na(CHG), + label = "Weeks 0 to 12" + ) |> + metalite::define_parameter( + name = "SODIUM", + label = "Sodium (mmol/L)", + subset = PARAMCD == "SODIUM" + ) |> + metalite::define_analysis( + name = "boxly", + label = "Interactive Box Plot", + x = "AVISITN", + y = "CHG" + ) |> + metalite::meta_build() + +meta |> prepare_boxly() |> boxly() ``` diff --git a/_pkgdown.yml b/_pkgdown.yml index 6f870bd..9eefabd 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -26,7 +26,6 @@ footer: reference: - title: Interactive box plot contents: - - meta_boxly - prepare_boxly - boxly - title: Example data From 0ae5f35df08c072b3890b7f10eefe515677deed4 Mon Sep 17 00:00:00 2001 From: LittleBeannie Date: Mon, 10 Aug 2026 14:55:55 +0000 Subject: [PATCH 6/6] Style code (GHA) --- tests/testthat/helper-meta_boxly.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/helper-meta_boxly.R b/tests/testthat/helper-meta_boxly.R index e37b7fc..9625b70 100644 --- a/tests/testthat/helper-meta_boxly.R +++ b/tests/testthat/helper-meta_boxly.R @@ -51,4 +51,4 @@ meta_boxly_test <- function( } metalite::meta_build(meta) -} \ No newline at end of file +}