Package version: GA4GHclient 1.0.0


1 Introduction

The Global Alliance for Genomics and Health (GA4GH) was formed to help accelerate the potential of genomic medicine to advance human health. It brings together over 400 leading institutions working in healthcare, research, disease advocacy, life science, and information technology. The Data Working Group of the GA4GH developed data model schemas and application program interfaces (APIs) for genomic data. These APIs are specifically designed to allow sharing of genomics data in a standardized manner and without having to exchange complete experiments. They developed a reference implementation for these APIs providing a web server for hosting genomic data.

The Bioconductor project provides tools for the analysis and comprehension of high-throughput genomic data. It uses the R statistical programming language, and is open source and open development. The Bioconductor provides stable representations for genomics data such as biological sequences and genomic variants.

We developed GA4GHclient, a Bioconductor package that provides an easy way to access public data servers through GA4GH APIs. The requested output data are converted into tidy data and presented as data frames. Our package provides methods for converting genomic variant data into VCF data allowing the creation of complex data analysis using public genomic data and well validated Bioconductor packages. This package also provides an interactive web application for interacting with genomics data through GA4GH APIs.

Public data servers that use GA4GH Genomics API:

2 Available request methods

The table below shows all available methods in GA4GHclient package. These methods are based on the official GA4GH schemas. Let us know if some method is missing by opening an issue at

Method Description
searchDatasets Search for datasets
searchReferenceSets Search for reference sets (reference genomes)
searchReferences Search for references (genome sequences, e.g. chromosomes)
listReferenceBases Get the sequence bases of a reference genome by genomic range
searchVariantSets Search for for variant sets (VCF files)
searchVariants Search for variants by genomic ranges (lines of VCF files)
searchCallSets Search for call sets (sample columns of VCF files)
searchVariantAnnotationSets Search for variant annotation sets (annotated VCF files)
searchVariantAnnotations Search for annotated variants by genomic range
searchFeatureSets Search for feature sets (genomic features, e.g. GFF files)
searchFeatures Search for features (lines of genomic feature files)
searchReadGroupSets Search for read group sets (sequence alignement, e.g BAM files)
searchReads Search for reads by genomic range (bases of aligned sequences)
searchBiosamples Search for biosamples
searchIndividuals Search for individuals
searchRnaQuantificationSets Search for RNA quantification sets
searchRnaQuantifications Search for RNA quantifications
searchExpressionLevels Search for expression levels
searchPhenotypeAssociationSets Search for phenotype association sets
searchPhenotypeAssociations Search for phenotype associations
getDataset Get a dataset by its ID
getReferenceSet Get a reference set by its ID
getReference Get a reference by its ID
getVariantSet Get a variant set by its ID
getVariant Get a variant by its ID with all call sets for this variant
getCallSet Get a call set by its ID
getVariantAnnotationSet Get a variant annotation set by its ID
getVariantAnnotation Get an annotated variant by its ID
getFeatureSet Get a feature set by its ID
getFeature Get a feature by its ID
getReadGroupSet Get a read group set by its ID
getBiosample Get a biosample by its ID
getIndividual Get an individual by its ID
getRnaQuantificationSet Get an RNA quantification set by its ID
getRnaQuantification Get an RNA quantification by its ID
getExpressionLevel Get an expression level by its ID

3 Retrieving Thousand Genomes Project data through GA4GHclient package

First, load required packages for this vignette.


For this example we will use Hosting Thousand Genomes Project server. It contains data from the 1000 Genomes project. Set the URL of GA4GH API data server. This variable will be used by all request functions.

host <- ""

Get basic information about data server. The dataset may contain many variant sets. A variant set represents the header of an VCF file. A collection of variants represent lines of an VCF file. The nrow attribute define the amount of entries we want to get from the server. For the dataset and variant set we want only the first entry.

The searchVariants function requests genomic variant data from the server. It uses genomic intervals to retrieve these varants. As R programming language, the genomic indice is 1-based. If you want to see what reference names (e.g. chromosomes) are available run the searchReferences function.

datasets <- searchDatasets(host, nrows = 1)
datasetId <- datasets$id
variantSets <- searchVariantSets(host, datasetId, nrows = 1)
variantSetId <- variantSets$id
variants <- searchVariants(host, variantSetId, referenceName = "1",
    start = 15000, end = 16000, nrows = 10)
