#Simulation of number of sires in complete clutch for SL51 #The R script produces Fig.S1 in Wacker et al. 2018 Ecology & Evolution #870 is the estimated total clutch size, 43 is the number of genotyped offspring and 32 is the number of sires detected in the sample of 43 offspring xfreqtot = NULL xsirestot = NULL low5 = NULL upp5 = NULL for (i in 1:300) { xfreq = NULL xsires = NULL for (g in 1:10000) { xy<-rpois(i,870/i) xid<-seq(1,length(xy)) xoff<-rep(xid,xy) a<-sample(xoff,43,replace=FALSE) xfreq[g]<-nlevels(factor(a)) xsires[g]<-length(subset(xy,xy>0)) } xsirestot [i] <- mean(xsires) xfreqtot [i] <- mean(xfreq) upp5 [i] <-quantile(xfreq,0.975) low5 [i] <-quantile(xfreq,0.025) } ma<-max(subset(xsirestot,low5==32)) mi<-min(subset(xsirestot,upp5==32)) median(subset(xsirestot,xfreqtot>31.5&xfreqtot<32.5)) plot(xfreqtot,xsirestot,xlim=c(20,43),ylim=c(0,200),ylab="Number of sires in complete clutch (870 offspring)",xlab="Detected number of sires in sample (43 offspring)") minor.tick(ny=5,nx=5,tick.ratio=0.5) points(low5,xsirestot,pch=16,ce=0.5) points(upp5,xsirestot,pch=16,ce=0.5) abline(v=32,lty=2) lines(x=c(0,32),y=c(mi,mi),lty=2,col="red",lwd=2) lines(x=c(0,32),y=c(ma,ma),lty=2,col="red",lwd=2) lines(x=c(0,32),y=c(68,68),lty=2,col="blue",lwd=2)