Open biethbr1 opened 4 years ago
Hi @biethbr1 Please check findings/questions/solutions:
2.1 Workaround approach: by adding facet_grid function with labeller argument.
mlxpath <- file.path(system.file(package = "ggPMX"),
"testdata", "1_popPK_model", "project.mlxtran")
ctr <- pmx_mlxtran(mlxpath, config = "standing", settings = mySet)
ctr %>% pmx_plot_eta_cats(labels = list(title = "EBE vs discrete covariates")) +
facet_grid(EFFECT~variable,
labeller = labeller(
variable=c('SEX'="Gender", 'RACE'="Race", 'DISE' = "Disease", 'ILOW' = "I low"),
EFFECT=c('CL'= "first", 'F'= "second", 'Vc'= "third", 'Vp1'= "forth")
))
2.2 Make changes in existing code:
if (!is.null(x$facets))
p <- p + facet_grid(stats::as.formula("EFFECT~variable"), scales = "free", labeller = x$facets$labeller)
Call will look like:
mySet=pmx_settings(is.draft=FALSE, use.abbrev = FALSE, use.labels = TRUE,
cats.labels = list(
RACE = c("0"= "As", "1"="Bl"),
variable=c('SEX'="Gender", 'RACE'="Race", 'DISE' = "Disease", 'ILOW' = "I low"),
EFFECT=c('CL'= "first", 'F'= "second", 'Vc'= "third", 'Vp1'= "forth")
)
)
mlxpath <- file.path(system.file(package = "ggPMX"),
"testdata","1_popPK_model","project.mlxtran")
ctr <- pmx_mlxtran(mlxpath, config = "standing", settings = mySet)
ctr %>% pmx_plot_eta_cats(labels = list(title = "EBE vs discrete covariates"))
Result:
2.3 I also see some comments in the code plot-eta-cov.R:
pmx_plot_eta_cats
and pmx_plot_eta_conts
you can customize the covariatespmx_cov
.Maybe someone could clarify this in details.
ctr %>% pmx_plot_eta_cats(labels = list(title = "EBE vs discrete covariates"), is.hline=TRUE, hline = 0.25)
About 3. Yes, this looks good!
About 3. At first glance it possible to do with workaround:
library(facetscales)
library(dplyr)
library(ggplot2)
library(reshape)
ctr <- theophylline()
df <- ctr$data$eta
df <- df[, c(ctr$cats, "VALUE", "EFFECT"), with = FALSE]
max_y <- df %>%
group_by(EFFECT) %>%
summarise(
maxValue = max(abs(VALUE), na.rm = T)
) %>%
arrange(EFFECT)
get_scales_y <- function(i, scales_y = NULL){
scales_i <- list(scale_y_continuous(limits = c(-max_y$maxValue[i], max_y$maxValue[i])))
names(scales_i) <- max_y$EFFECT[i]
append(scales_y, scales_i)
}
scales_y <- sapply(1:length(max_y$EFFECT), get_scales_y)
p <- ggplot(melt(df, measure.vars = ctr$cats)) +
geom_boxplot(aes_string(x = "value", y = "VALUE"))
p + facet_grid_sc(stats::as.formula("EFFECT~variable"), scales = list(y = scales_y))
Will check how to implement this in ggPMX. Do we plan to use this functionality in other charts? If yes, which exactly?
@baltcir1 Hi! Are we good to introduce new dependency for implementation of symmetric ranges Y-axis - facetscales library (it is not on CRAN)?
Approach 2.3 seems like is the right way to manage labels. This approach currently works for pmx_plot_eta_conts
mlxpath <- file.path(system.file(package = "ggPMX"),
"testdata","1_popPK_model","project.mlxtran")
ctr <- pmx_mlxtran(mlxpath, config = "standing")
ctr %>% pmx_plot_eta_conts(
covariates=pmx_cov(values=list("HT0","TRT"),
labels=list("HT0 long","TRT long"))
)
After improvments will work for pmx_plot_eta_cats
mlxpath <- file.path(system.file(package = "ggPMX"),
"testdata","1_popPK_model","project.mlxtran")
ctr <- pmx_mlxtran(mlxpath, config = "standing")
ctr %>% pmx_plot_eta_cats(
covariates=pmx_cov(values=list("RACE","DISE"),
labels=list("Race changed","Dise changed"))
)
Dear Kostia, This library is not on CRAN and is not planning to go on CRAN, so it’s not an option for us. Is there another way to solve this? Many thanks, Irina
From: Kostiantyn Zinher notifications@github.com Sent: Thursday, 19 November 2020 10:04 To: ggPMXdevelopment/ggPMX ggPMX@noreply.github.com Cc: Baltcheva, Irina irina.baltcheva@novartis.com; Mention mention@noreply.github.com Subject: Re: [ggPMXdevelopment/ggPMX] Eta_Cats (#71)
@baltcir1https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_baltcir1&d=DwMCaQ&c=ZbgFmJjg4pdtrnL2HUJUDw&r=aKykINevLIXBb2-gHmhroKGVY88hh9HCgL0YAgz8yzg&m=6MUeYFKgsdp2amfiX4CkqT2gXhnHH6iP0N0dTy9r5Ow&s=49KuJw29J8KJvOBGaBOJmLlFpiwyZ7yPStS0pwER1VU&e= Hi! Are we good to introduce new dependency for implementation of symmetric ranges Y-axis - facetscales library?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_ggPMXdevelopment_ggPMX_issues_71-23issuecomment-2D730230837&d=DwMCaQ&c=ZbgFmJjg4pdtrnL2HUJUDw&r=aKykINevLIXBb2-gHmhroKGVY88hh9HCgL0YAgz8yzg&m=6MUeYFKgsdp2amfiX4CkqT2gXhnHH6iP0N0dTy9r5Ow&s=qM5hEXlBDRsDPR-n8uDI2fuNqj9zmIweqa9TkaSyT0Q&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AGCGRLCMSKFWJECF4TKMSRTSQTNRFANCNFSM4NADGESA&d=DwMCaQ&c=ZbgFmJjg4pdtrnL2HUJUDw&r=aKykINevLIXBb2-gHmhroKGVY88hh9HCgL0YAgz8yzg&m=6MUeYFKgsdp2amfiX4CkqT2gXhnHH6iP0N0dTy9r5Ow&s=3js0LBumGA_GdHnSGOUwcGajSkoyF1dnWJWvD-EGPfw&e=.
(Old Ticket #235)