kassambara / survminer

Survival Analysis and Visualization
https://rpkgs.datanovia.com/survminer/
506 stars 162 forks source link

ggforest & subgroup analysis #271

Open agnusdei13 opened 6 years ago

agnusdei13 commented 6 years ago

Expected behavior

I read the dataset from spss like this. OSA <- readSPSS("C:/Users/Desktop/test.sav", rownames=FALSE, stringsAsFactors=TRUE, tolower=FALSE)

bigmodel <- coxph( Surv(OS, OS_censor) ~ Hb_low + AGE60 + Stage, data = OSA ) ggforest(bigmodel, data = OSA)

I got the forestplot without subgroups. In the variables from dataset"OSA", Hb_low is coded like 1 or 0, which 1 is low hemoglobin group and 0 is not.

How can I make forestplot with subgroup using the ggforest?

Actual behavior

Steps to reproduce the problem

session_info()

# please paste here the result of
devtools::session_info()
pbiecek commented 6 years ago

Hi, I cannot replicate this code as I do not have this dataset. Would you prepare a snippet of code with some builtin dataset? Is it like some variable is missing in the plot?

agnusdei13 commented 6 years ago

Thank you for reply. I'm a beginner in R programming. I'll send the scripts and the dataset. I don't know how can make the subgroup in the forest plot. There are continuous variables and categorical variables in dataset. I used the categorical variables in ggforest.

the code is like this

require("survival") require("survminer") OSA <- readSPSS("C:/Users/SHJ2/Desktop/test.sav", rownames=FALSE, stringsAsFactors=TRUE, tolower=FALSE)

model <- coxph( Surv(OS, survival) ~ Hb_low + AGE60 + low_BMI + well_poorly + alb_low + Sex_male + CD_Cx + approach_cat + total_cat + ASA3_cat + stage_cat + TC_low + adj_cat + D2_Cat , data = OSA ) ggforest(model)


2018-01-24 7:47 GMT+09:00 Przemysław Biecek notifications@github.com:

Hi, I cannot replicate this code as I do not have this dataset. Would you prepare a snippet of code with some builtin dataset? Is it like some variable is missing in the plot?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kassambara/survminer/issues/271#issuecomment-359957955, or mute the thread https://github.com/notifications/unsubscribe-auth/AgYQDI64B9w-V1mS3IM7ubzjSG5biJruks5tNmGGgaJpZM4QpfeS .

kassambara commented 6 years ago

hi @agnusdei13, please provide a demo data set with a reproducible R code, thanks

amarawi commented 6 years ago

Hi Kassambara,

How can use ggforest to plot for a variable with >2 categories (e.g. Low, middle, high, very high)? Currently, I get 1 only for the reference category. Summary(model) for the cox has all the details.

highwindmx commented 9 months ago

I can do it in python, but not R, the idea is do multiple cox fit for each subgroup and combine the results as one table then plot; and ensure each of your subgroup contains all group-by factors (such as both treatment/control, unstratifable data means you will divide by zero, which means you need to do an extra if-else or data-filter process whichever called in R)