read a INFO tag in the VCF/BCF into R data structure
Usage
vcfinfo(
vcffile,
tag,
region = "",
vartype = "all",
ids = NULL,
qual = 0,
pass = FALSE,
setid = FALSE
)
Arguments
- vcffile
path to the VCF/BCF file
- tag
the INFO tag to extract.
- region
region to subset in bcftools-like style: "chr1", "chr1:1-10000000"
- vartype
restrict to specific type of variants. supports "snps","indels", "sv", "multisnps","multiallelics"
- ids
character vector. restrict to sites with ID in the given vector. default NULL won't filter any sites.
- qual
numeric. restrict to variants with QUAL > qual.
- pass
logical. restrict to variants with FILTER = "PASS".
- setid
logical. reset ID column as CHR_POS_REF_ALT.
Value
Return a list containing the following components:
- chr
: character vector;
the CHR column in the VCF file- pos
: character vector;
the POS column in the VCF file- id
: character vector;
the ID column in the VCF file- ref
: character vector;
the REF column in the VCF file- alt
: character vector;
the ALT column in the VCF file- qual
: character vector;
the QUAL column in the VCF file- filter
: character vector;
the FILTER column in the VCF file- tag
: vector of either integer, numberic or character values depending on the tag to extract;
a specifiy tag in the INFO column to be extracted
Details
vcfinfo
uses the C++ API of vcfpp, which is a wrapper of htslib, to read VCF/BCF files.
Thus, it has the full functionalities of htslib, such as restrict to specific variant types,
samples and regions. For the memory efficiency reason, the vcfinfo
is designed
to parse only one tag at a time in the INFO column of the VCF. Currently it does not support
parsing a vector of values for a given INFO tag.
Author
Zilong Li zilong.dk@gmail.com
Examples
library('vcfppR')
vcffile <- system.file("extdata", "raw.gt.vcf.gz", package="vcfppR")
res <- vcfinfo(vcffile, "AF", region = "chr21:1-5050000", vartype = "snps", pass = TRUE)
str(res)