Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving ggforest #178

Closed
kassambara opened this Issue Mar 23, 2017 · 8 comments

Comments

Projects
None yet
2 participants
@kassambara
Copy link
Owner

kassambara commented Mar 23, 2017

I just discovered the forestmodel package (https://github.com/NikNakk/forestmodel), which creates forest plots of the coefficients of models produced by lm, glm, survival::coxph

library("forestmodel")
library("survival")
library("dplyr")
pretty_lung <- lung %>%
  transmute(time,
            status,
            Age = age,
            Sex = factor(sex, labels = c("Male", "Female")),
            ECOG = factor(lung$ph.ecog),
            `Meal Cal` = meal.cal)

print(forest_model(coxph(Surv(time, status) ~ ., pretty_lung)))

rplot01

@pbiecek : In ggforest(), I vote for staying focused on survival::coxph. But, how can we improve the output ? shoud we use internally the forestmodel package?

@pbiecek

This comment has been minimized.

Copy link
Contributor

pbiecek commented Mar 23, 2017

Cool, it works for lm and glm as well.
Will look into this.

@pbiecek

This comment has been minimized.

Copy link
Contributor

pbiecek commented Apr 1, 2017

It took me some time to look for some other ideas for forest model plots that will be as nice as the one generated by NikNakk. Will submit a new version of ggforest this weekend.

@kassambara

This comment has been minimized.

Copy link
Owner Author

kassambara commented Apr 1, 2017

@pbiecek

This comment has been minimized.

Copy link
Contributor

pbiecek commented Apr 1, 2017

The new version of ggforest looks like the figure below (will be uploaded soon, need some polishing)
I borrowed some ideas from forestmodel package. In addition to standard elements in the bottom-left corner there are some model statistics (AIC/n.events and others).
forest2

@kassambara

This comment has been minimized.

Copy link
Owner Author

kassambara commented Apr 2, 2017

Thank you @pbiecek for this great work!

Default text size in the ggforest() script is 0.7, some users might want to change this.
Suggestion: additional argument fontsize or labelsize or ...

I observed that, the hazard ratio axis ticks are not displayed sometimes. It seems to depend on the model. Do you have any idea?

For example,

  1. In the example below, the axis ticks are displayed:
require("survival")
require("survminer")
model <- coxph( Surv(time, status) ~ sex+rx,
                data = colon )
ggforest(model)

rplot

  1. But, in this second example, the ticks are not shown:
require("survival")
require("survminer")
model <- coxph( Surv(time, status) ~ sex+rx+adhere,
                data = colon )
ggforest(model)

rplot04

@pbiecek

This comment has been minimized.

Copy link
Contributor

pbiecek commented Apr 2, 2017

Ticks are not displayed because the scale vary from 0.55 to 1.59 and the 'pretty printing' cannot find nice looking ticks in such narrow range.
One solution is to force the OX scale to be at least c(0.5, 2),
will add this if there are no other candidate solutions.

Having more graphical parameters exposed is a good idea, will do this.
However, the left panel is not a pure ggplot2 plot, so we cannot simply use theme parameter.

@pbiecek

This comment has been minimized.

Copy link
Contributor

pbiecek commented Apr 2, 2017

Ok, things are even stranger, since in the first plot the OX scale is more narrow.
Will look into this.

pbiecek added a commit to pbiecek/survminer that referenced this issue Apr 2, 2017

pbiecek added a commit to pbiecek/survminer that referenced this issue Apr 2, 2017

fix for kassambara#178
more graphical parameters
added plot title
removed OX axis
@pbiecek

This comment has been minimized.

Copy link
Contributor

pbiecek commented Apr 2, 2017

the problem was in using scale_x limits instead of coord_ limits
fixed in #182

kassambara added a commit that referenced this issue Apr 3, 2017

@kassambara kassambara closed this Apr 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.