This function extract the SNPs that pass a frequency cut-off in at least one super population from a GDS SNP information file and save the retained SNP information into a VCF file.

snvListVCF(gdsReference, fileOut, offset = 0L, freqCutoff = NULL)

Arguments

gdsReference

an object of class gds.class (a GDS file), the 1KG GDS file.

fileOut

a character string representing the path and file name of the VCF file that will be created wit the retained SNP information. The file should have the ".vcf" extension.

offset

a single integer that is added to the SNP position to switch from 0-based to 1-based coordinate when needed (or reverse). Default: 0L.

freqCutoff

a single positive numeric specifying the cut-off to keep a SNP. If NULL, all SNPs are retained. Default: NULL.

Value

The integer 0L when successful.

Author

Pascal Belleau, Astrid Deschênes and Alexander Krasnitz

Examples


## Required library
library(gdsfmt)

## Path to the demo pedigree file is located in this package
dataDir <- system.file("extdata", package="RAIDS")

## Demo 1KG Reference GDS file
fileGDS <- openfn.gds(file.path(dataDir,
                    "PopulationReferenceDemo.gds"))

## Output VCF file that will be created (temporary)
vcfFile <- file.path(tempdir(), "Demo_TMP_01.vcf")

## Create a VCF file with the SNV dataset present in the GDS file
## No cutoff on frequency, so all SNVs are saved
snvListVCF(gdsReference=fileGDS, fileOut=vcfFile, offset=0L,
                    freqCutoff=NULL)
#> Warning: appending column names to file
#> [1] 0

## Close GDS file (IMPORTANT)
closefn.gds(fileGDS)

## Remove temporary VCF file
unlink(vcfFile, force=TRUE)