#Function to calculate Hudson's Fst (see Hudson et al. 1992) ### function for Fst as a summary statistic for a pair of populations, ### transformation of allele frequencies hudsonFst <- function(p1=NA, p2=NA, locusspecific=F){ p1.comp <- 1 - p1 p2.comp <- 1 - p2 # numerator <- p1 * p1.comp + p2 * p2.comp # denominator <- p1 * p2.comp + p2 * p1.comp # 1 - numerator/denominator # fst if(locusspecific==T){ return(1 - (p1 * p1.comp + p2 * p2.comp)/(p1 * p2.comp + p2 * p1.comp)) } (mean(1 - (p1 * p1.comp + p2 * p2.comp)/(p1 * p2.comp + p2 * p1.comp), na.rm=T)) }