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

Hide panels #1

Closed
arazraw opened this issue Nov 21, 2015 · 6 comments
Closed

Hide panels #1

arazraw opened this issue Nov 21, 2015 · 6 comments

Comments

@arazraw
Copy link

arazraw commented Nov 21, 2015

Absolutely lovely package - saves huge amounts of time.

As you surely know it is common to perform regression with sequential adjusting (e.g models 1 to 3), and therefore it would be great if one could display several forest plots side by side, and that is doable in current format by (for example) using gridExtra to place the plots next to each other. However, it is desirable to be able to remove some panels from selected plots in order to not repeat variable names. Is it possible to remove that panel, i.e the variable name panel and thus only display "N", "Hazard Ratio", and "P"?

Best regards

@NikNakk
Copy link
Owner

NikNakk commented Nov 24, 2015

Thanks for your compliments!

I designed the package to be pretty flexible, so you can do this without any changes to the code. The panels that get plotted are completely configurable. The default includes the variable name as the second member of the list and the factor levels as the third. So, an easy way of doing this would be:

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)
my_model <- coxph(Surv(time, status) ~ ., pretty_lung)
forest_model(my_model, default_forest_panels(my_model)[-(2:3)])

If you look at the output of default_forest_panels(my_model) you can see the general structure of the panels object a bit better.

@NikNakk
Copy link
Owner

NikNakk commented Nov 24, 2015

Please let me know if that resolves the question you had and I'll close the issue.

@arazraw
Copy link
Author

arazraw commented Nov 25, 2015

Many thanks Dr Kennedy, problem solved.

If You are planning future versions of this package, it would be great if there were columns for number of events, person years and event rates, whenever applicable (coxph). Thats just a proposition, however, I'm very satisfied with the package in current format.

Cheers

@NikNakk
Copy link
Owner

NikNakk commented Nov 25, 2015

Great!

For your other point, I'm not clear on how you'd want to include number of events, etc. since they apply to the whole model, not to each separate covariate. They're also not part of the standard output from broom::tidy, although the number of events is a member of the model and of the output of broom::glance.

@NikNakk NikNakk closed this as completed Nov 25, 2015
@arazraw
Copy link
Author

arazraw commented Nov 25, 2015

Perhaps it was a bad idea, but I'll try to clarify. Suppose you examine the association between treatment groups and mortality. Using Your package it is easy to present a plot of the association, particularly with "covariates=c()" argument which filters out unwanted predictors. The plot displays number of individuals in each treatment group, along with hazard ratios and p values. But it does not present number of events in both groups, nor event rates (the former would be the most important from an epidemiological perspective). However, it is not a difficult task to code this separately and display it in a separate table but I'm thinking it could be valuable to see directly in the forest plot. I will have a go at trying to code it myself but it won't be of the same quality as your work.

@NikNakk
Copy link
Owner

NikNakk commented Nov 25, 2015

I understand now. I’ve created new variables for the number of events and the person-time (which would be person-years if the time is measured in years).

It’s currently on its own branch at https://github.com/NikNakk/forestmodel/tree/newcoxphvars and issue #2.

I’ve added an example which uses custom panels with these new variables.

From: arazraw [mailto:notifications@github.com]
Sent: 25 November 2015 12:07
To: NikNakk/forestmodel forestmodel@noreply.github.com
Cc: NikNakk nick@nick-kennedy.com
Subject: Re: [forestmodel] Hide panels (#1)

Perhaps it was a bad idea, but I'll try to clarify. Suppose you examine the association between treatment groups and mortality. Using Your package it is easy to present a plot of the association, particularly with "covariates=c()" argument which filters out unwanted predictors. The plot displays number of individuals in each treatment group, along with hazard ratios and p values. But it does not present number of events in both groups, nor event rates (the former would be the most important from an epidemiological perspective). However, it is not a difficult task to code this separately and display it in a separate table but I'm thinking it could be valuable to see directly in the forest plot. I will have a go at trying to code it myself but it won't be of the same quality as your work.


Reply to this email directly or view it on GitHub #1 (comment) . https://github.com/notifications/beacon/ACEx_8DOv5D6QvP1i0oKbB7ueo2uUoGBks5pJZvjgaJpZM4Gm5CQ.gif

NikNakk pushed a commit that referenced this issue Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants