Package version: cellbaseR 1.0.0

Contents

1 Introduction to CellbaseR

This R package makes use of the exhaustive RESTful Web service API that has been implemented for the Cellabase database. It enable researchers to query and obtain a wealth of biological information from a single database saving a lot of time. Another benefit is that researchers can easily make queries about different biological topics and link all this information together as all information is integrated.

2 CellbaseR Classes and Methods

2.1 The CellbaseR class

This is an S4 class that holds the basic configuration for connecting to the Cellbase web services. Let us start by loading the library.

# to get the default CellbaseR object (human data, from genome GRCh37)
library(cellbaseR)
# A default cellbaseR object is created as follows
cb <- CellBaseR()

2.2 The CellbaseR Methods

The cellbaseR package provide many methods to query the cellbase webservices, they include:

In all cases the user is expected to provide the ids for the query and the resource to be queried, in addition to the CellbaseQuery object they created. For example, a query through the cbGene will look something like this

2.2.1 getGene

library(cellbaseR)
cb <- CellBaseR()
genes <- c("TP73","TET1")
res <- getGene(object = cb, ids = genes, resource = "info")
str(res,2)
## 'data.frame':    2 obs. of  12 variables:
##  $ id         : chr  "ENSG00000078900" "ENSG00000138336"
##  $ name       : chr  "TP73" "TET1"
##  $ biotype    : chr  "protein_coding" "protein_coding"
##  $ status     : chr  "KNOWN" "KNOWN"
##  $ chromosome : chr  "1" "10"
##  $ start      : int  3569084 70320413
##  $ end        : int  3652765 70454239
##  $ strand     : chr  "+" "+"
##  $ source     : chr  "Ensembl" "Ensembl"
##  $ description: chr  "tumor protein p73 [Source:HGNC Symbol;Acc:HGNC:12003]" "tet methylcytosine dioxygenase 1 [Source:HGNC Symbol;Acc:HGNC:29484]"
##  $ transcripts:List of 2
##   ..$ :'data.frame': 14 obs. of  20 variables:
##   ..$ :'data.frame': 1 obs. of  20 variables:
##  $ annotation :'data.frame': 2 obs. of  2 variables:
##   ..$ expression:List of 2
##   ..$ diseases  :List of 2
# as you can see the res dataframe also contains a transcripts column 
# which is in fact a list column of nested dataframes, to get the
# trasnscripts data.frame for first gene
TET1_transcripts <- res$transcripts[[1]]
str(TET1_transcripts,1)
## 'data.frame':    14 obs. of  20 variables:
##  $ id                : chr  "ENST00000378295" "ENST00000604074" "ENST00000354437" "ENST00000357733" ...
##  $ name              : chr  "TP73-001" "TP73-006" "TP73-002" "TP73-202" ...
##  $ biotype           : chr  "protein_coding" "protein_coding" "protein_coding" "protein_coding" ...
##  $ status            : chr  "KNOWN" "KNOWN" "KNOWN" "KNOWN" ...
##  $ chromosome        : chr  "1" "1" "1" "1" ...
##  $ start             : int  3569084 3569084 3569129 3569129 3569129 3598930 3598930 3607236 3607236 3607236 ...
##  $ end               : int  3652765 3652765 3649856 3650467 3650467 3649643 3649643 3649856 3649856 3652765 ...
##  $ strand            : chr  "+" "+" "+" "+" ...
##  $ genomicCodingStart: int  3598930 3598930 3598930 3598930 3598930 3598930 3598930 3607470 3607470 3607470 ...
##  $ genomicCodingEnd  : int  3649643 3649326 3649326 3649643 3649643 3649643 3649643 3649326 3648119 3649643 ...
##  $ cdnaCodingStart   : int  156 156 111 111 111 1 1 235 235 235 ...
##  $ cdnaCodingEnd     : int  2066 1367 1610 1778 1733 1668 1623 1587 1515 1998 ...
##  $ cdsLength         : int  1910 1211 1499 1667 1622 1667 1622 1352 1280 1763 ...
##  $ proteinID         : chr  "ENSP00000367545" "ENSP00000475143" "ENSP00000346423" "ENSP00000350366" ...
##  $ proteinSequence   : chr  "MAQSTATSPDGGTTFEHLWSSLEPDSTYFDLPQSSRGNNEVVGGTDSSMDVFHLEGMTTSVMAQFNLLSSTMDQMSSRAASASPYTPEHAASVPTHSPYAQPSSTFDTMSP"| __truncated__ "MAQSTATSPDGGTTFEHLWSSLEPDSTYFDLPQSSRGNNEVVGGTDSSMDVFHLEGMTTSVMAQFNLLSSTMDQMSSRAASASPYTPEHAASVPTHSPYAQPSSTFDTMSP"| __truncated__ "MAQSTATSPDGGTTFEHLWSSLEPDSTYFDLPQSSRGNNEVVGGTDSSMDVFHLEGMTTSVMAQFNLLSSTMDQMSSRAASASPYTPEHAASVPTHSPYAQPSSTFDTMSP"| __truncated__ "MAQSTATSPDGGTTFEHLWSSLEPDSTYFDLPQSSRGNNEVVGGTDSSMDVFHLEGMTTSVMAQFNLLSSTMDQMSSRAASASPYTPEHAASVPTHSPYAQPSSTFDTMSP"| __truncated__ ...
##  $ cDnaSequence      : chr  "TGCCTCCCCGCCCGCGCACCCGCCCGGAGGCTCGCGCGCCCGCGAAGGGGACGCAGCGAAACCGGGGCCCGCGCCAGGCCAGCCGGGACGGACGCCGATGCCCGGGGCTGC"| __truncated__ "TGCCTCCCCGCCCGCGCACCCGCCCGGAGGCTCGCGCGCCCGCGAAGGGGACGCAGCGAAACCGGGGCCCGCGCCAGGCCAGCCGGGACGGACGCCGATGCCCGGGGCTGC"| __truncated__ "AGGGGACGCAGCGAAACCGGGGCCCGCGCCAGGCCAGCCGGGACGGACGCCGATGCCCGGGGCTGCGACGGCTGCAGAGCGAGCTGCCCTCGGAGGCCGGCGTGGGGAAGA"| __truncated__ "AGGGGACGCAGCGAAACCGGGGCCCGCGCCAGGCCAGCCGGGACGGACGCCGATGCCCGGGGCTGCGACGGCTGCAGAGCGAGCTGCCCTCGGAGGCCGGCGTGGGGAAGA"| __truncated__ ...
##  $ xrefs             :List of 14
##  $ tfbs              :List of 14
##  $ exons             :List of 14
##  $ annotationFlags   :List of 14

2.2.2 getRegion

# making a query through cbRegion to get all the clinically relevant variants 
# in a specific region
library(cellbaseR)
cb <- CellBaseR()
res <- getRegion(object=cb,ids="17:1000000-1005000",
resource="clinical")
# to get all conservation data in this region
res <- getRegion(object=cb,ids="17:1000000-1005000",
resource="conservation")
#likewise to get all the regulatory data for the same region
res <- getRegion(object=cb,ids="17:1000000-1005000", resource="regulatory")
str(res,1)
## 'data.frame':    60 obs. of  12 variables:
##  $ chromosome  : chr  "17" "17" "17" "17" ...
##  $ source      : chr  "ccat_histone" "SWEmbl_R0005_IDR" "SWEmbl_R0005_IDR" "SWEmbl_R0005_IDR" ...
##  $ featureType : chr  "H3K27_trimethylation_site" "H3K27_acylation_site" "H3K4_monomethylation_site" "H3K9_acetylation_site" ...
##  $ start       : int  993140 997759 997760 998344 998400 999107 999880 997760 998344 998400 ...
##  $ end         : int  1004420 1000704 1002709 1000418 1000080 1000583 1000680 1002709 1000418 1000080 ...
##  $ score       : chr  "." "." "." "." ...
##  $ strand      : chr  "." "." "." "." ...
##  $ frame       : chr  "." "." "." "." ...
##  $ name        : chr  "H3K27me3" "H3K27ac" "H3K4me1" "H3K9ac" ...
##  $ featureClass: chr  "Histone" "Histone" "Histone" "Histone" ...
##  $ alias       : chr  "K562_H3K27me3_ENCODE_YALE_ccat_histone" "Monocytes-CD14+_H3K27ac_ENCODE_Broad_SWEmbl_R0005_IDR" "Monocytes-CD14+_H3K4me1_ENCODE_Broad_SWEmbl_R0005_IDR" "Monocytes-CD14+_H3K9ac_ENCODE_Broad_SWEmbl_R0005_IDR" ...
##  $ cellTypes   :List of 60

