VCF parsing#
fastdfe infers a DFE from a site-frequency spectrum, and everything that turns a VCF into one lives in
sfsutils, the standalone package fastdfe depends on and re-exports. Every
class below is therefore available under both names, and resolves to the same sfsutils class.
Note
As of fastdfe 1.4.0, code written against earlier releases remains valid without modification. See the
changelog for the details of the separation.
import fastdfe as fd
import sfsutils as su
fd.Parser.__module__, su.Parser.__module__
('sfsutils.parser', 'sfsutils.parser')
library(fastdfe)
fd <- load_fastdfe()
su <- reticulate::import("sfsutils")
c(fd$Parser$`__module__`, su$Parser$`__module__`)
[1] "sfsutils.parser" "sfsutils.parser"
Parser reads a VCF and returns the Spectra that the inference
pages take as input. It determines polarization from the AA tag by default (see
skip_non_polarized), and takes three kinds of component:
Stratifications split the spectrum by site property, most importantly
DegeneracyStratification, which gives the neutral and selected spectra a DFE inference needs.Annotations add the site information a stratification reads.
DegeneracyAnnotationdetermines each site’s degeneracy from a reference genome and a GFF, whichDegeneracyStratificationthen splits on, and an ancestral allele annotation provides the polarization an unfolded spectrum requires.Filtrations drop sites before they reach the spectrum, such as
BiasedGCConversionFiltration, and are applied to a VCF directly with theFilterer.
For worked examples in Python and R, see sfsutils’ guides on
parsing,
annotations,
filtrations and
manipulating the SFS.