The function calculates the site frequency spectrum.

SFS(DNAmat)

Arguments

DNAmat

matrix; either a single-nucleotide polymorphism matrix or a segregating sites matrix. See details.

Value

The site frequency spectrum with class 'SFS_class'.

Details

The site frequency spectrum is a vector of length \(n-1\), where \(n\) is the sample size. The \(i\)'th entry is the number of segregating sites where a mutation occur in \(i\) sequences.

The input to the function should be either a single-nucleotide polymorphism matrix or a segregating sites matrix. Either way, each row in the matrix represents a DNA sequence. The matrix should have a 1 where a mutation has occured and a 0 otherwise. If this is not the case, it will cause an error. If there exists a position on which all sequences have a mutation, it will cause a warning, and such a position will be treated as if it had no mutations.

Examples

SFS(matrix(c(0,1,0,1,0,0,0,0,0),nrow=3))
#> [1] 2 0