Learn R Programming

fsthet (version 1.0.1)

var.fst: This calculates Cockerham & Weir's Beta.

Description

This calculates Weir & Cockerham (1993)'s Fst. The caluclation is based on variance in allele frequencies. See the vignette for details on the calculation of beta.

Usage

var.fst(df, i)

Arguments

df

A dataframe containing the genepop information, where the first column is the population ID.

i

Column number containing genotype information.

Value

ht

2pbar(1-pbar). This is a single numerical value.

fst

The calculated beta value for this locus.

Examples

Run this code
# NOT RUN {
  gpop<-data.frame(popinfo=c(rep("POP 1", 20),rep("POP 2", 20)),ind.names=c(1:20,1:20),
                  loc0=sample(c("0101","0102","0202"),40,replace=TRUE),
                  loc1=sample(c("0101","0102","0202"),40,replace=TRUE))
  var1<-var.fst(gpop,3) 
  
# }
# NOT RUN {
    gfile<-system.file("extdata", "example.genepop.txt",package = 'fsthet')
    gpop<-my.read.gpop(gfile)
    var1<-var.fst(gpop,3) #calculate variance-based for the first SNP
  
# }

Run the code above in your browser using DataLab