Skip to content

Commit

Permalink
Merge pull request #47 from RConsortium/app_output_refine
Browse files Browse the repository at this point in the history
Refine application output and ADRG updates
  • Loading branch information
rpodcast authored Oct 3, 2022
2 parents 3edd75f + bff962a commit 6299dfe
Show file tree
Hide file tree
Showing 25 changed files with 646 additions and 420 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
.RData
.Ruserdata
pilot2wrappers.Rcheck/
pilot2wrappers*.tar.gz
pilot2wrappers*.tgz
inst/doc
.DS_Store
rsconnect/
9 changes: 9 additions & 0 deletions .renvignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.Rproj.user
.Rhistory
.Ruserdata
inst/
rsconnect/
dev/
vignettes/
pkgdown/
.devcontainer/
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: pilot2wrappers
Type: Package
Title: R Consortium R Submission Pilot 2
Version: 0.4.0
Version: 0.5.0
Authors@R: c(
person("Eric", "Nantz", email = "[email protected]", role = c("aut", "cre")),
person("Yilong", "Zhang", role = c("aut")),
Expand Down Expand Up @@ -39,12 +39,14 @@ Imports:
htmltools,
pkgload,
tippy,
markdown
markdown,
purrr
Suggests:
devtools,
testthat,
knitr,
rmarkdown
rmarkdown,
pkglite
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# pilot2wrappers 0.5.0

- Hide p-values when a data filter is applied, and display only when no filters are applied. This addresses comments from FDA reviewers after they saw a preview of the application.
- Add a new description in the App Information module regarding display of p-values.
- Add another footnote to the primary and efficacy table displays regarding the p-value display.
- Increase plot window height for KM module, improving readability

# pilot2wrappers 0.4.0

- Ensure column width of efficacy table's 95% CI header is wide enough to fit in a single row
Expand Down
7 changes: 4 additions & 3 deletions R/eff_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
#' @param data Source dataset (filtered by flags)
#' @param var Variable on which model should be run
#' @param wk Visit to be modeled
#' @param show_pvalue Indicator to display p-values in table
#'
#' @return Formatted dataframe
#'
#' @importFrom dplyr filter mutate case_when rowwise select bind_rows arrange
#' @importFrom stats drop1 confint
#' @export
#'
efficacy_models <- function(data, var=NULL, wk=NULL) {
efficacy_models <- function(data, var=NULL, wk=NULL, show_pvalue = TRUE) {
# Need to set contrasts to work for Type III SS. See analysis results metadata for
# table 14-3.01. Reference for R here: https://www.r-bloggers.com/anova-%E2%80%93-type-iiiiii-ss-explained/
op <- options(contrasts = c("contr.sum","contr.poly"))
Expand Down Expand Up @@ -55,7 +56,7 @@ efficacy_models <- function(data, var=NULL, wk=NULL) {

# Pull it out into a table
sect1 <- tibble::tibble(row_label=c('p-value(Dose Response) [1][2]'),
`81` = c(num_fmt(ancova[2, 'Pr(>F)'], int_len=4, digits=3, size=12))
`81` = ifelse(show_pvalue, c(num_fmt(ancova[2, 'Pr(>F)'], int_len=4, digits=3, size=12)), "Not Applicable")
) %>%
pad_row()

Expand All @@ -81,7 +82,7 @@ efficacy_models <- function(data, var=NULL, wk=NULL) {
rowwise() %>%
# Create the display strings
mutate(
p = num_fmt(p.value, int_len=4, digits=3, size=12),
p = ifelse(show_pvalue, num_fmt(p.value, int_len=4, digits=3, size=12), "Not Applicable"),
diff_se = as.character(
glue::glue('{num_fmt(estimate, int_len=2, digits=1, size=4)} ({num_fmt(SE, int_len=1, digits=2, size=4)})')
),
Expand Down
19 changes: 19 additions & 0 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,23 @@ set_data_path <- function(path) {
# set golem config option
golem::amend_golem_config("adam_path", path, talkative = FALSE)
invisible(TRUE)
}

#' check if a filter is active in a teal module
#'
#' @param datasets instance of teal filtered datasets class
#'
#' @return boolean, TRUE if a filter is applied, FALSE otherwise
filter_active <- function(datasets) {
result <- FALSE
if (length(names(datasets$get_filter_state()) > 0)) {
filter_use <- purrr::map_lgl(names(datasets$get_filter_state()), ~{
# grab call of filter code
f_call <- datasets$get_call(.x)$filter
f_call != glue::glue("{.x}_FILTERED <- {.x}")
})
result <- any(filter_use)
}

return(result)
}
2 changes: 1 addition & 1 deletion R/tm_g_kmplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' @importFrom shiny NS tagList plotOutput
ui_g_kmplot <- function(id, datasets) {
ns <- NS(id)
plotOutput(ns("plot"))
plotOutput(ns("plot"), height = "800px")
}

#' srv_g_kmplot Server Functions
Expand Down
7 changes: 4 additions & 3 deletions R/tm_t_efficacy.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ ui_t_efficacy <- function(id, datasets) {
tags$br(),
tags$hr(),
fluidRow(
h6(tags$i("Abbreviations: CI=Confidence Interval; LS=Least Squarses; SD=Standard Deviation"))
h6(tags$i("Abbreviations: CI=Confidence Interval; LS=Least Squares; SD=Standard Deviation")),
h6(tags$p("Statistical model and comparison p-values removed when applying data filters. Refer to the application information for additional details."))
)
)
}
Expand Down Expand Up @@ -112,7 +113,7 @@ srv_t_efficacy <- function(input, output, session, datasets) {
mutate(
comp = "Study Drug vs. Placebo",
mean = fmt_ci(estimate, lower, upper),
p = fmt_pval(p.value)
p = ifelse(filter_active(datasets), "Not Applicable", fmt_pval(p.value))
) %>%
select(comp:p)

Expand Down Expand Up @@ -168,7 +169,7 @@ srv_t_efficacy <- function(input, output, session, datasets) {
reactable(
apr0ancova2,
columns = collist,
defaultColDef = colDef(footerStyle = list(fontStyle = "itatlic"))
defaultColDef = colDef(footerStyle = list(fontStyle = "italic"))
)
})
}
3 changes: 2 additions & 1 deletion R/tm_t_primary.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ui_t_primary <- function(id, datasets) {
ns <- NS(id)
tagList(
uiOutput(ns("table")),
p("Statistical model and comparison p-values removed when applying data filters. Refer to the application information for additional details."),
p("[1] Based on Analysis of covariance (ANCOVA) model with treatment and site group as factors and baseline value as a covariate."),
p("[2] Test for a non-zero coefficient for treatment (dose) as a continuous variable."),
p("[3] Pairwise comparison with treatment as a categorical variable: p-values without adjustment for multiple comparisons.")
Expand Down Expand Up @@ -61,7 +62,7 @@ srv_t_primary <- function(input, output, session, datasets) {


## -----------------------------------------------------------------------------------------------------------------------------------
model_portion <- efficacy_models(adas, 'CHG', 24)
model_portion <- efficacy_models(adas, 'CHG', 24, !filter_active(datasets))


## -----------------------------------------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion dev/03_deploy.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ devtools::build(path = "renv/cellar")
devtools::build(path = "renv/cellar", binary = TRUE)

# Install to renv library
renv::install("renv/cellar/pilot2wrappers_0.2.0.tar.gz")
renv::install(file.path(getwd(), "renv/cellar/pilot2wrappers_0.5.0.tar.gz"))

# Deploy

Expand Down
7 changes: 5 additions & 2 deletions inst/app/docs/about.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
## Introduction
# Introduction

This application is intended for a pilot submission to the FDA composing of a Shiny application, as part of the [R Submissions Working Group](https://rconsortium.github.io/submissions-wg/) Pilot 2. The data sets and results displayed in the application originate from the [Pilot 1 project](https://rconsortium.github.io/submissions-wg/pilot-overall.html#pilot-1---common-analyses). Below is a brief description of the rest of the application:

## Note on Dynamic Filters

This application enables dynamic filtering of the input datasets used within each of the modules described below. When one or more filters are applied, the statistical estimates displayed in the table or visualization will dynamically update. However, since the statistical models and comparison methods were not powered for dynamic subgroups produced by these filters, p-values will be removed from the view until all filters are removed.
### Demographic Table

In this interface, summary statistics associated with baseline clinical characteristics and other demographic factors is shown.
Expand All @@ -16,4 +19,4 @@ A summary table of the primary efficacy analysis is shown for each of the time p

### Efficacy Table

A summary table of an additional efficacy analysis is shown for baseline and week 20. The efficacy variable (Glucose) was analzying using ANCOVA model with treatment and baseline value as covariates, comparing Placebo to Xanomeline High Dose.
A summary table of an additional efficacy analysis is shown for baseline and week 20. The efficacy variable (Glucose) was analzying using ANCOVA model with treatment and baseline value as covariates, comparing Placebo to Xanomeline High Dose.
2 changes: 1 addition & 1 deletion inst/golem-config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default:
golem_name: pilot2wrappers
golem_version: 0.4.0
golem_version: 0.5.0
app_prod: no
adam_path: "datasets/adam"
production:
Expand Down
2 changes: 1 addition & 1 deletion inst/startup.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Project Level Setup
R_version <- "4.2.0" # set up project R version
snapshot <- "2022-02-01" # set up snapshot date
snapshot <- "2022-09-01" # set up snapshot date
teal_snapshot <- "2022-06-09"
repos <- c(
paste0("https://packagemanager.rstudio.com/cran/", snapshot),
Expand Down
4 changes: 3 additions & 1 deletion man/efficacy_models.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions man/filter_active.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6299dfe

Please sign in to comment.