ggPMXdevelopment / ggPMX

ggPMX R package
37 stars 11 forks source link

IWRES Quantile plot #63

Closed biethbr1 closed 2 years ago

biethbr1 commented 4 years ago
ctr <- theophylline()
max.iwres <- 3
ctr %>% pmx_plot_iwres_qq(
  strat.color = "SEX", 
  cats.labels = list(SEX=c("0"="M","1"="F")), use.labels = TRUE, 
  ranges = list(x = c(-max.iwres*1.05, max.iwres*1.05), y = c(-max.iwres*1.05, max.iwres*1.05)) ,  
  hline = list(yintercept = 0, color = "black", size = 0.25), 
  vline = list(xintercept = 0, color = "black", size = 0.25), 
  use.identity_line = F,
  identity_line = list (color = "red", linetype = 3))

Additional issues:

Response from Amine Gassem:

ctr <- theophylline(
  pmx_settings(cats.labels = list(SEX=c("0"="M","1"="F")), 
               use.labels = TRUE)
)

ctr %>% pmx_plot_iwres_qq(
  strat.facet = "SEX", 
  reference_line = list (color = "red", linetype = 3)) 

Further investigation:

(Old Ticket #237)

tynesjo commented 3 years ago

Failed to reproduce the reported bug strat error does not work.

ctr <- theophylline(
  settings=pmx_settings(
    cats.labels=list(SEX=c("0"="M","1"="F")), 
    use.labels = TRUE,
    use.identity_line=FALSE,
    identity_line = list (color = "red", linetype = 3),
    reference_line = list (color = "red", linetype = 3)
  )
)

# Issue: facet not working (Failed to reproduce) 
p0a <-
  ctr %>%
  pmx_plot_iwres_qq(
    #  strat.facet = "SEX", 
  reference_line=list(color="red", linetype=3)
  ) 

p0b <-
  ctr %>%
  pmx_plot_iwres_qq(
  strat.facet = "SEX", 
  reference_line=list(color="red", linetype=3)
) 

here p0a yields no facets: p0a

while p0b does yield facets: p0b

tynesjo commented 3 years ago

Regarding the reported bugs no reference line for this plot: as show by the following code snippets and outputs, is.reference_line has to be explicitly set to TRUE for a reference line to be plotted.

p1a <-
  ctr %>%
  pmx_plot_iwres_qq(
    strat.facet = "SEX",
#    is.reference_line=TRUE,
    is.identity_line=TRUE,
    identity_line=list(color="red", linetype=3),
    reference_line=list(color="red", linetype=3)
  )

p1b <-
  ctr %>%
  pmx_plot_iwres_qq(
    strat.facet = "SEX",
    is.reference_line=TRUE,
    is.identity_line=FALSE,
    identity_line=list(color="red", linetype=3),
    reference_line=list(color="goldenrod", linetype=3)
  )

(using the control object from the previous comment)

here p1a shows no reference line:

p1a

whereas p1b does show one, (as expliticly asked for): p1b

tynesjo commented 3 years ago

Regarding the reported bug that identity line graphical parameters cannot be customized e.g. color and linetype.

Failed to reproduce this bug.

Below is a code snippet and resulting graphical output which shows customization working.

ctr %>%
pmx_plot_iwres_qq(
  strat.facet = "SEX",
  is.identity_line=TRUE,
  identity_line=list(color="pink", linetype=4, size=2)
)

Resulting graphical output: p2

tynesjo commented 3 years ago

Regarding the reported bug that Adding stratificiation color leads to extra points on plot.

Failed to reproduce this bug.

Below is a code snippet and resulting graphical outputs:

p3a <-
  ctr %>%
  pmx_plot_iwres_qq(
    strat.facet = "SEX",
    strat.color = "SEX"
  )

p3b <-
  ctr %>%
  pmx_plot_iwres_qq(
    strat.facet = "SEX",
    is.reference_line=FALSE
  )

Here p3a yields:

p3a

and, p3b yields: p3b

tynesjo commented 3 years ago

Regarding the reported bug that imposing x-axis ranges do not take effect: they take effect but only on eliminating data from the plot, not setting the limits of the x axis:

p8a <-
  ctr %>%
  pmx_plot_iwres_qq(
    ranges=list(
      x=c(-1L, 1L),
      y=c(-1L, 1L)
      ),
    discrete=FALSE
  )

p8b <-
  ctr %>%
  pmx_plot_iwres_qq()

Here p8a yields: p8a

and p8b yields: p8b

@biethbr1 is this the desired behavior?

tynesjo commented 3 years ago

Regarding the reported bug that style of hline is not configurable:

Failed to reproduce. Please see below example of two different plots with hline style settings taking effect:

p9a <-
  ctr %>%
  pmx_plot_iwres_qq(
    is.hline=TRUE,
   hline = list(yintercept=0, color="blue", size=3)
  )

p9b <-
  ctr %>%
  pmx_plot_iwres_qq(
    is.hline=TRUE  
  )

Here p9a yields: p9a

whereas p9b yields:

p9b

tynesjo commented 3 years ago

Regarding the reported bug that style of vline is not configurable.

This bug was found to be due to a missing feature: vline was not an implemented layer for QQ plots.

The feature has not been implemented in the issue branch (pull request TBA); resulting in the following functionality:

p10a <-
  ctr %>%
  pmx_plot_iwres_qq(
    is.vline=TRUE,
    vline = list(xintercept=0, color="blue", size=3)
  )

p10b <-
  ctr %>%
  pmx_plot_iwres_qq(
    is.vline=TRUE,
    vline = list(xintercept=0)
  )

Here p10a yields:

p10a

whereas p10b yields:

p10b

tynesjo commented 3 years ago

Regarding the reported bug that BLOQ points should be a different color.

This is not a bug, but rather due to the fact that no BLOQ layer has been implemented for QQ pplots.

Suggest creating a feature request if it is desirable to have this functionality.

tynsci commented 2 years ago