2.2.3 getVariant

Getting annotation for a specific variant

library(cellbaseR)
cb <- CellBaseR()
res2 <- getVariant(object=cb, ids="1:169549811:A:G", resource="annotation")
# to get the data 
res2 <- cbData(res2)
str(res2, 1)

A very powerfull feature of cellbaseR is ability to fetch a wealth of clinical data, as well as abiliy to fiter these data by gene, phenotype, rs, etc…

2.2.4 getClinical

library(cellbaseR)
cb <- CellBaseR()
# First we have to specify aour param, we do that by creating an object of
# class CellbaseParam
cbparam <- CellBaseParam(gene="TET1", genome="GRCh38")
cbparam
## |An object of class CellBaseParam
## |use this object to control what results are returned from the CellBaseR
##       methods
# Note that cbClinical does NOT require any Ids to be passed, only the param
# and of course the CellbaseQuery object
res <- getClinical(object=cb,param=cbparam)
str(res,1)
## 'data.frame':    18 obs. of  37 variables:
##  $ chromosome                  : chr  "10" "10" "10" "10" ...
##  $ start                       : int  70446203 70446407 70406107 70333081 70450816 70450697 70451227 70426853 70406413 70446178 ...
##  $ end                         : int  70446203 70446407 70406107 70333081 70450816 70450697 70451227 70426853 70406413 70446178 ...
##  $ reference                   : chr  "G" "C" "T" "T" ...
##  $ alternate                   : chr  "A" "A" "G" "G" ...
##  $ source                      : chr  "cosmic" "cosmic" "cosmic" "cosmic" ...
##  $ geneName                    : chr  "TET1" "TET1" "TET1" "TET1" ...
##  $ mutationGRCh37Strand        : chr  "+" "+" "+" "+" ...
##  $ primarySite                 : chr  "lung" "upper_aerodigestive_tract" "ovary" "prostate" ...
##  $ mutationZygosity            : chr  "" "" "het" "" ...
##  $ mutationAA                  : chr  "p.D1715N" "p.R1783R" "p.P1207P" "p.F329V" ...
##  $ tumourOrigin                : chr  "primary" "primary" "primary" "primary" ...
##  $ histologySubtype            : chr  "adenocarcinoma" "squamous_cell_carcinoma" "serous_carcinoma" "NS" ...
##  $ accessionNumber             : chr  "ENST00000373644" "ENST00000373644" "ENST00000373644" "ENST00000373644" ...
##  $ mutationID                  : chr  "COSM94115" "COSM122027" "COSM81804" "COSM94112" ...
##  $ mutationCDS                 : chr  "c.5143G>A" "c.5347C>A" "c.3621T>G" "c.985T>G" ...
##  $ sampleName                  : chr  "94699" "HN_62506" "TCGA-13-0884-01" "111995" ...
##  $ primaryHistology            : chr  "carcinoma" "carcinoma" "carcinoma" "carcinoma" ...
##  $ mutationGRCh37GenomePosition: chr  "10:70446203-70446203" "10:70446407-70446407" "10:70406107-70406107" "10:70333081-70333081" ...
##  $ mutationDescription         : chr  "Substitution - Missense" "Substitution - coding silent" "Substitution - coding silent" "Substitution - Missense" ...
##  $ genomeWideScreen            : chr  "n" "y" "y" "n" ...
##  $ idTumour                    : chr  "1443016" "1481994" "1398537" "1443190" ...
##  $ idSample                    : chr  "1520641" "1560544" "1474838" "1520815" ...
##  $ mutationSomaticStatus       : chr  "Confirmed somatic variant" "Variant of unknown origin" "Confirmed somatic variant" "Confirmed somatic variant" ...
##  $ siteSubtype                 : chr  "NS" "larynx" "NS" "NS" ...
##  $ geneCDSLength               : int  6411 6411 6411 6411 6411 6411 6411 6411 6411 6411 ...
##  $ hgncId                      : chr  "29484" "29484" "29484" "29484" ...
##  $ pubmedPMID                  : chr  "20668451" "21798893" "21720365" "20668451" ...
##  $ sampleSource                : chr  "NS" "surgery fresh/frozen" "NS" "NS" ...
##  $ age                         : num  NA NA 39 NA NA NA 60 69 NA 78 ...
##  $ comments                    : logi  NA NA NA NA NA NA ...
##  $ snp                         : logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
##  $ fathmmPrediction            : chr  "PATHOGENIC" "NEUTRAL" "NEUTRAL" "NEUTRAL" ...
##  $ idStudy                     : int  NA NA 331 NA NA NA 331 331 NA 331 ...
##  $ _geneIds                    :List of 18
##  $ _phenotypes                 :List of 18
##  $ clinvarSet                  :'data.frame':    18 obs. of  8 variables:

