I am working in R . I have a gene expression matrix with 100 patients and 10000 genes. I do some clustering analysis on patients and obtain different different groups of patients. 5 clusters are obtained and each patient is allotted a number 1,2,3,4 or 5 depending on which cluster the patient belongs. I also have clinical data frame in R of all the 100 patients in the gene expression matrix. The clinical data contains survival time in days, if death occurred or not (0 or 1). I then combine clinical data and the clustering information and the new data frame looks like :
$ Survival: int 1614 370 183 310 691 1560 268 515 821 537 ...
$ Death : int 1 1 1 1 1 1 1 1 1 1 ...
$ Cluster : int 1 2 2 2 1 1 3 1 4 5 1 ...
I want to plot Schoenfeld plots for each cluster. That means I want 5 Schoenfeld plots.
I use the following code to do it:
fitcox <- coxph(Surv(Survival,Death) ~ as.factor(cluster), data = dataX)
summary(fitcox)
ftest <- cox.zph(fitcox)
ftest
ggcoxzph(ftest)
The problem is that I get only one Schoenfeld plot, instead of multiple plots ( one for each cluster) in the R plots tab.
I would be grateful if someone rectifies this code to obtain the plots for each cluster. There are five clusters. If one cluster is taken as reference then 4 plots are expected.
Thanks.