#it is essential that you load the survival package library(survival) # loads your survival spreadsheet datafile <- read.csv("/Users/nsafren1/desktop/Survival_spreadsheet.csv") #Performs cox proportional hazards and outputs statistics coxfit <- coxph(Surv(time_death, as.logical(censored)) ~ group, data=datafile) summary(coxfit) # plots cumulative risk of death for each group. To save your plot click on the export button above your plot. coxfit <- coxph(Surv(time_death, as.logical(censored)) ~ strata(group), data=datafile) plot(survfit(coxfit), fun="cumhaz", main="Experiment Title", xlab="Time in hours", ylab="Cumulative risk of death", col=c("black","red"),lwd=c(5)) cox.zph(coxfit) #adjust the next line to modify the legend legend("topleft", legend=c("WT","Mutant"), col=c("black","red"), lwd=c(2), cex=.8) # plots survival data as a Kaplan Meier Curve kmfit <- survfit(Surv(time_death, as.logical(censored)) ~ group, data=datafile) plot(kmfit, main="Experiment Title", xlab="Time in hours",ylab="survival fraction", col=c("black","red"),lwd=c(5)) #adjust the next line to modify the legend legend("bottomleft", legend=c("WT","Mutant"), col=c("black","red"), lwd=c(2), cex=.8)