rggplot2survival-analysissurvivalsurvminer

How to present survival curves with event variable with more than 2 categories in R?


I have patients who can have two types of outcomes.

structure(list(time = c(45.7, 2, 98.4, 87.3, 104.5, 78.2, 78.2, 
9.2, 14.2, 109.6, 39.6, 109.6, 55.8, 53.8, 6, 76.1, 118.7, 4, 
2, 94.4, 41.6, 7.1, 115.7, 24.4, 97.4, 15.2, 26.4, 118.7, 69, 
102.5, 116.7, 58.8, 109.6, 2, 67, 70, 22.3, 87.3, 82.2, 109.6, 
58.8, 33.5, 57.9, 9.2, 90.3, 23.3, 37.5, 3, 17.3, 49.7, 111.6, 
84.2, 116.7, 111.6, 8.1, 30.5, 30.5, 27.4, 94.4, 6.1, 81.2, 44.7, 
70, 14.2, 70, 78.2, 41.6, 4.1, 25.4, 33.5, 104.5, 17.3, 77.1, 
1, 31.5, 87.3, 80.2, 116.7, 9.2, 84.2, 1, 36.5, 85.2, 99.4, 111.6, 
4.1, 37.5, 4.1, 80.2, 39.5, 104.5, 6.1, 81.2, 56.8, 47.7, 66, 
6.1, 44.7, 36.5, 34.5, 95.3, 92.4, 14.2, 15.2, 114.7, 68, 120.7, 
2, 3, 33.5, 32.5, 55.8, 1, 54.8, 15.2, 29.5, 18.3, 29.5, 3.1, 
3, 4.1, 2, 10.2, 10.1, 19.3, 49.7, 27.4, 89.3, 93.4, 59.8, 1, 
61.9, 64.9, 47.7, 19.3, 8.2, 4.1, 94.4, 1, 95.3, 13.2, 79.2, 
61.9, 11.1, 0, 69, 48.7, 34.5, 1, 103.5, 18.3, 72, 97.4, 97.4, 
46.6, 22.3, 80.2, 34.5, 60.9, 114.7, 109.6, 2, 47.7, 98.4, 77.1, 
1, 43.7, 0, 93.4, 117.7, 14.2, 37.5, 83.2, 77.1, 78.2, 8.1, 49.7, 
31.4, 103.5, 30.5, 90.3, 22.3, 13.2, 37.5, 2, 107.5, 112.6, 8.1, 
103.5, 19.3, 3, 35.5, 5.1, 97.4, 1, 61.9, 1, 13.1, 27.4, 12.2, 
19.3, 91.3, 112.6, 109.6, 41.6, 97.4, 54.8, 99.4, 3, 114.7, 32.5, 
3, 9.2, 2.1, 59.8, 112.6, 35.5, 66, 103.5, 117.7, 66.9, 55.8, 
69, 3, 4, 109.6, 4.1, 81.2, 93.4, 113.6, 0, 57.9, 86.2, 11.2, 
20.3, 2, 5.1, 3.1, 54.8, 55.8, 110.6, 50.7, 91.3, 45.7, 6.1, 
75.1, 58.8, 2.1, 13.2, 99.4, 83.2, 16.2, 40.6, 22.3, 18.3, 100.4, 
63.9, 2, 17.3, 1, 84.2, 3.1, 5, 23.3, 78.2, 40.6, 114.7, 2, 74.1, 
1, 95.3, 80.2, 56.8, 94.4, 58.8, 107.5, 80.2, 5.1, 36.5, 79.2, 
51.7, 115.7, 17.3, 4, 4.1, 5.1, 55.8, 79.2, 8.1, 80.2, 102.5, 
86.2, 41.6, 1, 15.2, 48.7, 53.8, 82.2, 79.2, 35.5, 23.3, 32.5, 
2, 40.6, 11.1, 1, 80.2, 27.4, 93.4, 78.2, 30.5, 112.6, 5.1, 2, 
2, 14.2, 8.1, 2, 18.3, 64.9, 42.6, 36.5, 103.5, 55.8, 18.3, 1, 
2.1, 55.8, 106.6, 2, 84.2, 6.1, 8.1, 14.2, 3, 52.8, 57.9, 1, 
81.2, 50.7, 86.2, 17.3, 56.8, 1, 11.1, 8.1, 1, 94.4, 85.2, 43.7, 
105.5, 78.2, 114.7, 80.1, 2, 82.2, 87.3, 90.3, 111.6, 94.4, 63.9, 
85.2, 32.5, 29.5, 14.2, 75.1, 8.1, 45.7, 70, 74.1, 43.7, 40.6, 
22.3, 64.9, 2, 4, 9.1, 117.7, 6.1, 12.2, 105.5, 26.4, 8.1, 32.5, 
46.6, 114.7, 1, 71, 80.2, 52.8, 2, 2, 73.1, 63.9, 74.1, 85.2, 
116.7, 0.9, 115.7, 66, 16.2, 54.8, 92.4, 85.2, 31.5, 2, 74.1, 
9.2, 104.5, 106.6, 5.1, 29.5, 97.4, 95.3, 38.6, 105.5, 75.1, 
54.8, 75.1, 100.4, 48.7, 83.2, 113.6, 75.1, 54.8, 60.9, 16.2, 
44.7, 46.6, 40.6, 2, 29.5, 45.7, 116.7, 0, 4.1, 1, 85.2, 27.4, 
55.8, 2, 86.2, 10.2, 77.1, 52.8, 44.7, 45.7, 80.2, 19.3, 9.2, 
64.9, 116.7, 69, 22.3, 5.1, 4, 29.5, 2, 3, 4.1, 55.8, 72, 22.3, 
1, 49.7, 61.9, 52.8, 42.6, 97.4, 88.3, 79.2, 48.7, 90.3, 10.1, 
103.5, 16.2, 63.9, 37.5, 6.1, 99.4, 112.6, 20.2, 119.7, 90.3, 
77.1, 2.1, 89.3, 88.3, 96.4, 11.1, 10.1, 53.8, 30.5, 87.3, 45.7, 
41.6, 84.2, 27.4, 2.1, 24.4, 37.5, 106.6, 13.2, 84.2, 106.6, 
36.5, 102.5, 0, 104.5, 24.4, 11.1, 5.1, 107.5, 2.1, 100.4, 70, 
98.4, 103.5, 7.1, 1, 4.1, 22.3, 7.1, 11.1, 84.2, 101.5, 15.2, 
10.1, 31.5, 2, 1, 56.8, 77.1, 10.1, 32.5, 1, 100.4, 21.3, 2, 
62.9, 0, 1, 24.4, 57.9, 8.1, 3, 114.7, 0, 5.1, 15.2, 61.9, 52.8, 
17.3, 104.5, 47.7, 67, 33.5, 53.8, 114.7, 115.7, 31.5, 13.2, 
11.1, 0, 58.8, 1, 36.5, 1, 53.8, 11.1, 94.4, 93.4, 111.6, 108.5, 
38.6, 2, 50.7, 1, 105.5, 41.6, 113.6, 45.7, 50.7, 37.5, 23.3, 
99.4, 36.5, 44.6, 103.5, 20.3, 102.5, 117.7, 4.1, 4, 1, 40.6, 
3.1, 49.7, 33.5, 55.8, 1, 30.5, 29.5, 119.7, 114.7, 9.2, 107.5, 
9.2, 40.6, 77.1, 104.5, 72, 99.4, 84.2, 31.5, 80.2, 46.6, 64.9, 
99.4, 1, 0, 3.1, 72, 27.4, 73.1, 116.7, 54.8, 2, 1, 69, 49.7, 
96.4, 39.6, 30.5, 110.6, 17.3, 92.4, 32.5, 79.2, 43.7, 72, 91.3, 
26.3, 5.1, 88.3, 46.6, 21.3, 113.6, 1, 37.5, 98.4, 90.3, 109.6, 
62.9, 99.4, 36.5, 28.4, 120.7, 54.8, 17.3, 49.7, 76.1, 40.6, 
111.6, 36.5, 33.5, 16.2, 62.9, 1, 102.5, 11.2, 14.2, 106.6, 29.5, 
24.4, 84.2, 59.8, 26.4, 57.9, 0, 105.5, 22.3, 31.5, 31.5, 66, 
46.6, 103.5, 91.3, 91.3, 25.4, 42.6, 51.7, 41.6, 13.2, 119.7, 
3, 14.2, 10.2, 116.7, 90.3, 109.6, 1, 28.4, 113.6, 3.1, 53.8, 
15.2, 9.2, 114.7, 1, 38.6, 29.5, 21.3, 2, 99.4, 82.2, 90.3, 62.9, 
13.2, 90.3, 1, 51.7, 2, 40.6, 44.7, 92.4, 96.4, 4.1, 88.3, 68, 
107.5, 88.3, 25.4, 120.7, 30.5, 103.5, 83.2, 89.3, 105.5, 108.5, 
3.1, 0, 105.5, 99.4, 0, 108.5, 17.3, 94.4, 108.5, 4.1, 115.7, 
43.7, 34.5, 55.8, 115.7, 17.3, 91.3, 90.3, 114.7, 73.1, 99.4, 
56.8, 93.4, 62.9, 78.2, 0, 103.5, 2, 12.2, 101.5, 42.6, 1, 2, 
111.6, 76.1, 4.1, 4.1, 35.5, 41.6, 30.5, 115.7, 38.6, 5.1, 7.1, 
47.7, 31.4, 32.5, 53.8, 23.3, 38.6, 63.9, 27.4, 41.6, 13.2, 0, 
56.8, 44.7, 91.3, 29.5, 97.4, 90.3, 4, 29.5, 84.2, 108.5, 51.7, 
34.5, 98.4, 2, 2, 48.7, 118.7, 49.7, 73.1, 36.5, 112.6, 1, 111.6, 
5.1, 62.9, 90.3, 83.2, 86.2, 12.2, 62.9, 14.2, 57.9, 53.8, 40.6, 
48.7, 10.1, 28.4, 9.2, 68, 97.4, 54.8, 84.2, 105.5, 74.1, 1, 
47.7, 71, 116.7, 81.2, 1, 58.8, 80.2, 78.2, 14.1, 39.6, 1, 4.1, 
1, 86.2, 58.8, 0, 103.5, 82.2, 87.3, 107.5, 98.4, 3.1, 39.6, 
8.1, 68, 100.4, 3.1, 18.3, 104.5, 75.1, 68, 39.6, 1, 108.5, 74.1, 
84.2, 23.3, 118.7, 106.6, 7.1, 55.8, 105.5, 0, 7.1, 2, 50.7, 
90.3, 76.1, 95.3, 2.1, 74.1, 119.7, 1, 77.1, 1, 10.1, 22.3, 28.4, 
2, 3, 78.2, 33.5, 3, 3, 27.4, 2, 47.7, 15.2, 13.2, 20.3, 97.4, 
40.6, 76.1, 58.8, 2, 50.7, 11.2, 78.2, 75.1, 100.4, 21.3, 28.4, 
4.1, 59.8, 86.2, 39.6, 9.2, 92.4, 5.1, 0, 102.5, 70, 26.4, 89.3, 
118.7, 8.1, 2, 92.4, 20.3, 75.1, 115.7, 31.5, 96.4, 66, 64.9, 
79.2, 4.1, 0, 114.7, 2, 3.1, 30.5, 106.6, 117.7, 1, 20.3, 35.5, 
38.6, 32.5, 1, 6.1, 10.1, 96.4, 8.1, 7.1, 115.7, 2, 66, 42.6, 
69, 114.7, 10.1, 111.6, 5.1, 83.2, 78.2, 8.1, 30.5, 5, 13.2, 
41.6, 85.2, 45.7, 92.4, 91.3, 9.1, 109.6, 31.5, 31.5, 28.4, 63.9, 
72, 0.9, 31.5, 101.5, 76.1, 99.4, 81.2, 69, 75.1, 4.1, 5.1, 55.8, 
64.9, 68, 4.1, 47.7, 78.2, 109.6, 8.1, 66, 19.3, 9.2, 67, 71, 
55.8, 92.4, 3.1, 52.8, 55.8, 62.9, 6.1, 113.6, 90.3, 72, 5, 35.5, 
115.7, 46.6, 15.2, 28.4, 9.2, 102.5, 4, 53.8, 97.4, 56.8, 102.5, 
74.1, 14.2, 17.3, 117.7, 4, 2.1, 77.1, 3.1, 102.5, 13.2, 66, 
3, 60.9, 1, 26.4, 114.7, 111.6, 60.9, 9.1, 18.3, 59.8, 11.1, 
19.3, 71, 50.7, 64.9, 4, 6.1, 120.7, 29.5, 88.3, 66, 72, 59.8, 
16.3, 93.4, 50.7, 114.7, 19.3, 87.3, 2, 22.3, 70, 52.8, 32.5, 
33.5, 2, 18.3, 74.1, 3.1, 0, 118.7, 111.6, 82.2, 1, 42.6, 4.1, 
72, 98.4, 58.8, 91.3, 66, 48.7, 75.1, 41.6, 34.5, 14.2, 116.7, 
13.2, 75.1, 118.7, 45.7, 50.7, 120.7, 95.3, 12.2, 69, 63.9, 6, 
62.9, 0, 49.7, 90.3, 74.1, 1, 14.2, 116.7, 70, 54.8, 14.2, 33.5, 
47.7, 79.2, 115.7, 2, 1, 3, 113.6, 45.7, 88.3, 13.2, 53.8, 63.9, 
95.3, 18.3, 31.5, 102.5, 68, 37.5, 106.6, 76.1, 74.1, 9.1, 43.7, 
8.1, 117.7, 48.7, 94.4, 19.3, 2, 6.1, 26.4, 30.5, 97.4, 39.6, 
103.5, 68, 96.4, 2, 111.6, 59.8, 79.2, 62.9, 51.7, 112.6, 1, 
107.5, 3, 37.5, 58.8, 12.2, 59.8, 61.9, 25.3, 106.6, 71, 35.5, 
8.1, 71, 12.2, 31.5, 3, 87.3, 116.7, 52.8, 78.2, 102.5, 97.4, 
2, 41.6, 53.8, 67, 119.7, 93.4, 20.3, 4.1, 117.7, 42.7, 20.3, 
29.5, 48.7, 107.5, 30.5, 36.5, 63.9, 80.2, 1, 6.1, 5.1, 67, 81.2, 
97.4, 8.1, 0, 6.1, 57.9, 1, 1, 5.1, 99.4, 8.1, 41.6, 78.2, 44.7, 
48.7, 38.6, 67, 103.5, 91.3, 106.6, 58.8, 20.3, 16.2, 62.9, 36.5, 
15.2, 13.2, 115.7, 10.1, 15.2, 58.8, 47.7, 6.1, 4.1, 95.3, 17.3, 
4.1, 2.1, 90.3, 13.2, 27.4, 54.8, 61.9, 68, 10.1, 70, 23.3, 25.4, 
11.1, 83.2, 50.7, 29.5, 58.8, 31.5, 84.2, 61.9, 84.2, 110.6, 
68, 17.3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, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 
0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 
1, 0, 0, 0, 0)), row.names = c(NA, -1329L), class = "data.frame")

Does it make sense to present survival curves for two different type of events at the same time? If so is it possible to do it with R (ggplot) ?

survie_cmd_test<-survfit(Surv(time,status)~1, data=mydata)


ggsurvplot(
  survie_cmd_test,
  data = mydata,
  size = 0.5,                 # change line size
  palette =
    c("#E7B800", "#2E9FDF"),# custom color palettes
  conf.int = TRUE,          # Add confidence interval
  pval = TRUE,              # Add p-value
  legend.labs =
    c("Patients"),    # Change legend labels
  risk.table.height = 0.25, # Useful to change when you have multiple groups
  ggtheme = theme_bw(),# Change ggplot2 theme
  xlab="Time (months)",
  ylab="Survival probability"
  
)

These codes give me only one curve while i am expecting two curves (one for the category 1 and another for the category 2)


Solution

  • You have three categories for "ss_tp" ("0", "1", "2"), so you can plot the three groups, or only "ss_tp == 1" and "ss_tp == 2", i.e.

    library(tidyverse)
    library(survival)
    library(survminer)
    
    df <- mydata
    
    survie_cmd_test<-survfit(Surv(time,status)~1, data=df)
    
    ggsurvplot(
      survie_cmd_test,
      data = df,
      size = 0.5,                 # change line size
      palette =
        c("#E7B800", "#2E9FDF"),# custom color palettes
      conf.int = TRUE,          # Add confidence interval
      pval = TRUE,              # Add p-value
      legend.labs =
        c("Patients"),    # Change legend labels
      risk.table.height = 0.25, # Useful to change when you have multiple groups
      ggtheme = theme_bw(),# Change ggplot2 theme
      xlab="Time (months)",
      ylab="Survival probability"
      
    )
    #> Warning in .pvalue(fit, data = data, method = method, pval = pval, pval.coord = pval.coord, : There are no survival curves to be compared. 
    #>  This is a null model.
    

    (problematic plot)

    
    survie_cmd_test<-survfit(Surv(time,status)~ss_tp, data=df)
    
    ggsurvplot(
      survie_cmd_test,
      data = df,
      size = 0.5,                 # change line size
    #  palette =
    #    c("#E7B800", "#2E9FDF"),# custom color palettes
      conf.int = TRUE,          # Add confidence interval
      pval = TRUE,              # Add p-value
    #  legend.labs =
    #    c("Patients"),    # Change legend labels
      risk.table.height = 0.25, # Useful to change when you have multiple groups
      ggtheme = theme_bw(),# Change ggplot2 theme
      xlab="Time (months)",
      ylab="Survival probability"
      
    )
    

    
    # for only ss_tp = 1 verses ss+tp = 2
    survie_cmd_test<-survfit(Surv(time,status)~ss_tp, data=df[df$ss_tp != 0,])
    
    ggsurvplot(
      survie_cmd_test,
      data = df,
      size = 0.5,                 # change line size
      #  palette =
      #    c("#E7B800", "#2E9FDF"),# custom color palettes
      conf.int = TRUE,          # Add confidence interval
      pval = TRUE,              # Add p-value
      #  legend.labs =
      #    c("Patients"),    # Change legend labels
      risk.table.height = 0.25, # Useful to change when you have multiple groups
      ggtheme = theme_bw(),# Change ggplot2 theme
      xlab="Time (months)",
      ylab="Survival probability"
      
    )