#### Code for survival analysis presented in #### A test of the “genetic rescue” technique using bottlenecked donor populations #### Heber S, Briskie JV and Apiolaza LA #### #### Sol Heber #### School of Biological Sciences, University of Canterbury #### Private Bag 4800, Christchurch, New Zealand #### Sol.Heber@pg.canterbury.ac.nz #### #### #### Code cleaned on 2011-10-07 ####### Packages needed for analysis library(survival) # Therneau, T. (2011) library(multcomp) # Hothorn et al. (2008) ####### Read data files survival<-read.table(file="S5_survival.txt",header=T) attach(survival) names(survival) ####### Fit model with exponential error distribution: model1<-survreg(Surv(time,ci)~cross,dist="exponential") ####### Fit model with Weibull error distribution: model2<-survreg(Surv(time,ci)~cross) ####### Compare fit: anova(model1,model2) ####### Simplyfiying model by combining hybrid F2 from hybrid-hybrid and hybrid-inbred matings: model3<-survreg(Surv(time,ci)~cross2) anova(model2,model3) summary(model3) ####### Compare survival rates between all group pairs: crosscomp<-glht(model3,linfct=mcp(cross2='Tukey')) summary(crosscomp) plot(crosscomp) ####### Calculate adjusted confidence intervals: adjusted.z<-abs(qnorm("p-value"/2)) #abs for absolute gets rid of +/- sign as not important in t- and z-values std.error<-"Estimate"/"adjusted.z" lower95%CI<-"Estimate"-(std.error*1.96) upper95%CI<-"Estimate"+(std.error*1.96) ####### Very significant p-values are reported for example as <0.001. Therefore extract the exact p-values to be used in above calculations of adujusted CIs: summary(crosscomp)$test$pvalues ####### Graph with survival curves: plot(survfit(Surv(time,ci)~cross2),lty=c(1:6),ylab="Survivorship",xlab="Time") ####### Predict life span for each group separately: tapply(predict(model3,type="response"),cross2,mean)