Comments (8)
Hi @biethbr1
Please check findings/questions/solutions:
- cats.labels (+use.labels) does not work.
Unfortunately in the current implementation, there were no possibilities to set strat.facet for these types of plots: eta_matrix, eta_cats, eta_conts. Not sure could we use cats.labels without strat.facet - will discover more. - How to change covariate labels to full words?
We could do it in different ways:
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:
- set strat = TRUE in eta_cov structure.
- add code to plot_pmx.eta_cov function:
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"))
2.3 I also see some comments in the code plot-eta-cov.R:
#' In case of pmx_plot_eta_cats
and pmx_plot_eta_conts
you can customize the covariates
#' and covaraites labels using pmx_cov
.
Maybe someone could clarify this in details.
from ggpmx.
- How to specify symmetric ranges of y-axis different for each parameter?
Could you please explain in detail how the result must looks like?
Something like this:
from ggpmx.
- Does not work to add hline.
Will add changes to plot-eta-cov.R
Call will be
ctr %>% pmx_plot_eta_cats(labels = list(title = "EBE vs discrete covariates"), is.hline=TRUE, hline = 0.25)
from ggpmx.
About 3. Yes, this looks good!
from ggpmx.
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?
from ggpmx.
@baltcir1 Hi!
Are we good to introduce new dependency for implementation of symmetric ranges Y-axis - facetscales library (it is not on CRAN)?
from ggpmx.
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"))
)
from ggpmx.
from ggpmx.
Related Issues (20)
- Use `readr::read_table()`
- Change `select()` usage
- Use `reframe()` intesad of `summarize()` or recast as data.table syntax
- Use `purr::map() + purr::exec()`
- Unknown error when creating controller HOT 2
- Make a `pmx_effects()` controller with documentation about what everything means AND more intuitive parameter names
- Remove captioner
- Too much white space for figures HOT 1
- Remove captioner for now (doesn't match match our internal standards)
- `use.title` = `FALSE`
- censoring defaults HOT 1
- Switch on/off sci notation for tables
- Conditionally include `nlmixr2`
- CRAN update
- Parameter table for Monolix 2013R1
- Observations Ignored in Individual Plots HOT 2
- No all plots using ggPMX and a Monolix project HOT 2
- CRAN package requirement.
- Bare theophylline controller creation call fails
- directory fixes for CRAN
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ggpmx.