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

241: adding parameter to adjust dot size. #242

Merged
merged 2 commits into from
May 31, 2024
Merged

Conversation

kartikeyakirar
Copy link
Contributor

Fixes #241

I have added dot_size as a parameter to adjust the size and default to 3.

goshawk examples
pkgload::load_all("goshawk")
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"),
dot_size = 2
)

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_arb = 1.3,
  hline_vars = c("ANRHI", "ANRLO", "ULOQN", "LLOQN"),
  hline_vars_colors = c("pink", "brown", "purple", "gray"),
dot_size = 5
)

Copy link
Contributor

github-actions bot commented May 31, 2024

badge

Code Coverage Summary

Filename                           Stmts    Miss  Cover    Missing
-------------------------------  -------  ------  -------  ---------
R/g_boxplot.R                        116     116  0.00%    147-310
R/g_correlationplot.R                135     135  0.00%    251-419
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                               1182    1182  0.00%

Diff against main

Filename               Stmts    Miss  Cover
-------------------  -------  ------  --------
R/g_spaghettiplot.R       -1      -1  +100.00%
TOTAL                     -1      -1  +100.00%

Results for commit: 1887a7e

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

R/g_lineplot.R Outdated Show resolved Hide resolved
R/g_lineplot.R Show resolved Hide resolved
Copy link
Contributor

@vedhav vedhav left a comment

Choose a reason for hiding this comment

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

After resolving the comments it LGTM!

@kartikeyakirar kartikeyakirar merged commit e8bc12c into main May 31, 2024
28 checks passed
@kartikeyakirar kartikeyakirar deleted the 241_sym_size branch May 31, 2024 06:01
@github-actions github-actions bot locked and limited conversation to collaborators May 31, 2024
@kartikeyakirar
Copy link
Contributor Author

@npaszty The point size issue has been resolved and the update has been released to R-universe.

@npaszty
Copy link
Contributor

npaszty commented May 31, 2024

@kartikeyakirar

that looks great from a goshawk spaghetti plot perspective.

is it my imagination or did the lineplot symbols also get bigger by default?

I decided to also install the latest version of teal.goshawk thinking there might be an update to the tm_spaghetti plot UI to be able to control the dot size. while I do see the dot_size argument in spaghetti plot, version 0.1.15.9021 doesn't have the dot size control in the UI like boxplot and correlation plot.

it would be helpful to have consistency across the goshawk and teal.goshawk functions where data points are displayed. can that also be done for tm_spaghetti plot so that the UIs are consistent? thanks!

image

@kartikeyakirar
Copy link
Contributor Author

@npaszty,

Thank you for your feedback!

You’re right; the lineplot symbols appear bigger due to the default dot_size value. This can be adjusted via the dot_size argument.

I’ve also updated teal.goshawk with the suggested changes. Now, both the lineplot and spaghettiplot modules have the dot_size control in the UI within theplot_with_settingssection.

You can check out the updates here: PR #277.

@npaszty
Copy link
Contributor

npaszty commented Jun 3, 2024

@kartikeyakirar

thanks for opening the PR in teal.goshawk. having those UI elements will be helpful.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adjust Symbol Size in LoQ Legend and Spaghetti Plot
3 participants