## class: CollapsedVCF 
## dim: 10 0 
## rowRanges(vcf):
##   GRanges with 3 metadata columns: ID, REF, ALT
## info(vcf):
##   DataFrame with 14 columns: EUR_AF, SAS_AF, AC, AA, AF, AFR_AF, AMR_AF...
## info(header(vcf)):
##                  Number Type    Description                               
##    EUR_AF        A      Float   Allele frequency in the EUR populations...
##    SAS_AF        A      Float   Allele frequency in the SAS populations...
##    AC            A      Integer Total number of alternate alleles in ca...
##    AA            1      String  Ancestral Allele. Format: AA|REF|ALT|In...
##    AF            A      Float   Estimated allele frequency in the range...
##    AFR_AF        A      Float   Allele frequency in the AFR populations...
##    AMR_AF        A      Float   Allele frequency in the AMR populations...
##    AN            1      Integer Total number of alleles in called genot...
##    VT            .      String  indicates what type of variant the line...
##    EAS_AF        A      Float   Allele frequency in the EAS populations...
##    NS            1      Integer Number of samples with data               
##    EX_TARGET     0      Flag    indicates whether a variant is within t...
##    DP            1      Integer Total read depth; only low coverage dat...
##    MULTI_ALLELIC 0      Flag    indicates whether a site is multi-allelic 
## geno(vcf):
##   SimpleList of length 0:

Almost search functions will return an DataFrame object from S4Vector package. The searchVariants and getVariant functions will return an VCF object with header from VariantAnnotation package. The getVariantSet function will return an VCFHeader object. These three functions will return DataFrame object when asVCF or asVCFHeader parameters be FALSE.

variants.df <- searchVariants(host, variantSetId, referenceName = "1",
    start = 15000, end = 16000, nrows = 10, asVCF = FALSE)
DT::datatable(, options = list(scrollX = TRUE))

Due to internet connection, there is a limit of amount for response data imposed by the server (or the responseSize parameter). By default the function will make requests until get all response data. Increasing the value of the responseSize parameter will reduce the number os requests to server.

4 Search Variants by genomic location of genes

Bioconductor has annotation packages for many genomes. For example, the TxDb.Hsapiens.UCSC.hg19.knownGene pakage exposes an annotation databases generated from UCSC by exposing these as TxDb objects. Before using annotation packages, it is very important to check what version of reference genome was used by the GA4GH API-based data server. In other words, what reference genome was used to align sequencing reads and call for variants. This information can be accessed via searchReferenceSets function.

referenceSets <- searchReferenceSets(host, nrows = 1)

In this case, the version of reference genome is NCBI37, which is compatible with TxDb.Hsapiens.UCSC.hg19.knownGene.

Get name of all available genes.

head(keys(, keytype = "SYMBOL"))
## [1] "A1BG"  "A2M"   "A2MP1" "NAT1"  "NAT2"  "NATP"

Get genomic location of all genes.

## GRanges object with 6 ranges and 1 metadata column:
##             seqnames                 ranges strand |     gene_id
##                <Rle>              <IRanges>  <Rle> | <character>
##           1    chr19 [ 58858172,  58874214]      - |           1
##          10     chr8 [ 18248755,  18258723]      + |          10
##         100    chr20 [ 43248163,  43280376]      - |         100
##        1000    chr18 [ 25530930,  25757445]      - |        1000
##       10000     chr1 [243651535, 244006886]      - |       10000
##   100008586     chrX [ 49217763,  49233491]      + |   100008586
##   -------
##   seqinfo: 93 sequences (1 circular) from hg19 genome

Use case: search for variants located in SCN1A gene.

df <- select(, keys = "SCN1A", columns = c("SYMBOL", "ENTREZID"), keytype = "SYMBOL")
## 'select()' returned 1:1 mapping between keys and columns
gr <- genes(TxDb.Hsapiens.UCSC.hg19.knownGene, filter=list(gene_id=df$ENTREZID))
seqlevelsStyle(gr) <- "NCBI"
variants.scn1a <- searchVariantsByGRanges(host, variantSetId, gr, asVCF = FALSE)
DT::datatable([[1]]), options = list(scrollX = TRUE))
## Warning in instance$preRenderHook(instance): It seems your data is too
## big for client-side DataTables. You may consider server-side processing: