NikNakk / forestmodel

42 stars 13 forks source link

Plotting categorical variables without reference #11

Closed jgarces02 closed 5 years ago

jgarces02 commented 6 years ago

Hi @NikNakk, I like so much your package, it's very easy to use.

I'm doing a survival analysis with categorical variables (I've categorized a numeric value of a gene to different expression levels) and, when I draw the forest_model plot, the first group is used as reference... could you explain why (I though that was a simple ratio) and is there any way to avoid this and take it as another normal variable?

image

Thanks a lot in advance!

NikNakk commented 6 years ago

Thanks for the feedback. This should mirror what you get when you run summary on your coxph model, except that doesn’t display the reference level. In effect, the hazard ratios for the other levels of the factor are being compared to the reference level, so for PCLAF_BM the hazard ratio comparing those with 1 compared to 0 is 0.9 and for 2 compared to 0 it is 2.26. What were you expecting to see?

BW

Nick

On 21 Jun 2018, at 18:05, jgarces notifications@github.com wrote:

Hi @NikNakk, I like so much your package, it's very easy to use.

I'm doing a survival analysis with categorical variables (I've categorized a numeric value of a gene to different expression levels) and, when I draw the forest_model plot, the first group is used as reference... could you explain why (I though that was a simple ratio) and is there any way to avoid this and take it as another normal variable?

Thanks a lot in advance!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

jgarces02 commented 6 years ago

Hi @NikNakk, you're right... I didn't think that reference came from previous cox regression not from (obviously) the figure. Thanks anyway for your help!

fittken commented 4 years ago

Hi guys,

1) I have the same problem. Can anyone tell me how to get the hazard ratios for categorical variables without a reference? There are forest plots without a reference, how do I get these hazard ratios?

2) How do I handle categorical variables with more than 2 levels? How can I get the hazard ratios?

Thank you for helping me!

jgarces02 commented 4 years ago

Hi @fittken,

  1. You cannot calculate a hazard ratio without a reference because this is always a relative (to something) risk.
  2. Hazard ratio can be obtained from a Cox regression, and it's indifferent use a two- or more-levels category.

Maybe these tutorials give you some ideas -> [1] and [2]

fittken commented 4 years ago

Hi @jgarces02 , thank you for your fast answer!

Sorry, I think my question was not specific enough.

I want to create a forest plot in order to show a subgroup analysis, like this one

For example the subgroup age >65 years and the subgroup <65 years, they both have a hazard ratio displayed.

1) Do you get these hazard ratios in this example by obtaining two univariate Cox regression analysis for patients >65 years and for patients <65 years?

2) If I am right with my guess in 1), is there a way to perform the analysis easily with "coxph" and "forest_model", I mean, to transfer all the specific hazard ratios for each subgroup and also to calculate the p for interaction?

I really appreciate your effort! Thank you for your help!

jgarces02 commented 4 years ago

That's a good point. I don't have any idea how they performed this analysis, I've took a glance to their paper and it's not clear for me, sorry.

I guess that, as you said in point 1, they might have made two (or more) Cox regressions interchanging the reference group in each one and obtaining two different HR (and the corresponding P-value)... but this's only a supposition, maybe you can ask to the corresponding author.

I don't know how forest_plot will take these results... maybe you should to combine in some way and test if this package works. If it doesn't work, another solution could be create a data.frame and try this other package forestplot that'd allow you to work with tables.

PD: I think the interaction you mentioned is another kind of topic, it must be included in the cox analysis itself (some like ~var1*var2), forest_plot doesn't calculate P-values, it only shows results...