Helper function to read in SNP data from a VCF file.
Arguments
- file
File path to a VCF file. See details.
- bsgenome
An object of class BSgenome for the species you are interrogating; see BSgenome::available.genomes for a list of species.
Details
Note that the VCF must be filtered to only contain variant sites (i.e.,
no 0/0
), or only homozygous alt sites if you choose (0/1
or 1/1
). This
can be accomplished with bcftools:
# Filter to any variant sites:
bcftools view -i 'GT="alt"' ...
# Filter to homozygous alt sites:
bcftools view -i 'GT="AA"' ...
Examples
if (FALSE) {
library(BSgenome.Ggallus.UCSC.galGal6)
vcf_file <- system.file("extdata", "galGal6-chr33.vcf.gz", package="tfboot", mustWork = TRUE)
snps <- read_vcf(vcf_file, BSgenome.Ggallus.UCSC.galGal6)
snps
}