Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

read.vcf

Create a bed.matrix from VCF files


Description

Create a bed.matrix from a .vcf file.

Usage

read.vcf(file, max.snps, get.info = FALSE, convert.chr = TRUE, 
                 verbose = getOption("gaston.verbose",TRUE))

Arguments

file

The name of the VCF file to read

max.snps

The maximal number of SNPs to read

get.info

If TRUE, the INFO field from the VCF file will integrated in @ped$info

convert.chr

If TRUE, chromosomes ids "X", "Y" and "MT" will be converted in their numeric equivalents

verbose

If TRUE, display information on the function progress

Details

The vcf format is described in https://github.com/samtools/hts-specs

In addition to the usual data in the slot @snps, the bed.matrices produced by read.vcf have @snps$quality and @snps$filter columns corresponding to the QUAL and FILTER fields in the VCF file. If get.info = TRUE, an additionnal column @snps$info is added, corresponding to the INFO field.

The information about individuals in VCF files is incomplete: in the slot @ped, the columns @ped$famid and @ped$id will both contain the sample id; sex and phenotypes will be set to unknown.

The function currently assumes that the GT field is the first field in the genotypes format. If it is not the case, the variants are discarded.

Value

Author(s)

Hervé Perdry and Claire Dandine-Roulland

See Also

Examples

## Read vcf file (from file name)
filepath <-system.file("extdata", "LCT.vcf.gz", package="gaston")
x1 <- read.vcf( filepath )
x1

gaston

Genetic Data Handling (QC, GRM, LD, PCA) & Linear Mixed Models

v1.5.7
GPL-3
Authors
Hervé Perdry [cre, aut, cph], Claire Dandine-Roulland [aut, cph], Deepak Bandyopadhyay [cph] (C++ gzstream class), Lutz Kettner [cph] (C++ gzstream class)
Initial release
2020-09-18

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.