Skip to content

Commit

Permalink
Merge branch 'ui-phase2' of https://github.com/pfizer-opensource/carver
Browse files Browse the repository at this point in the history
… into ui-phase2
  • Loading branch information
sahas56 committed Sep 23, 2024
2 parents 84cf453 + 69aae53 commit da7c701
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
21 changes: 10 additions & 11 deletions R/edish_plot.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' Process data for eDISH plot
#'
#' @param datain Input dataset.
Expand Down Expand Up @@ -47,7 +46,7 @@ process_edish_data <- function(datain,
"Please provide valid PARAMCD" =
all(c(alt_paramcd, ast_paramcd, bili_paramcd) %in% datain$PARAMCD)
)

hy_data <- datain |>
filter(.data$PARAMCD %in% c(alt_paramcd, ast_paramcd, bili_paramcd)) |>
mutate(maxv = .data$AVAL / .data$ANRHI) |>
Expand All @@ -58,7 +57,7 @@ process_edish_data <- function(datain,
TRUE ~ "bili"
)
)

hy <- hy_data |>
group_by(across(all_of(c("USUBJID", "TRTVAR", "PARAMCD", "PARAM", "PARM")))) |>
summarise(x = max(.data$maxv)) |>
Expand All @@ -67,21 +66,21 @@ process_edish_data <- function(datain,
names_from = PARM,
values_from = x
)

if (xvar %in% c("alt", "ast")) {
hy <- hy |> mutate(XVAR = .data[[xvar]])
} else {
hy <- hy |> mutate(XVAR = pmax(.data$ast, .data$alt))
}

hy |>
mutate(
text = paste0(
"Subjid = ",
USUBJID,
"\n",
ifelse(xvar == "both", "Max of ALT/AST = ",
paste("value of", toupper(xvar), "=")
paste("value of", toupper(xvar), "=")
),
round(XVAR, 3),
"\n",
Expand Down Expand Up @@ -198,7 +197,7 @@ edish_plot <- function(datain,
),
interactive = "N") {
stopifnot(is.data.frame(datain))

### Modified plot options ####
if (length(axis_opts$Xbrks) > 0 && length(axis_opts$Xlims) > 0) {
axis_opts$Xlims[2] <- max(ceiling(max(datain$XVAR)), axis_opts$Xlims)
Expand All @@ -207,7 +206,7 @@ edish_plot <- function(datain,
max(axis_opts$Xbrks)
)
}

if (length(axis_opts$Ybrks) > 0 && length(axis_opts$Ylims) > 0) {
axis_opts$Ylims[2] <- max(ceiling(max(datain$XVAR)), axis_opts$Ylims)
axis_opts$Ybrks[which.max(axis_opts$Ybrks)] <- min(
Expand All @@ -229,9 +228,9 @@ edish_plot <- function(datain,
max(as.numeric(yrefline[1]), max(axis_opts$Ybrks)),
as.numeric(yrefline[1]) - 0.2
)

# for ploting values per subject

sp <- datain |>
scatter_plot(
axis_opts = axis_opts,
Expand Down Expand Up @@ -287,7 +286,7 @@ edish_plot <- function(datain,
y = quad_labels_opts_y[4],
label = quad_labels[4]
)

# ggplotly if interactive
if (interactive == "Y") {
sp <- as_plotly(plot = sp, hover = c("text"))
Expand Down
6 changes: 3 additions & 3 deletions R/mod_generic_filters.R
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ mod_generic_filters_server <-
choices = pct_denom
)
})

observe({
req(domain())
if (repName() == "eDISH_plot") {
Expand Down Expand Up @@ -690,7 +690,7 @@ mod_generic_filters_server <-
input$treatment1, input$treatment2, input$pctdisp, input$denom_subset,
input$trtbign, input$ae_hlt
))

observe({
req(sourcedata())
req(domain())
Expand All @@ -705,7 +705,7 @@ mod_generic_filters_server <-
merged_df <- sourcedata()$adsl %>%
adsl_merge(
dataset_add = filter(sourcedata()$adlb, !!!rlang::parse_exprs(input$a_subset))
) %>%
) %>%
mentry(
subset = input$overall_subset,
byvar = NA_character_,
Expand Down

0 comments on commit da7c701

Please sign in to comment.