| Title: | Whole-genome variant annotation data manipulation using GDS files |
|---|---|
| Description: | Fast and memory-efficient manipulation of whole-genome variant annotation data stored in Genomic Data Structure (GDS) files. The annotated GDS (aGDS) format introduced by FAVOR stores the FAVOR annotations of the variants together with the genotypes in one SeqArray GDS file. This package generalizes the format to annotation GDS files of any source, with or without genotypes. Annotation resources and annotator outputs, including FAVOR, gnomAD, Ensembl VEP and SnpEff, are converted into compact SeqArray-compatible GDS files with random access. Variants can be given as chr-pos-ref-alt strings, data frames, GRanges objects, VCF files or objects, or SeqArray GDS files. They are annotated by querying the annotation files, and the annotations can be written back into a genotype GDS file. Summary statistics of the variants and their annotations are computed in a single pass over a file and rendered as a VEP/SnpEff-like report. The package is intended for large-scale whole-genome sequencing studies. |
| Authors: | Xiuwen Zheng [aut, cre] (ORCID: <https://orcid.org/0000-0002-1390-0708>), Yuantao (Raven) Chen [ctb], Hufeng Zhou [ctb] |
| Maintainer: | Xiuwen Zheng <[email protected]> |
| License: | GPL-3 |
| Version: | 0.99.1 |
| Built: | 2026-09-27 08:29:14 UTC |
| Source: | https://github.com/BiocStaging/GDSAnnotator |
Fast and memory-efficient manipulation of whole-genome variant annotation data stored in Genomic Data Structure (GDS) files.
| Package: | GDSAnnotator |
| Type: | Package |
| License: | GPL-3 |
| Depends: | gdsfmt, SeqArray |
The package stores per-variant annotations in SeqArray GDS files, one chromosome per file, under the node "annotation/info". The columnar, typed and block-compressed layout is compact and supports random access, so a small set of variants can be annotated without reading the whole database.
Storing variant annotations in a GDS file was introduced by FAVOR with the annotated GDS (aGDS) format, in which the FAVOR functional annotations of the variants of a study are added to the SeqArray GDS file holding the genotypes. This package generalizes the format to annotation GDS files of any source, with or without genotypes: a whole-genome annotation database is kept as one GDS file per chromosome and queried by position and alleles, and the annotations of the variants of a study are written into its genotype GDS file (with the FAVOR annotations, this produces an aGDS file).
Import: seqToGDS_FAVOR,
seqToGDS_gnomAD, seqToGDS_VEP,
seqToGDS_SnpEff and seqToGDS_ANNOVAR
convert the annotation resources and the outputs of the
annotators to GDS files.
Annotate: seqAnnotate annotates variants given as
"chr-pos-ref-alt" strings, a data.frame or
DataFrame, a GRanges object, a VCF object
or file (seqAnnotateVCF) or a SeqArray GDS file
(seqAnnotateGDS), and can write the annotations
back into a GDS file block by block.
Explore & summarize: seqAnnotList lists the
annotations in a file, seqValueCounts tabulates
their values, and seqAnnotStat,
seqAnnotReport and seqAnnotGeneTable
produce VEP/SnpEff-like summary statistics and reports in a
single pass over the file.
Xiuwen Zheng [email protected]
Zhou H, Arapoglou T, Li X, et al. FAVOR: functional annotation of variants online resource and annotator for variation across the human genome. Nucleic Acids Res. 2023;51(D1):D1300-D1311. DOI: 10.1093/nar/gkac966.
Zheng X, Gogarten SM, Lawrence M, et al. SeqArray: a storage-efficient high-performance data format for WGS variant calls. Bioinformatics. 2017;33(15):2251-2257. DOI: 10.1093/bioinformatics/btx145.
seqOpen, seqGetData,
seqVCF2GDS
# FAVOR essential dataset of chromosome 22 (subset) annot_gds <- system.file("extdata", "favor_chr22_sub.gds", package="GDSAnnotator") # the annotations in the file seqAnnotList(annot_gds) # annotate two variants seqAnnotate(c("22-10510007-T-C", "22-10510038-T-C"), annot_gds, varnm=c("rsid", "cadd_phred", "linsight"))# FAVOR essential dataset of chromosome 22 (subset) annot_gds <- system.file("extdata", "favor_chr22_sub.gds", package="GDSAnnotator") # the annotations in the file seqAnnotList(annot_gds) # annotate two variants seqAnnotate(c("22-10510007-T-C", "22-10510038-T-C"), annot_gds, varnm=c("rsid", "cadd_phred", "linsight"))
Annotate a list of variants using the annotation stored in GDS files.
## S4 method for signature 'character' seqAnnotate(object, annot_gds, varnm, split="[-_:]", ..., verbose=TRUE) ## S4 method for signature 'data.frame' seqAnnotate(object, annot_gds, varnm, col_chr="chr", col_pos="pos", col_ref="ref", col_alt="alt", ..., verbose=TRUE) ## S4 method for signature 'DataFrame' seqAnnotate(object, annot_gds, varnm, col_chr="chr", col_pos="pos", col_ref="ref", col_alt="alt", ..., verbose=TRUE) ## S4 method for signature 'GRanges' seqAnnotate(object, annot_gds, varnm, ..., verbose=TRUE) ## S4 method for signature 'GRangesList' seqAnnotate(object, annot_gds, varnm, ..., verbose=TRUE) ## S4 method for signature 'IRanges' seqAnnotate(object, annot_gds, varnm, chr, ..., verbose=TRUE) ## S4 method for signature 'ANY' seqAnnotate(object, annot_gds, varnm, ..., verbose=TRUE) ## S4 method for signature 'SeqVarGDSClass' seqAnnotate(object, annot_gds, varnm, add_to_gds=FALSE, no_sample=TRUE, root="", cleanup=FALSE, bsize=1000000L, ..., verbose=TRUE) seqAnnotateGDS(gds_fn, annot_gds, varnm, add_to_gds=FALSE, no_sample=TRUE, root="", cleanup=TRUE, bsize=1000000L, ..., verbose=TRUE) seqAnnotateVCF(vcf_fn, annot_gds, varnm, ..., verbose=TRUE)## S4 method for signature 'character' seqAnnotate(object, annot_gds, varnm, split="[-_:]", ..., verbose=TRUE) ## S4 method for signature 'data.frame' seqAnnotate(object, annot_gds, varnm, col_chr="chr", col_pos="pos", col_ref="ref", col_alt="alt", ..., verbose=TRUE) ## S4 method for signature 'DataFrame' seqAnnotate(object, annot_gds, varnm, col_chr="chr", col_pos="pos", col_ref="ref", col_alt="alt", ..., verbose=TRUE) ## S4 method for signature 'GRanges' seqAnnotate(object, annot_gds, varnm, ..., verbose=TRUE) ## S4 method for signature 'GRangesList' seqAnnotate(object, annot_gds, varnm, ..., verbose=TRUE) ## S4 method for signature 'IRanges' seqAnnotate(object, annot_gds, varnm, chr, ..., verbose=TRUE) ## S4 method for signature 'ANY' seqAnnotate(object, annot_gds, varnm, ..., verbose=TRUE) ## S4 method for signature 'SeqVarGDSClass' seqAnnotate(object, annot_gds, varnm, add_to_gds=FALSE, no_sample=TRUE, root="", cleanup=FALSE, bsize=1000000L, ..., verbose=TRUE) seqAnnotateGDS(gds_fn, annot_gds, varnm, add_to_gds=FALSE, no_sample=TRUE, root="", cleanup=TRUE, bsize=1000000L, ..., verbose=TRUE) seqAnnotateVCF(vcf_fn, annot_gds, varnm, ..., verbose=TRUE)
object |
the variants to be annotated: a character vector of
variant identifiers combining chromosome, position, reference and
alternative alleles (e.g., "22-23413241-A-G", see |
gds_fn |
character for a SeqArray GDS file name |
vcf_fn |
character for a VCF or BCF file name, read by
|
annot_gds |
a character vector for GDS file names or a list of opened
GDS files ( |
varnm |
a character vector for GDS node names without the prefix
"annotation/info/"; ":id" for accessing "annotation/id", ":qual" for
"annotation/qual", ":filter" for "annotation/filter"; if it is missing,
to use all annotations in the first file of |
col_chr |
the column name for chromosome |
col_pos |
the column name for position |
col_ref |
the column name for the reference alleles |
col_alt |
the column name for the alternative alleles |
chr |
a character vector of chromosome(s), used with an
|
add_to_gds |
logical or character for an output file name; if
|
no_sample |
logical, when |
root |
character, to save the annotated GDS nodes to a |
cleanup |
if |
bsize |
the block size, i.e., the number of variants to be mapped
and written to the output GDS file at a time, when |
split |
regular expression to split the character vector in
|
verbose |
if |
... |
additional arguments passed to specific methods, e.g., from
|
If varnm=character() or NULL, seqAnnotate returns
a DataFrame object with two columns 'file_idx' and 'variant_idx' to indicate
where the variants are found, and NA in 'variant_idx' if the variant is not
found.
seqAnnotateGDS() opens the GDS file gds_fn and calls the
SeqVarGDSClass method. seqAnnotateVCF() reads the VCF file with
readVcf and annotates the VCF object.
The package VariantAnnotation should be installed for the VCF files and
objects: it is a suggested package loaded on demand, so the class VCF
is not used in a method signature, and a VCF object is handled by the
method for ANY, which checks the class of the object.
A VCF object is annotated for each alternative allele of each row: a
CollapsedVCF with multi-allelic sites gives one row per alternative
allele, a row without any alternative allele (ALT is ".") is skipped,
so the output can have more or fewer rows than the VCF object, and
expand can be used first to get one
alternative allele per row. The output is the same for a CollapsedVCF
and for its expanded version.
When the annotations are written to a GDS file (add_to_gds is
TRUE or a file name), the variants are matched and the annotation data
are loaded and written block by block (see bsize), so that the memory
usage does not depend on the total number of variants. The genotype GDS file
then holds the annotations of its variants under "annotation/info" (or under
"annotation/info/root"); with the annotations of FAVOR, this produces an
annotated GDS (aGDS) file, see seqToGDS_FAVOR.
Returns a DataFrame with one row per input variant (one row per
variant located in the ranges for a GRanges, GRangesList or
IRanges input, and one row per alternative allele for a VCF
input) and one column per annotation in varnm; the
annotations of a variant not found in annot_gds are NA. If
varnm=character() or NULL, the DataFrame has the two
columns 'file_idx' and 'variant_idx' instead, see details. When
add_to_gds is TRUE or a file name, the annotations are written
to the GDS file and NULL is returned invisibly.
Xiuwen Zheng
seqAnnotList, seqValueCounts,
seqToGDS_FAVOR, seqToGDS_VEP
# FAVOR essential dataset of chromosome 22 (subset) annot_gds <- system.file("extdata", "favor_chr22_sub.gds", package="GDSAnnotator") # list the annotations in the gds file (ann <- seqAnnotList(annot_gds)) varnm <- ann$name # use all annotation snp <- c("22-10510007-T-C", "22-10510038-T-C", "22-10510282-G-C", "22-10510303-G-C" # a fake SNP, return NA ) seqAnnotate(snp, annot_gds, varnm) # a subset of the annotations, from a data.frame df <- data.frame(chr="22", pos=c(10510007L, 10510038L, 10510282L), ref=c("T", "T", "G"), alt=c("C", "C", "C")) seqAnnotate(df, annot_gds, varnm=c("rsid", "cadd_phred", "linsight")) # all the variants located in the genomic ranges gr <- GenomicRanges::GRanges(seqnames = c("chr22", "chr22"), ranges = IRanges::IRanges(start = c(10510100, 10510225), end = c(10510125, 10510250))) seqAnnotate(gr, annot_gds, varnm) # the variants of a VCF file, one row per alternative allele (the package # VariantAnnotation should be installed) vcf_fn <- system.file("extdata", "gnomad.genomes.v4.chr22_sub.vcf.gz", package="GDSAnnotator") if (requireNamespace("VariantAnnotation", quietly=TRUE)) { res <- seqAnnotateVCF(vcf_fn, annot_gds, varnm=c("rsid", "cadd_phred")) print(head(res[!is.na(res$cadd_phred), ])) # or from a VCF object of the package VariantAnnotation vcf <- VariantAnnotation::readVcf(vcf_fn) res2 <- seqAnnotate(vcf, annot_gds, varnm=c("rsid", "cadd_phred")) print(identical(res, res2)) }# FAVOR essential dataset of chromosome 22 (subset) annot_gds <- system.file("extdata", "favor_chr22_sub.gds", package="GDSAnnotator") # list the annotations in the gds file (ann <- seqAnnotList(annot_gds)) varnm <- ann$name # use all annotation snp <- c("22-10510007-T-C", "22-10510038-T-C", "22-10510282-G-C", "22-10510303-G-C" # a fake SNP, return NA ) seqAnnotate(snp, annot_gds, varnm) # a subset of the annotations, from a data.frame df <- data.frame(chr="22", pos=c(10510007L, 10510038L, 10510282L), ref=c("T", "T", "G"), alt=c("C", "C", "C")) seqAnnotate(df, annot_gds, varnm=c("rsid", "cadd_phred", "linsight")) # all the variants located in the genomic ranges gr <- GenomicRanges::GRanges(seqnames = c("chr22", "chr22"), ranges = IRanges::IRanges(start = c(10510100, 10510225), end = c(10510125, 10510250))) seqAnnotate(gr, annot_gds, varnm) # the variants of a VCF file, one row per alternative allele (the package # VariantAnnotation should be installed) vcf_fn <- system.file("extdata", "gnomad.genomes.v4.chr22_sub.vcf.gz", package="GDSAnnotator") if (requireNamespace("VariantAnnotation", quietly=TRUE)) { res <- seqAnnotateVCF(vcf_fn, annot_gds, varnm=c("rsid", "cadd_phred")) print(head(res[!is.na(res$cadd_phred), ])) # or from a VCF object of the package VariantAnnotation vcf <- VariantAnnotation::readVcf(vcf_fn) res2 <- seqAnnotate(vcf, annot_gds, varnm=c("rsid", "cadd_phred")) print(identical(res, res2)) }
Return the number of annotation records of each gene, broken down by impact category.
seqAnnotGeneTable(stat)seqAnnotGeneTable(stat)
stat |
a |
The output is the equivalent of the "genes.txt" file of SnpEff. It is
NULL if the GDS file has no gene annotation, e.g., if the file was
not annotated by Ensembl-VEP or SnpEff.
Returns a data.frame with one row per gene, sorted by the total
count in decreasing order: the column gene for the gene symbol,
total for the total number of annotation records, and one column for
each impact category (HIGH, MODERATE, LOW and MODIFIER).
Xiuwen Zheng
# SnpEff-annotated variants of chromosome 22 (subset) gds_fn <- system.file("extdata", "example_wgs_sites_chr22_snpeff.gds", package="GDSAnnotator") st <- seqAnnotStat(gds_fn, verbose=FALSE) head(seqAnnotGeneTable(st))# SnpEff-annotated variants of chromosome 22 (subset) gds_fn <- system.file("extdata", "example_wgs_sites_chr22_snpeff.gds", package="GDSAnnotator") st <- seqAnnotStat(gds_fn, verbose=FALSE) head(seqAnnotGeneTable(st))
List the annotations stored in the GDS file.
seqAnnotList(gdsfile)seqAnnotList(gdsfile)
gdsfile |
a |
Returns a DataFrame with the columns 'name', 'type' (R data type),
'trait' (data type defined in GDS) and 'description'.
Xiuwen Zheng
# gnomAD v4.1.0 dataset of chromosome 22 gds_fn <- system.file("extdata", "gnomad.genomes.v4.chr22_sub.gds", package="GDSAnnotator") # list the annotations in the gds file seqAnnotList(gds_fn)# gnomAD v4.1.0 dataset of chromosome 22 gds_fn <- system.file("extdata", "gnomad.genomes.v4.chr22_sub.gds", package="GDSAnnotator") # list the annotations in the gds file seqAnnotList(gds_fn)
Generate a summary report of the variants and their annotations stored in a SeqArray GDS file, in HTML or Markdown format, similar to the reports of Ensembl-VEP and SnpEff.
seqAnnotReport(stat, out_fn="annot_summary.html", format=c("auto", "html", "markdown", "rmd"), title="GDSAnnotator Summary Report", parallel=FALSE, bsize=100000L, verbose=TRUE)seqAnnotReport(stat, out_fn="annot_summary.html", format=c("auto", "html", "markdown", "rmd"), title="GDSAnnotator Summary Report", parallel=FALSE, bsize=100000L, verbose=TRUE)
stat |
a |
out_fn |
the file name of the output report |
format |
the output format: |
title |
the title of the report |
parallel |
the number of processes, passed to
|
bsize |
block size, passed to |
verbose |
if |
The three output formats show the same content: the report is first built as a format-independent list of sections, then rendered. None of them writes a companion image directory, i.e., the report is always a single file.
The HTML output is self-contained, using plain HTML tables and inline SVG charts, so it requires no JavaScript, no pandoc and no additional package, and it can be viewed offline.
The Markdown output uses GitHub-flavored pipe tables, with the bar charts drawn using block characters, so that it is also readable as plain text.
The R Markdown output embeds the counts in the document as R code, and
the charts are drawn by barplot() when the document is knitted, e.g.,
by rmarkdown::render(). Use this format to restyle the charts, to add
text of your own, or to include the report in a larger document. The code
chunks are hidden by echo=FALSE in the setup chunk.
The report contains a general information section (the annotator version and command line taken from the VCF header, the number of variants, annotation records, genes and transcripts, and the variant rate), the variant-level sections (variants per chromosome, variant classes, base changes with the Ts/Tv ratio, InDel length distribution, alleles per variant, known vs. novel, FILTER and QUAL) and, if the file was annotated by Ensembl-VEP or SnpEff, the annotation sections (consequences for all records and for the most severe consequence per variant, region, impact, functional class with the Missense/Silent ratio, transcript biotypes, feature types, SIFT and PolyPhen predictions, the warnings reported by the annotator, and the most frequently annotated genes).
Return the file name of the report with an absolute path.
Xiuwen Zheng
seqAnnotStat, seqAnnotGeneTable
# Ensembl-VEP annotated variants of chromosome 22 (subset) gds_fn <- system.file("extdata", "example_wgs_sites_chr22_vep.gds", package="GDSAnnotator") # HTML report html_fn <- tempfile(fileext=".html") seqAnnotReport(gds_fn, html_fn, title="Ensembl-VEP, chromosome 22", verbose=FALSE) # Markdown report, reusing the statistics st <- seqAnnotStat(gds_fn, verbose=FALSE) md_fn <- tempfile(fileext=".md") seqAnnotReport(st, md_fn, title="Ensembl-VEP, chromosome 22", verbose=FALSE) cat(head(readLines(md_fn), 20), sep="\n") # R Markdown source, to be knitted by rmarkdown::render() rmd_fn <- tempfile(fileext=".Rmd") seqAnnotReport(st, rmd_fn, title="Ensembl-VEP, chromosome 22", verbose=FALSE) # remove the temporary files unlink(c(html_fn, md_fn, rmd_fn), force=TRUE)# Ensembl-VEP annotated variants of chromosome 22 (subset) gds_fn <- system.file("extdata", "example_wgs_sites_chr22_vep.gds", package="GDSAnnotator") # HTML report html_fn <- tempfile(fileext=".html") seqAnnotReport(gds_fn, html_fn, title="Ensembl-VEP, chromosome 22", verbose=FALSE) # Markdown report, reusing the statistics st <- seqAnnotStat(gds_fn, verbose=FALSE) md_fn <- tempfile(fileext=".md") seqAnnotReport(st, md_fn, title="Ensembl-VEP, chromosome 22", verbose=FALSE) cat(head(readLines(md_fn), 20), sep="\n") # R Markdown source, to be knitted by rmarkdown::render() rmd_fn <- tempfile(fileext=".Rmd") seqAnnotReport(st, rmd_fn, title="Ensembl-VEP, chromosome 22", verbose=FALSE) # remove the temporary files unlink(c(html_fn, md_fn, rmd_fn), force=TRUE)
Calculate the summary statistics of the variants and their annotations stored in a SeqArray GDS file, in a single pass over the file.
seqAnnotStat(gdsfile, parallel=FALSE, bsize=100000L, verbose=TRUE) ## S3 method for class 'SeqAnnotStat' print(x, ...)seqAnnotStat(gdsfile, parallel=FALSE, bsize=100000L, verbose=TRUE) ## S3 method for class 'SeqAnnotStat' print(x, ...)
gdsfile |
a |
parallel |
|
bsize |
block size, i.e., the number of variants to be processed at a time |
verbose |
if |
x |
a |
... |
unused arguments |
All statistics are collected in a single call to
seqBlockApply, so that the file is scanned only once
no matter how many statistics are reported. Each statistic is stored as a
named vector of counts, and the counts are additive: when gdsfile is a
character vector of multiple file names (e.g., one GDS file per chromosome),
the files are summarized one by one and the counters are merged into a single
object. The memory usage is proportional to the number of distinct categories
(e.g., the number of genes), not to the number of variants.
Since the counters are additive, parallel splits the variants
between the processes, each process calculates its own counters, and the
results are merged. Each counter is a named numeric vector, and its
categories are stored in a fixed order (e.g., the chromosomes in numerical
order, the impact categories from HIGH to MODIFIER, and the other categories
in alphabetical order), so that the output does not depend on
parallel or on bsize.
The variant-level statistics (the number of variants per chromosome, the variant classes, the base changes and the Ts/Tv ratio, the InDel length distribution, the number of alleles, known vs. novel, FILTER and QUAL) are derived from the nodes "chromosome", "position", "allele", "annotation/id", "annotation/qual" and "annotation/filter".
The annotation statistics are calculated when the GDS file contains the
sub-fields of Ensembl-VEP ("annotation/info/CSQ.list", see
seqToGDS_VEP) or SnpEff ("annotation/info/ANN.list", see
seqToGDS_SnpEff). Both annotators report Sequence Ontology
terms, and an internal table ("so_consequence.csv" in the "extdata" folder)
is used to rank the consequences by severity, to classify them into impact
categories (HIGH, MODERATE, LOW and MODIFIER), into functional classes
(MISSENSE, NONSENSE and SILENT) and into genomic regions. The consequences
are counted twice: once for every annotation record (e.g., one record per
transcript), and once per variant using only the most severe consequence.
Returns an object of class SeqAnnotStat, a list with the
components: file, filesize, n_variant, source
(the annotator), profile (the annotation sub-fields in use),
header (the VCF header), counts (a list of named numeric
vectors of counts) and created.
Xiuwen Zheng
seqAnnotReport, seqAnnotGeneTable,
seqValueCounts, seqAnnotList
# SnpEff-annotated variants of chromosome 22 (subset) gds_fn <- system.file("extdata", "example_wgs_sites_chr22_snpeff.gds", package="GDSAnnotator") (st <- seqAnnotStat(gds_fn, verbose=FALSE)) # the most severe consequence of each variant st$counts$cons_severe # the impact of every annotation record st$counts$impact # transitions & transversions st$counts$base_change # using two processes: the counters are additive, so the result is the same st2 <- seqAnnotStat(gds_fn, parallel=2L, verbose=FALSE) identical(st$counts, st2$counts)# SnpEff-annotated variants of chromosome 22 (subset) gds_fn <- system.file("extdata", "example_wgs_sites_chr22_snpeff.gds", package="GDSAnnotator") (st <- seqAnnotStat(gds_fn, verbose=FALSE)) # the most severe consequence of each variant st$counts$cons_severe # the impact of every annotation record st$counts$impact # transitions & transversions st$counts$base_change # using two processes: the counters are additive, so the result is the same st2 <- seqAnnotStat(gds_fn, parallel=2L, verbose=FALSE) identical(st$counts, st2$counts)
Convert ANNOVAR-annotated VCF output (from table_annovar.pl) to a
SeqArray GDS file. Unlike VEP or SnpEff which pack annotations into a
single pipe-delimited INFO field, ANNOVAR stores each annotation as a
separate INFO key-value pair. This function imports the VCF via
seqVCF2GDS, removes ANNOVAR bookkeeping fields
(ANNOVAR_DATE, ALLELE_END), and optionally adds
descriptions and type information for known ANNOVAR annotation columns.
seqToGDS_ANNOVAR(vcf_fn, out_fn, compress=c("LZMA", "ZIP", "none"), keep=TRUE, verbose=TRUE)seqToGDS_ANNOVAR(vcf_fn, out_fn, compress=c("LZMA", "ZIP", "none"), keep=TRUE, verbose=TRUE)
vcf_fn |
the path(s) of VCF file from ANNOVAR output
(generated by |
out_fn |
the file name of output SeqArray GDS file |
compress |
compression method (LZMA by default), |
keep |
if |
verbose |
if |
ANNOVAR's table_annovar.pl with -vcfinput adds annotations
as individual INFO fields in the VCF output, such as
Func.refGeneWithVer, Gene.refGeneWithVer,
ExonicFunc.refGeneWithVer, AAChange.refGeneWithVer,
gnomAD_exome_AF, SIFT_score, CADD_phred, etc.
Each annotation becomes a separate node under annotation/info/
in the output GDS file.
The function automatically removes the ANNOVAR_DATE and
ALLELE_END bookkeeping fields that ANNOVAR adds to the VCF.
Known ANNOVAR annotation fields are matched against an internal
metadata table to add descriptions.
Return the file name of GDS format with an absolute path.
Xiuwen Zheng
Wang K, Li M, Hakonarson H. ANNOVAR: functional annotation of genetic variants from high-throughput sequencing data. Nucleic Acids Research, 38(16):e164, 2010. DOI: 10.1093/nar/gkq603.
seqVCF2GDS, seqToGDS_VEP,
seqToGDS_SnpEff
# ANNOVAR annotation vcf_fn <- system.file("extdata", "example_wgs_sites_chr22_annovar.vcf.gz", package="GDSAnnotator") out_fn <- tempfile(fileext=".gds") seqToGDS_ANNOVAR(vcf_fn, out_fn) # list the annotations in the output file seqAnnotList(out_fn) # delete the temporary file unlink(out_fn, force=TRUE)# ANNOVAR annotation vcf_fn <- system.file("extdata", "example_wgs_sites_chr22_annovar.vcf.gz", package="GDSAnnotator") out_fn <- tempfile(fileext=".gds") seqToGDS_ANNOVAR(vcf_fn, out_fn) # list the annotations in the output file seqAnnotList(out_fn) # delete the temporary file unlink(out_fn, force=TRUE)
Convert FAVOR CSV files to a SeqArray GDS file.
seqToGDS_FAVOR(csv_fn, out_fn, compress=c("LZMA", "ZIP", "none"), root="FAVOR", use_float32=TRUE, verbose=TRUE) seqToGDS_FAVOR_tar(tar_fn, out_fn, fn_in_tar=NULL, compress=c("LZMA", "ZIP", "none"), root="", use_float32=TRUE, block_size=100000L, tar_cmd=Sys.getenv("TAR"), verbose=TRUE)seqToGDS_FAVOR(csv_fn, out_fn, compress=c("LZMA", "ZIP", "none"), root="FAVOR", use_float32=TRUE, verbose=TRUE) seqToGDS_FAVOR_tar(tar_fn, out_fn, fn_in_tar=NULL, compress=c("LZMA", "ZIP", "none"), root="", use_float32=TRUE, block_size=100000L, tar_cmd=Sys.getenv("TAR"), verbose=TRUE)
csv_fn |
the path(es) of FAVOR csv file |
tar_fn |
the path of a FAVOR tar file containing csv files |
out_fn |
the file name of output SeqArray GDS file |
compress |
compression method (LZMA by default), |
root |
specify the GDS node, the annotation will be stored in
"annotation/info/root"; if |
use_float32 |
if |
fn_in_tar |
a character vector for the csv file names in the tar file |
block_size |
the block size (# of lines) for reading a csv file |
tar_cmd |
the path of TAR to the command to be used |
verbose |
if |
The CSV files (which may be gzip-compressed) should have the columns
"variant_vcf", "chromosome", "position", "ref_vcf" and "alt_vcf"; all the
other columns are stored as annotations under "annotation/info" (or under
"annotation/info/root" if root is not empty). The column types of the
FAVOR essential database are defined in the internal table
"favor_csv_header.csv" in the "extdata" folder.
seqToGDS_FAVOR_tar() reads the CSV files directly from a tar
archive (e.g., the per-chromosome files of the FAVOR essential database)
block by block, so that it does not require extracting the archive nor
loading a whole CSV file in memory; it calls the external program
tar_cmd via pipe(), so a tar program should be available
on the system.
Return the file name of GDS format with an absolute path.
Xiuwen Zheng
Zhou H, Arapoglou T, ..., Lin X. FAVOR: Functional Annotation of Variants Online Resource and Annotator for Variation across the Human Genome. NAR 2022 Nov 9; gkac966. PMID: 36350676. DOI: 10.1093/nar/gkac966.
# FAVOR essential dataset of chromosome 22 (subset) in CSV format csv_fn <- system.file("extdata", "favor_chr22_sub.csv.gz", package="GDSAnnotator") out_fn <- tempfile(fileext=".gds") seqToGDS_FAVOR(csv_fn, out_fn) # list the annotations in the output file seqAnnotList(out_fn) # delete the temporary file unlink(out_fn, force=TRUE)# FAVOR essential dataset of chromosome 22 (subset) in CSV format csv_fn <- system.file("extdata", "favor_chr22_sub.csv.gz", package="GDSAnnotator") out_fn <- tempfile(fileext=".gds") seqToGDS_FAVOR(csv_fn, out_fn) # list the annotations in the output file seqAnnotList(out_fn) # delete the temporary file unlink(out_fn, force=TRUE)
Convert gnomAD VCF files to a SeqArray GDS file.
seqToGDS_gnomAD(vcf_fn, out_fn, compress=c("LZMA", "ZIP", "none"), verbose=TRUE)seqToGDS_gnomAD(vcf_fn, out_fn, compress=c("LZMA", "ZIP", "none"), verbose=TRUE)
vcf_fn |
the path(es) of gnomAD VCF file |
out_fn |
the file name of output SeqArray GDS file |
compress |
compression method (LZMA by default), |
verbose |
if |
Return the file name of GDS format with an absolute path.
Xiuwen Zheng
Chen S, Francioli LC, Goodrich, JK, Collins, RL, etc., Nature. 625, 92-100 (2024). doi.org/10.1038/s41586-023-06045-0. PMID: 38057664
# gnomAD v4.1.0 dataset of chromosome 22 vcf_fn <- system.file("extdata", "gnomad.genomes.v4.chr22_sub.vcf.gz", package="GDSAnnotator") out_fn <- tempfile(fileext=".gds") seqToGDS_gnomAD(vcf_fn, out_fn) # list the annotations in the output file seqAnnotList(out_fn) # delete the temporary file unlink(out_fn, force=TRUE)# gnomAD v4.1.0 dataset of chromosome 22 vcf_fn <- system.file("extdata", "gnomad.genomes.v4.chr22_sub.vcf.gz", package="GDSAnnotator") out_fn <- tempfile(fileext=".gds") seqToGDS_gnomAD(vcf_fn, out_fn) # list the annotations in the output file seqAnnotList(out_fn) # delete the temporary file unlink(out_fn, force=TRUE)
Convert SnpEff VCF output to a SeqArray GDS file.
seqToGDS_SnpEff(vcf_fn, out_fn, compress=c("LZMA", "ZIP", "none"), root=c("ANN", "LOF", "NMD"), keep=FALSE, bsize=50000L, verbose=TRUE)seqToGDS_SnpEff(vcf_fn, out_fn, compress=c("LZMA", "ZIP", "none"), root=c("ANN", "LOF", "NMD"), keep=FALSE, bsize=50000L, verbose=TRUE)
vcf_fn |
the path(es) of VCF file from SnpEff output |
out_fn |
the file name of output SeqArray GDS file |
compress |
compression method (LZMA by default), |
root |
the name(s) of INFO field in the input VCF file to be parsed |
keep |
if |
bsize |
the block size (number of variants per chunk) for processing annotations; a smaller value reduces peak memory usage at the cost of more iterations |
verbose |
if |
Return the file name of GDS format with an absolute path.
Xiuwen Zheng
Cingolani, P., Platts, A., Wang le L., Coon, M., Nguyen, T., Wang, L., Land, S.J., Lu, X., & Ruden, D.M. (2012). A program for annotating and predicting the effects of single nucleotide polymorphisms, SnpEff: SNPs in the genome of Drosophila melanogaster strain w1118; iso-2; iso-3. Fly, 6(2), 80-92. PMID: 22728672.
# SnpEff annotation vcf_fn <- system.file("extdata", "example_wgs_sites_chr22_snpeff.vcf.gz", package="GDSAnnotator") out_fn <- tempfile(fileext=".gds") seqToGDS_SnpEff(vcf_fn, out_fn) # list the annotations in the output file seqAnnotList(out_fn) # delete the temporary file unlink(out_fn, force=TRUE)# SnpEff annotation vcf_fn <- system.file("extdata", "example_wgs_sites_chr22_snpeff.vcf.gz", package="GDSAnnotator") out_fn <- tempfile(fileext=".gds") seqToGDS_SnpEff(vcf_fn, out_fn) # list the annotations in the output file seqAnnotList(out_fn) # delete the temporary file unlink(out_fn, force=TRUE)
Convert Ensembl-VEP VCF output to a SeqArray GDS file.
seqToGDS_VEP(vcf_fn, out_fn, compress=c("LZMA", "ZIP", "none"), root="CSQ", keep=FALSE, bsize=50000L, verbose=TRUE)seqToGDS_VEP(vcf_fn, out_fn, compress=c("LZMA", "ZIP", "none"), root="CSQ", keep=FALSE, bsize=50000L, verbose=TRUE)
vcf_fn |
the path(es) of VCF file from Ensembl-VEP output |
out_fn |
the file name of output SeqArray GDS file |
compress |
compression method (LZMA by default), |
root |
the name of INFO field in the input VCF file, the default is
|
keep |
if |
bsize |
the block size (number of variants per chunk) for processing annotations; a smaller value reduces peak memory usage at the cost of more iterations |
verbose |
if |
Return the file name of GDS format with an absolute path.
Xiuwen Zheng
McLaren W, Gil L, Hunt SE, Riat HS, Ritchie GR, Thormann A, Flicek P, Cunningham F. The Ensembl Variant Effect Predictor. Genome Biology Jun 6; 17(1):122. (2016) DOI:10.1186/s13059-016-0974-4.
# Ensembl-VEP annotation vcf_fn <- system.file("extdata", "example_wgs_sites_chr22_vep.vcf.gz", package="GDSAnnotator") out_fn <- tempfile(fileext=".gds") seqToGDS_VEP(vcf_fn, out_fn) # list the annotations in the output file seqAnnotList(out_fn) # delete the temporary file unlink(out_fn, force=TRUE)# Ensembl-VEP annotation vcf_fn <- system.file("extdata", "example_wgs_sites_chr22_vep.vcf.gz", package="GDSAnnotator") out_fn <- tempfile(fileext=".gds") seqToGDS_VEP(vcf_fn, out_fn) # list the annotations in the output file seqAnnotList(out_fn) # delete the temporary file unlink(out_fn, force=TRUE)
Calculate the counts of unique values.
seqValueCounts(gdsfile, varnm, use_info=TRUE, FUN=NULL, per_variant=FALSE, parallel=FALSE, bsize=100000L, verbose=TRUE, ...)seqValueCounts(gdsfile, varnm, use_info=TRUE, FUN=NULL, per_variant=FALSE, parallel=FALSE, bsize=100000L, verbose=TRUE, ...)
gdsfile |
a |
varnm |
a character vector containing GDS node name(s) |
use_info |
|
FUN |
|
per_variant |
|
parallel |
|
bsize |
block size |
verbose |
if |
... |
additional arguments passed to |
Returns a contingency table, an object of class table, an array of
integer values.
Xiuwen Zheng
# gnomAD v4.1.0 dataset of chromosome 22 gds_fn <- system.file("extdata", "gnomad.genomes.v4.chr22_sub.gds", package="GDSAnnotator") # open the file f <- seqOpen(gds_fn) # list the annotations in the gds file (a <- seqAnnotList(f)) seqValueCounts(f, "variant_type") seqValueCounts(f, "was_mixed") seqValueCounts(f, c("variant_type", "allele_type")) seqValueCounts(f, c("variant_type", "allele_type", "was_mixed")) seqClose(f)# gnomAD v4.1.0 dataset of chromosome 22 gds_fn <- system.file("extdata", "gnomad.genomes.v4.chr22_sub.gds", package="GDSAnnotator") # open the file f <- seqOpen(gds_fn) # list the annotations in the gds file (a <- seqAnnotList(f)) seqValueCounts(f, "variant_type") seqValueCounts(f, "was_mixed") seqValueCounts(f, c("variant_type", "allele_type")) seqValueCounts(f, c("variant_type", "allele_type", "was_mixed")) seqClose(f)