Learn R Programming

vcfR (version 1.0.0)

read.vcfR: Read and write vcf format files

Description

Read and files in the *.vcf structured text format, as well as the compressed *.vcf.gz format. Write objects of class vcfR to *.vcf.gz.

Usage

read.vcfR(file, limit = 1e+07, nrows = -1, skip = 0, cols = NULL,
  verbose = TRUE)

write.vcf(x, file = "", mask = FALSE, APPEND = FALSE)

Arguments

file
A filename for a variant call format (vcf) file.
limit
amount of memory (in bytes) not to exceed when reading in a file.
nrows
integer specifying the maximum number of rows (variants) to read in.
skip
integer specifying the number of rows (variants) to skip before beginning to read data.
cols
vector of column numbers to extract from file.
verbose
report verbose progress.
x
An object of class vcfR or chromR.
mask
logical vector indicating rows to use.
APPEND
logical indicating whether to append to existing vcf file or write a new file.

Value

  • read.vcfR returns an object of class vcfR-class. See the vignette: vignette('vcf_data')

Details

The function read.vcfR reads in files in *.vcf (text) and *.vcf.gz (gzipped text) format and returns an object of class vcfR. The parameter 'limit' is an attempt to keep the user from trying to read in a file which contains more data than there is memory to hold. Based on the dimensions of the data matrix, an estimate of how much memory needed is made. If this estimate exceeds the value of 'limit' an error is thrown and execution stops. The user may increase this limit to any value, but is encourages to compare that value to the amout of available physical memory.

The function write.vcf takes an object of either class vcfR or chromR and writes the vcf data to a vcf.gz file (gzipped text). If the parameter 'mask' is set to FALSE, the entire object is written to file. If the parameter 'mask' is set to TRUE and the object is of class chromR (which has a mask slot), this mask is used to subset the data. If an index is supplied as 'mask', then this index is used, and recycled as necessary, to subset the data.

See Also

CRAN: http://cran.r-project.org/package=pegas{pegas}::read.vcf, http://cran.r-project.org/package=PopGenome{PopGenome}::readVCF, http://cran.r-project.org/package=data.table{data.table}::fread

Bioconductor: http://www.bioconductor.org/packages/release/bioc/html/VariantAnnotation.html{VariantAnnotation}::readVcf

Use: browseVignettes('vcfR') to find examples.