R/tools.R
snvListVCF.Rd
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)
an object of class gds.class
(a GDS file), the 1KG GDS file.
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.
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
.
a single positive numeric
specifying the cut-off to
keep a SNP. If NULL
, all SNPs are retained. Default: NULL
.
The integer 0L
when successful.
## 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)