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

249 remove analysis variable name plot title in spaghettiplot #251

Merged
merged 4 commits into from
Oct 10, 2024

Conversation

m7pr
Copy link
Contributor

@m7pr m7pr commented Jul 25, 2024

Close #249

Before the change
title_before

After the change

after

Tested with below

library(stringr)

# 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")

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("\\D+", "", 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(ANRLO = .5, ANRHI = 1) %>%
  rowwise() %>%
  group_by(PARAMCD) %>%
  mutate(LBSTRESC = ifelse(USUBJID %in% sample(USUBJID, 1, replace = TRUE),
                           paste("<", round(runif(1, min = .5, max = .7))), LBSTRESC
  )) %>%
  mutate(LBSTRESC = ifelse(USUBJID %in% sample(USUBJID, 1, replace = TRUE),
                           paste(">", round(runif(1, min = .9, max = 1.2))), LBSTRESC
  )) %>%
  ungroup()
attr(ADLB[["ARM"]], "label") <- var_labels[["ARM"]]
attr(ADLB[["ANRLO"]], "label") <- "Analysis Normal Range Lower Limit"
attr(ADLB[["ANRHI"]], "label") <- "Analysis Normal Range Upper Limit"

# add LLOQ and ULOQ variables
ADLB_LOQS <- goshawk:::h_identify_loq_values(ADLB, "LOQFL")
ADLB <- left_join(ADLB, ADLB_LOQS, by = "PARAM")

g_spaghettiplot(
  data = ADLB,
  subj_id = "USUBJID",
  biomarker_var = "PARAMCD",
  biomarker = "CRP",
  value_var = "AVAL",
  trt_group = "ARM",
  time = "AVISITCD",
  color_manual = color_manual,
  color_comb = "#39ff14",
  alpha = .02,
  xtick = c("BL", "W 1", "W 4"),
  xlabel = c("Baseline", "Week 1", "Week 4"),
  rotate_xlab = FALSE,
  group_stats = "median",
  hline_vars = c("ANRHI", "ANRLO"),
  hline_vars_colors = c("pink", "brown")
)

@m7pr m7pr added the core label Jul 25, 2024
@m7pr m7pr mentioned this pull request Jul 25, 2024
4 tasks
Copy link
Contributor

github-actions bot commented Jul 25, 2024

badge

Code Coverage Summary

Filename                           Stmts    Miss  Cover    Missing
-------------------------------  -------  ------  -------  ---------
R/g_boxplot.R                        116     116  0.00%    147-310
R/g_correlationplot.R                137     137  0.00%    251-421
R/g_density_distribution_plot.R       86      86  0.00%    125-236
R/g_lineplot.R                       275     275  0.00%    266-610
R/g_scatterplot.R                    130     130  0.00%    142-310
R/g_spaghettiplot.R                  101     101  0.00%    248-381
R/geom_axes_line.R                   167     167  0.00%    46-358
R/t_summarytable.R                   102     102  0.00%    87-224
R/utils.R                             70      70  0.00%    17-137
TOTAL                               1184    1184  0.00%

Diff against main

Filename      Stmts    Miss  Cover
----------  -------  ------  --------
TOTAL             0       0  +100.00%

Results for commit: 0938358

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@npaszty npaszty changed the title 249 remove biomarker name from the plot legend in spaghettiplot 249 remove analysis variable name plot title in spaghettiplot Jul 25, 2024
@npaszty
Copy link
Contributor

npaszty commented Jul 25, 2024

@m7pr

there was a misunderstanding. the issue is not to remove the biomarker name from the legend. the legend is fine.

the issue is to remove the analysis variable name from the title.

I updated the MR title. please see issue description #249

@m7pr
Copy link
Contributor Author

m7pr commented Jul 29, 2024

@npaszty the code and the example are related to the removal of the TITLE. the only mistake I made was to put LEGEND in the title of this PR/MR but the provided fix removes the unneeded component from the plot TITLE - see print screens from the initial comment

@m7pr m7pr requested a review from edelarua July 29, 2024 12:49
Copy link
Contributor

@edelarua edelarua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to go if Nick is happy with the solution. Thanks @m7pr!

@npaszty
Copy link
Contributor

npaszty commented Jul 31, 2024

@m7pr

yes, that's the problem, the printscreen from the initial comment has the incorrect compoonent of the title removed. "AVAL" chould be removed not the not the biomarker variable label.

also note that the units are missing from the y-axis label. this is an inconsistency isdentifed in another issue #248

image

R/g_spaghettiplot.R Outdated Show resolved Hide resolved
Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
@m7pr
Copy link
Contributor Author

m7pr commented Aug 1, 2024

Ah, got it @npaszty !
Sorry for that. I just send a push with an update.

Removed AVAL and left the biomarker

image

@m7pr m7pr merged commit 4f90f9f into main Oct 10, 2024
25 checks passed
@m7pr m7pr deleted the 249_remove_biomarker_spaghetti@main branch October 10, 2024 12:50
@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spahghetti Plot
3 participants