Implement ggplot2_args in the tm_g_km (and others)
tm_g_km is missing ggplot2_args to control additional graphical attributes. Implement ggplot2_args in the same fashion as in other ggplot2 modules in tmc.
tm_g_km is a little bit different because it's not a ggplot object therefore we can't really utilize ggplot2 call arguments into the grid plot call - there simply be no match
@Polkas am I right here? what we can do with it? grid_args?
Precisely NO GGPLOT OR TABLE in tm_g_km, as g_km is returning a grob of class gTree.
We could support there title and footnote nevertheless it should not be connected with ggplot2_args functionality.
Then we could consider adding to tm_g_km additional args like title, which is not so obvious.
The first step should be unification of tern functions arguments.
Then we could think of plot_args argument? or simply rewrite the functions to use ggplot2.
i think we should add it, i will make a PR. For a few grid plots we are currently support limited arguments like tm_g_ipp.
Yeah, I was mislead by g_km(..., ggtheme)and I thought instantly that it's a ggplot2. This grid/graphics/ggplot2 is a think we could debate in the future. Whether to support them all or to support ggplot2 only and switch to ggplot2 everywhere (tern, osprey, goshawk)
@Polkas Issue is not for the UAT, don't need to rush. I'm just raising the flag like: "Hey guys, we have one module here which is an exception, maybe we can fix this"
Something to research https://cran.r-project.org/web/packages/cowplot/vignettes/introduction.html#:~:text=The%20cowplot%20package%20is%20a,or%20mix%20plots%20with%20images
Please make a deep dive in tern and find if tern functions can be converted to ggplot2 objs
There's a simple functionality/parameter of tm_g_km that is missing that controls the y-axis: ylim = c(0,1).
This is ylim in tern g_km: https://github.com/insightsengineering/tern/blob/1ecaadcc3a7a067e7bdae5d43aa98b8768601952/R/g_km.R#L153 https://insightsengineering.github.io/tern/latest-tag/reference/g_km.html#ref-usage
This parameter needs to be added somewhere where tm_g_km calls g_km, and added appropriately to upstream parameterization options: https://github.com/insightsengineering/teal.modules.clinical/blob/8fa40eb6db8faf4b02ec117a37460f96ea0b1cdb/R/tm_g_km.R#L173
g_km produces nice Kaplan-Meier plots, but to realize its functionality within teal, it is nice to include all g_km parameterization options into tm_g_km. Otherwise, you can't produce nice KM plots on the fly within R shiny interactively. It is a very standard display in the field for the y-axis in KM plots to be simply from 0 to 1 (or 0% to 100%), as opposed to the default setting which scales the y-axis from the min/max of the data.
In regards to this issue, please note that all tern graphing functions now produce ggplot objects.
@rkostadi the ylim was introduced in here https://github.com/insightsengineering/teal.modules.clinical/pull/1177