therneau/survival

Enhancement: Highlight Special Patients in Survival Plot

Closed this issue · 1 comments

I am aware of plot.survfit and points functions, but I don't think that it is possible combine them for my use case. The scenario is two groups of patients; one has 594 samples and the other has 8 (HPV human genome integration is rare for oral cancers). Instead of plotting two lines and having one look very jagged, I suppose it would be better to plot one line for all 602 patients and indicate the 8 HPV-positive samples in some way (e.g. solid blue circle for event sample, empty blue circle for censored sample). I am wondering if points could be enhanced to accept sample IDs from a fitted Surv object and then draw those few samples differently.

You can use the standard R "points" function.
Say that your 8 patient's values are the vectors time8 and status8, and the the overall survival curve is "fit".
Here is a simple example

fit <- survfit(Surv(time, status) ~ 1, data= aml)
plot(fit, xmax=50)
time8 <- c(2,8,10,25, 30,36, 40)
status8 <- c(0, 1, 1,1,0,0,1,0)

temp <- summary(fit, time=time8)
points(time8,  temp$surv, pch= status8, col=2)