teal.modules.clinical icon indicating copy to clipboard operation
teal.modules.clinical copied to clipboard

Implement ggplot2_args in the tm_g_km (and others)

Open gogonzo opened this issue 3 years ago • 9 comments

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.

gogonzo avatar Jan 24 '22 17:01 gogonzo

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?

pawelru avatar Jan 26 '22 12:01 pawelru

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.

Polkas avatar Jan 26 '22 12:01 Polkas

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.

Polkas avatar Jan 26 '22 12:01 Polkas

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"

gogonzo avatar Jan 26 '22 13:01 gogonzo

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

gogonzo avatar Feb 15 '22 14:02 gogonzo

Please make a deep dive in tern and find if tern functions can be converted to ggplot2 objs

gogonzo avatar Feb 15 '22 14:02 gogonzo

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.

rkostadi avatar Apr 29 '24 12:04 rkostadi

In regards to this issue, please note that all tern graphing functions now produce ggplot objects.

edelarua avatar Apr 29 '24 14:04 edelarua

@rkostadi the ylim was introduced in here https://github.com/insightsengineering/teal.modules.clinical/pull/1177

m7pr avatar May 07 '24 10:05 m7pr