3 CellbaseR utilities

3.1 CreateGeneModel

A usefull utility for fast building of gene models, compatible with Gviz package for genomic visualization

library(cellbaseR)
cb <- CellBaseR()
test <- createGeneModel(object = cb, region = "17:1500000-1550000")
if(require("Gviz")){
  testTrack <- Gviz::GeneRegionTrack(test)
  Gviz::plotTracks(testTrack, transcriptAnnotation='symbol')
}

3.2 AnnotateVcf

This utility allows users to annoate genomic variants from small to medium-sized vcf files directly from the cellbase server, with a wealth of genomic annotations including riche clinical annotations like clinvar, gwas, and cosmic data, as well as conservation and functional scores like phast and cadd scores , without the need to download any files.

library(cellbaseR)
library(VariantAnnotation)
cb <- CellBaseR()
fl <- system.file("extdata", "hapmap_exome_chr22_500.vcf.gz",package = "cellbaseR" )
res <- AnnotateVcf(object=cb, file=fl, BPPARAM = bpparam(workers=2))
vcf <- readVcf(fl, "hg19")
samples(header(vcf))
##  [1] "NA07034@1099927558" "NA07048@1099927687" "NA07055@1099927615"
##  [4] "NA10846@1099927836" "NA10847@1099927741" "NA12146@1099927743"
##  [7] "NA12239@1099927424" "NA12877@1099925716" "NA12878@1099927697"
## [10] "NA12891@1099927856" "NA12892@1099927810" "NA18503@1099927775"
## [13] "NA18504@0178873056" "NA18505@1099927412" "NA18506@1099927650"
## [16] "NA18524@1099927756" "NA18532@1099927601" "NA18912@1099927835"
## [19] "NA18913@1099927630" "NA18914@0178874379" "NA18940@1099927867"
## [22] "NA18947@0178875080"
length(rowRanges(vcf))==nrow(res)
## [1] TRUE
str(res,1)
## 'data.frame':    335 obs. of  14 variables:
##  $ chromosome             : chr  "22" "22" "22" "22" ...
##  $ start                  : int  16157603 17060707 17072347 17177682 17265124 17326914 17446991 17469049 17602839 17603503 ...
##  $ reference              : chr  "G" "G" "C" "C" ...
##  $ alternate              : chr  "C" "A" "T" "A" ...
##  $ id                     : chr  "rs370790235" "rs117836313" "rs139948519" "rs3020747" ...
##  $ displayConsequenceType : chr  "intron_variant" "2KB_downstream_gene_variant" "stop_gained" "non_coding_transcript_exon_variant" ...
##  $ consequenceTypes       :List of 335
##  $ populationFrequencies  :List of 335
##  $ conservation           :List of 335
##  $ geneExpression         :List of 335
##  $ geneTraitAssociation   :List of 335
##  $ geneDrugInteraction    :List of 335
##  $ functionalScore        :List of 335
##  $ variantTraitAssociation:'data.frame': 335 obs. of  3 variables: