Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correlation Plot: Warning: Unknown or uninitialised column: AVALU. #294

Closed
m7pr opened this issue Jul 25, 2024 · 8 comments · Fixed by #307
Closed

Correlation Plot: Warning: Unknown or uninitialised column: AVALU. #294

m7pr opened this issue Jul 25, 2024 · 8 comments · Fixed by #307
Assignees
Labels
bug Something isn't working core low-priority

Comments

@m7pr
Copy link
Contributor

m7pr commented Jul 25, 2024

Each time a variable in the encoding section of correlationplot is changed in Theory App, the below message is displayed in the shiny console

Warning: Unknown or uninitialised column: `AVALU`.
@m7pr m7pr added bug Something isn't working core labels Jul 25, 2024
@m7pr
Copy link
Contributor Author

m7pr commented Jul 25, 2024

Also mentioned in here #287

creates warning in console "Warning: Unknown or uninitialised column: AVALU." Perhaps it is coming from the title and axis label where a lab unit should be displayed like in the other modules? if so then this is a goshawk issue I beleieve

@npaszty
Copy link
Contributor

npaszty commented Jul 25, 2024

@m7pr

let me go through the issues on recent findings and ensure we have a cohesive approach to them. it might result in consolidating/closing some of them.

@npaszty npaszty changed the title Warning: Unknown or uninitialised column: AVALU. Correlation Plot: Warning: Unknown or uninitialised column: AVALU. Jul 25, 2024
@npaszty
Copy link
Contributor

npaszty commented Jul 25, 2024

@m7pr

beleive this bug issue needs to stay here in teal.goshawk to investigate first. using the roxigen example and looking at the data being created in the environment and passed to the module, ADLB$AVALU does exist.

so I think the first step is to see if this warning is coming from the module processing code. when I run the goshawk roxigen example there is no AVALU warning but does use AVALU as the value for the unti argument. looks like the title code in goshawk has been removed and the unit argument no longer does anything in the goshawk context. 😢

from teal.goshawk title/label code which along with the warning is why the correlation plot title and

setup the x-axis label. Combine the biomarker and the units (if available)

  if (is.null(ANL$AVALU) || all(ANL[["AVALU"]] == "")) {
    title_text <- paste(xparam, "and", yparam, "@ Visits")
    xaxis_lab <- paste(xparam, input$xaxis_var, "Values")
    yaxis_lab <- paste(yparam, input$yaxis_var, "Values")
  } else {
    xunit <- ANL$AVALU[ANL[[param_var]] == input$xaxis_param][1]
    yunit <- ANL$AVALU[ANL[[param_var]] == input$yaxis_param][1]

    title_text <- paste0(xparam, " (", xunit, ") and ", yparam, " (", yunit, ") @ Visits")
    xaxis_lab <- paste0(xparam, " (", xunit, ") ", input$xaxis_var, " Values")
    yaxis_lab <- paste0(yparam, " (", yunit, ") ", input$yaxis_var, " Values")
  }

  list(title_text = title_text, xaxis_lab = xaxis_lab, yaxis_lab = yaxis_lab)
})

from teal gallery app you can see that the ADLB data does include AVALU and PARAMCD does have a unit value but it is not being included in the title or the x-axis or y-axis label.
image

@npaszty
Copy link
Contributor

npaszty commented Jul 25, 2024

@m7pr

set to low-priority as it isn't a blocker for now to needing to tag and release.

@donyunardi
Copy link
Contributor

donyunardi commented Aug 8, 2024

Acceptance Criteria:

  • Investigate where the warning is coming from
  • Warning should not always appear each time a variable in the encoding section of correlation plot is changed
  • If the scope of the solution/fix is bigger than expected (e.g., the issue originates from the framework rather than goshawk/teal.goshawk), then refine it into an actionable issue for further assessment.

@m7pr m7pr self-assigned this Sep 16, 2024
@m7pr
Copy link
Contributor Author

m7pr commented Sep 16, 2024

Getting back to this. So the warning exists in the regular example from the documentation as well

# Example using ADaM structure analysis dataset.
data <- teal_data()
data <- within(data, {
  library(dplyr)
  library(stringr)
  
  # use non-exported function from goshawk
  h_identify_loq_values <- getFromNamespace("h_identify_loq_values", "goshawk")
  
  # original ARM value = dose value
  arm_mapping <- list(
    "A: Drug X" = "150mg QD",
    "B: Placebo" = "Placebo",
    "C: Combination" = "Combination"
  )
  color_manual <- c("150mg QD" = "#000000", "Placebo" = "#3498DB", "Combination" = "#E74C3C")
  # assign LOQ flag symbols: circles for "N" and triangles for "Y", squares for "NA"
  shape_manual <- c("N" = 1, "Y" = 2, "NA" = 0)
  
  set.seed(1)
  ADSL <- rADSL
  ADLB <- rADLB
  var_labels <- lapply(ADLB, function(x) attributes(x)$label)
  ADLB <- ADLB %>%
    mutate(AVISITCD = case_when(
      AVISIT == "SCREENING" ~ "SCR",
      AVISIT == "BASELINE" ~ "BL",
      grepl("WEEK", AVISIT) ~
        paste(
          "W",
          trimws(
            substr(
              AVISIT,
              start = 6,
              stop = str_locate(AVISIT, "DAY") - 1
            )
          )
        ),
      TRUE ~ NA_character_
    )) %>%
    mutate(AVISITCDN = case_when(
      AVISITCD == "SCR" ~ -2,
      AVISITCD == "BL" ~ 0,
      grepl("W", AVISITCD) ~ as.numeric(gsub("[^0-9]*", "", AVISITCD)),
      TRUE ~ NA_real_
    )) %>%
    # use ARMCD values to order treatment in visualization legend
    mutate(TRTORD = ifelse(grepl("C", ARMCD), 1,
                           ifelse(grepl("B", ARMCD), 2,
                                  ifelse(grepl("A", ARMCD), 3, NA)
                           )
    )) %>%
    mutate(ARM = as.character(arm_mapping[match(ARM, names(arm_mapping))])) %>%
    mutate(ARM = factor(ARM) %>%
             reorder(TRTORD)) %>%
    mutate(
      ANRHI = case_when(
        PARAMCD == "ALT" ~ 60,
        PARAMCD == "CRP" ~ 70,
        PARAMCD == "IGA" ~ 80,
        TRUE ~ NA_real_
      ),
      ANRLO = case_when(
        PARAMCD == "ALT" ~ 20,
        PARAMCD == "CRP" ~ 30,
        PARAMCD == "IGA" ~ 40,
        TRUE ~ NA_real_
      )
    ) %>%
    rowwise() %>%
    group_by(PARAMCD) %>%
    mutate(LBSTRESC = ifelse(
      USUBJID %in% sample(USUBJID, 1, replace = TRUE),
      paste("<", round(runif(1, min = 25, max = 30))), LBSTRESC
    )) %>%
    mutate(LBSTRESC = ifelse(
      USUBJID %in% sample(USUBJID, 1, replace = TRUE),
      paste(">", round(runif(1, min = 70, max = 75))), LBSTRESC
    )) %>%
    ungroup()
  attr(ADLB[["ARM"]], "label") <- var_labels[["ARM"]]
  attr(ADLB[["ANRHI"]], "label") <- "Analysis Normal Range Upper Limit"
  attr(ADLB[["ANRLO"]], "label") <- "Analysis Normal Range Lower Limit"
  
  # add LLOQ and ULOQ variables
  ADLB_LOQS <- h_identify_loq_values(ADLB, "LOQFL")
  ADLB <- left_join(ADLB, ADLB_LOQS, by = "PARAM")
})

datanames <- c("ADSL", "ADLB")
datanames(data) <- datanames

join_keys(data) <- default_cdisc_join_keys[datanames]

app <- init(
  data = data,
  modules = modules(
    tm_g_gh_correlationplot(
      label = "Correlation Plot",
      dataname = "ADLB",
      param_var = "PARAMCD",
      xaxis_param = choices_selected(c("ALT", "CRP", "IGA"), "ALT"),
      yaxis_param = choices_selected(c("ALT", "CRP", "IGA"), "CRP"),
      xaxis_var = choices_selected(c("AVAL", "BASE", "CHG", "PCHG"), "BASE"),
      yaxis_var = choices_selected(c("AVAL", "BASE", "CHG", "PCHG"), "AVAL"),
      trt_group = choices_selected(c("ARM", "ACTARM"), "ARM"),
      color_manual = c(
        "Drug X 100mg" = "#000000",
        "Placebo" = "#3498DB",
        "Combination 100mg" = "#E74C3C"
      ),
      shape_manual = c("N" = 1, "Y" = 2, "NA" = 0),
      plot_height = c(500, 200, 2000),
      facet_ncol = 2,
      visit_facet = TRUE,
      reg_line = FALSE,
      loq_legend = TRUE,
      font_size = c(12, 8, 20),
      dot_size = c(1, 1, 12),
      reg_text_size = c(3, 3, 10),
      hline_arb = c(40, 50),
      hline_arb_label = "arb hori label",
      hline_arb_color = c("red", "blue"),
      hline_vars = c("ANRHI", "ANRLO", "ULOQN", "LLOQN"),
      hline_vars_colors = c("green", "blue", "purple", "cyan"),
      hline_vars_labels = c("ANRHI Label", "ANRLO Label", "ULOQN Label", "LLOQN Label"),
      vline_vars = c("ANRHI", "ANRLO", "ULOQN", "LLOQN"),
      vline_vars_colors = c("yellow", "orange", "brown", "gold"),
      vline_vars_labels = c("ANRHI Label", "ANRLO Label", "ULOQN Label", "LLOQN Label"),
      vline_arb = c(50, 70),
      vline_arb_label = "arb vert A",
      vline_arb_color = c("green", "orange")
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}
image

And indeed it comes from the place which @npaszty pointed

> is.null(ANL$AVALU) || all(ANL[["AVALU"]] == "")
[WARN] 2024-09-16 12:26:11.4810 pid:13156 token:[52144bb2] teal.goshawk Unknown or uninitialised column: `AVALU`.
[1] TRUE

@m7pr
Copy link
Contributor Author

m7pr commented Sep 16, 2024

Confirming AVALU exists in init data for ADLB, but it does not exist in data prepared for the plot.

> is.null(data@env$ADLB$AVALU)
[1] FALSE
> length(data@env$ADLB$AVALU)
[1] 8400

@m7pr
Copy link
Contributor Author

m7pr commented Sep 16, 2024

PR raised in here #307

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core low-priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants