Package: ABAEnrichment
Author: Steffi Grote
Date: August 26, 2015
ABAEnrichment is an R package for the enrichment analysis of user defined candidate genes (in the set of expressed protein coding genes) in different human brain regions. The package integrates the expression of the candidate gene set (averaged across donors) and the structural information of the brain using an ontology, both provided by the Allen Brain Atlas project [1-4]. The statistical analysis is performed by the core function aba_enrich
which interfaces the ontology enrichment software FUNC [5]. Additional functions provided in this package are get_expression
, plot_expression
, get_name
, get_sampled_substructures
and get_superstructures
supporting the exploration and visualization of the expression data.
The enrichment analysis for candidate genes is performed by using either the hypergeometric or the Wilcoxon rank test implemented in the ontology enrichment software FUNC [5]. The hypergeometric test evaluates the enrichment of expressed candidate genes compared to a set of background genes for each brain region. The background genes can be defined explicitly like the candidate genes or, by default, consist of all expressed genes from the dataset outside the candidate genes. Using the Wilcoxon rank test, scores assigned to candidate genes are tested for an enrichment in brain regions. The boundary between 'expressed' and 'not expressed' is defined by different expression quantiles (e.g. the lowest 40% of gene expression are 'not expressed' and the upper 60% are 'expressed' for a quantile of 0.4). These cutoffs are set with the parameter cutoff_quantiles
and an analysis is run for every cutoff separately.
The package incorporates three different brain expression datasets: first, microarray data from adult individuals, second, RNA-seq data from individuals of five different developmental stages (prenatal, infant, child, adolescent, adult) and third, a developmental effect score measuring the age effect on expression for given genes. In the latter case the data are not divided into 'expressed' and 'not expressed', but into 'developmental effect score above cutoff' or not. However, for simplicity we only refer to 'expression' in that documentation. For details on the datasets see the ABAData vignette.
Overview of the functions included in ABAEnrichment:
function | description |
---|---|
aba_enrich |
core function for performing enrichment analyses given a candidate gene set. |
get_expression |
returns expression data or developmental effect scores for a given set of genes and brain structures. |
plot_expression |
plots a heatmap with expression data or developmental effect scores for a given set of genes and brain structures. |
get_name |
returns the full name of a brain region given a structure id. |
get_sampled_substructures |
returns the substructures of a given brain region that have expression data available. |
get_superstructures |
returns the superstructures of a given brain region. |
For a random set of 13 genes a test for expression enrichment in human brain regions for different developmental stages is performed. A binary vector with '1' for a candidate gene and '0' for a background gene and names as gene identifiers (Entrez-ID, Ensembl-ID or HGNC-symbol) needs to be defined. In this example no background genes are defined, in which case all remaining protein coding genes of the dataset are used as background.
## load ABAEnrichment package
require(ABAEnrichment)
## create input vector with candidate genes
genes=rep(1,13)
names(genes)=c('NCAPG', 'APOL4', 'NGFR', 'NXPH4', 'C21orf59', 'CACNG2', 'AGTR1', 'ANO1', 'BTBD3', 'MTUS1', 'CALB1', 'GYG1', 'PAX2')
genes
## NCAPG APOL4 NGFR NXPH4 C21orf59 CACNG2 AGTR1 ANO1 BTBD3 MTUS1 CALB1 GYG1
## 1 1 1 1 1 1 1 1 1 1 1 1
## PAX2
## 1
In order to test the 13 random genes for enrichment in brain regions at different developmental stages using aba_enrich
the following parameters have to be defined: the vector 'genes' and the dataset '5_stages'. Additionally, in this example two optional parameters are set: the cutoff_quantiles
0.5, 0.7 and 0.9 for an example of using the 50%, 70% and 90% expression quantile across all genes as the boundary between 'expressed' and 'not expressed' genes and n_randsets
100 to use 100 random permutations to calculate the FWER. cutoff_quantiles
and n_randsets
have default values seq(0.1,0.9,0.1) and '1000' respectively.
## run enrichment analysis
res=aba_enrich(genes,dataset='5_stages',cutoff_quantiles=c(0.5,0.7,0.9),n_randsets=100)
The function aba_enrich
returns a list, the first element of which contains the results of the statistical analysis for each brain region and age category, since for the '5_stages' dataset the analyses are performed independently for each developmental stage:
## extract first element from the output list, which contains the statistics
fwers=res[[1]]
## see results for the brain regions with highest enrichment for children (3-11 yrs, age_category 3)
head(fwers[fwers[,1]==3,])
## age_category structure_id structure times_FWER_under_0.05 mean_FWER
## 55 3 Allen:10657 CBC_cerebellar cortex 0 0.5266667
## 56 3 Allen:10361 AMY_amygdaloid complex 0 0.9500000
## 57 3 Allen:10163 M1C_primary motor cortex (area M1, area 4) 0 0.9566667
## 58 3 Allen:10225 IPC_posteroventral (inferior) parietal cortex 0 0.9733333
## 59 3 Allen:10173 DFC_dorsolateral prefrontal cortex 0 0.9833333
## 60 3 Allen:10161 FCx_frontal neocortex 0 0.9866667
## min_FWER equivalent_structures FWERs
## 55 0.39 Allen:10657;Allen:10656;Allen:10655;Allen:10654;Allen:10653 0.66;0.53;0.39
## 56 0.85 Allen:10361 0.85;1;1
## 57 0.87 Allen:10163;Allen:10162 0.87;1;1
## 58 0.92 Allen:10225;Allen:10214 0.92;1;1
## 59 0.96 Allen:10173 0.96;1;0.99
## 60 0.96 Allen:10161 0.96;1;1
The rows in the output data frame are ordered by age_category
, times_FWER_under_0.05
, mean_FWER
and min_FWER
; with min_FWER
for example denoting the minimum FWER for expression enrichment of the candidate genes in this brain region across all expression cutoffs. The column FWERs
lists the individual FWERs for each cutoff. The column equivalent_structures
lists structures with identical expression data due to lack of independent expression measurements in all regions. Nodes (brain regions) in the ontology inherit data from their children (substructures), and in the case of only one child node with expression data, the parent node inherits the childs' data leading to identical enrichment statistics .
In addition to the statistics, the list that is returned from aba_enrich
also contains the input genes for which expression data is available and for each age category the gene expression values that correspond to the requested cutoff_quantiles
:
res[2:3]
## $genes
## NCAPG NGFR NXPH4 C21orf59 CACNG2 AGTR1 ANO1 BTBD3 MTUS1 CALB1 GYG1 PAX2
## 1 1 1 1 1 1 1 1 1 1 1 1
##
## $cutoffs
## age_category_1 age_category_2 age_category_3 age_category_4 age_category_5
## 50% 3.144621 2.85566 2.716809 2.777382 2.863357
## 70% 7.822559 7.01810 6.898696 6.842410 7.118916
## 90% 23.747267 22.47468 23.112102 21.625535 22.687928
The function get_expression
enables the output of gene and brain region specific expression data averaged across donors. By only setting the parameter structure_ids
defining the brain regions, the gene_ids
and dataset
are automatically set to the genes and dataset used in the last enrichment analysis. By setting the parameter background
to TRUE
, the gene expression data for both candidate genes and background genes is returned. For the '5_stages' dataset
the output of get_expression
is a list with a data.frame for each developmental stages, where the first element corresponds to the first stage and so on:
## get expression data (list) for the first 5 brain structures of the enrichment analysis output
expr=get_expression(fwers[1:5,"structure_id"],background=FALSE)
## look at the structure of the expression data
str(expr)
## List of 5
## $ age_category_1: num [1:5, 1:12] 1.5396 0.1506 0.205 0.0747 0.1323 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:5] "Allen:10657" "Allen:10163" "Allen:10269" "Allen:10278" ...
## .. ..$ : chr [1:12] "AGTR1" "ANO1" "BTBD3" "C21orf59" ...
## $ age_category_2: num [1:5, 1:12] 1.6434 0.0747 0.0305 0.0419 0.128 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:5] "Allen:10657" "Allen:10163" "Allen:10269" "Allen:10278" ...
## .. ..$ : chr [1:12] "AGTR1" "ANO1" "BTBD3" "C21orf59" ...
## $ age_category_3: num [1:5, 1:12] 1.3834 0.1275 0.1148 0.127 0.0851 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:5] "Allen:10657" "Allen:10163" "Allen:10269" "Allen:10278" ...
## .. ..$ : chr [1:12] "AGTR1" "ANO1" "BTBD3" "C21orf59" ...
## $ age_category_4: num [1:5, 1:12] 0.4504 0.0474 0.04 0.081 0.158 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:5] "Allen:10657" "Allen:10163" "Allen:10269" "Allen:10278" ...
## .. ..$ : chr [1:12] "AGTR1" "ANO1" "BTBD3" "C21orf59" ...
## $ age_category_5: num [1:5, 1:12] 0.3195 0.0288 0.0328 0.0243 0.2603 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:5] "Allen:10657" "Allen:10163" "Allen:10269" "Allen:10278" ...
## .. ..$ : chr [1:12] "AGTR1" "ANO1" "BTBD3" "C21orf59" ...
## see expression for children (age_category 3 -> 3rd element of expression list)
expr[[3]]
## AGTR1 ANO1 BTBD3 C21orf59 CACNG2 CALB1 GYG1 MTUS1 NCAPG
## Allen:10657 1.38336383 1.4322665 68.85743 10.276745 6.4179230 50.238135 23.35848 16.951106 0.5957943
## Allen:10163 0.12754925 0.4160865 23.07490 6.280150 0.9809065 5.042797 15.64878 7.277518 0.5123323
## Allen:10269 0.11476440 0.4025528 32.57702 6.294153 1.8724818 5.203308 11.31269 7.120675 0.4350924
## Allen:10278 0.12702200 0.3619545 27.52404 5.664331 1.0411885 8.969495 11.46349 4.977216 0.6567363
## Allen:10294 0.08507825 0.2714797 63.65507 7.602091 0.6432233 5.287736 16.35872 9.468135 0.6273795
## NGFR NXPH4 PAX2
## Allen:10657 2.1897517 11.935791 1.1334583
## Allen:10163 0.3845145 2.762445 0.0134415
## Allen:10269 0.3884268 2.351445 0.0300370
## Allen:10278 0.2559675 1.937003 0.0251400
## Allen:10294 0.4751978 1.034173 0.0275535
The function plot_expression
enables the visualization of expression data. The input parameters of plot_expression
are identical to those of get_expression
except for the additional arguments dendro
and age_category
which determine whether or not a dendrogram should be added to the heatplot and the developmental stage to be plotted, respectively.
## plot expression in 5 structures with dendrogram for the prenatal stage (age_category 1)
plot_expression(fwers[1:5,"structure_id"],age_category=1)
The colored side bar in the plot without dendrogram colors candidate genes (red) and background genes (black) independently. In this case only candidate gene expression was plotted (with the default option background=FALSE
):
## plot expression for the 10 highest scoring brain structures in age category 3 (children, 3-11 yrs) without dendrogram
plot_expression(fwers[fwers$age_category==3,'structure_id'][1:10],dendro=FALSE,age_category=3)
Both get_expression
and plot_expression
can also be used independently from a previous statistical analysis with aba_enrich
. In this case the gene_ids
and the dataset
must be specified. gene_ids
again can be Entrez-ID, Ensembl-ID or HGNC-symbol. For example: obtaining and visualizing the expression of a specific set of genes in the precentral gyrus, which corresponds to the structure id 'Allen:4010', is accomplished by:
## get expression data for six genes in the brain structure 'Allen:4010'
get_expression(structure_ids=c('Allen:4010'),gene_ids=c(324,8312,673,1029,64764,1499),dataset='adult')
## 324 8312 673 1029 64764 1499
## Allen:4012 7.014323 4.967949 7.350482 6.597084 6.603828 8.722930
## Allen:4013 7.045578 5.003370 7.298783 6.527379 6.691717 8.584229
## Allen:4014 6.900812 4.874076 7.302336 6.517605 6.368069 8.348260
## Allen:4015 7.016911 4.918875 7.443680 6.726566 6.964441 8.463246
## Allen:4017 6.881426 5.075758 7.234570 6.228161 6.573122 8.397123
## Allen:4018 6.999388 5.113792 7.508438 6.303073 6.692209 8.374960
## Allen:4019 6.929731 4.954951 7.141389 6.392160 6.690830 8.408290
## Allen:4020 6.949528 5.088940 7.308328 6.216858 6.514342 8.446041
## plot this expression
plot_expression(structure_ids=c('Allen:4010'),gene_ids=c(324,8312,673,1029,64764,1499),dataset='adult')
In this example the structure 'Allen:4010' does not directly have independet expression data available in the data set, but some of its substructures do have. Plotting or requesting expression data for 'Allen:4010' automatically obtains the data for all its substructures. The function get_sampled_substructures
returns all the substructures for which expression data is available. The function get_name
is useful to see the name of a brain region that corresponds to a structure id:
## get ids of the substructres of 'Allen:4010' that have expression data annotated
subs=get_sampled_substructures('Allen:4010')
## get the full name of those substructures
get_name(subs)
## Allen:4012
## "PrG-prc_precentral gyrus, Left, bank of the precentral sulcus"
## Allen:4013
## "PrG-sl_precentral gyrus, Left, superior lateral aspect of gyrus"
## Allen:4014
## "PrG-il_precentral gyrus, Left, inferior lateral aspect of gyrus"
## Allen:4015
## "PrG-cs_precentral gyrus, Left, bank of the central sulcus"
## Allen:4017
## "PrG-prc_precentral gyrus, Right, bank of the precentral sulcus"
## Allen:4018
## "PrG-sl_precentral gyrus, Right, superior lateral aspect of gyrus"
## Allen:4019
## "PrG-il_precentral gyrus, Right, inferior lateral aspect of gyrus"
## Allen:4020
## "PrG-cs_precentral gyrus, Right, bank of the central sulcus"
Besides the function get_sampled_substructures
the package also contains a function get_superstructures
which returns all superstructures of the requested structure and the structure itself. The output is ordered according to the hierarchy of brain structures beginning with the top structure:
## get ids of the superstructures of 'Allen:4010'
supers=get_superstructures('Allen:4010')
## get the full name of those superstructures
get_name(supers)
## Allen:4005 Allen:4006 Allen:4007 Allen:4008
## "Br_Brain" "GM_Grey Matter" "Tel_Telencephalon" "Cx_Cerebral Cortex"
## Allen:4009 Allen:4010
## "FL_Frontal Lobe" "PrG_precentral gyrus"
The Wilcoxon rank test requires a score for given sets of genes. It then evaluates the ranks of the genes (based on their score) that are expressed in a given brain structure compared to all the candidate genes that are expressed anywhere in the brain. Again, the genes
vector defines the scores, ranking the genes on specific features, while the names of the vector are the corresponding gene identifiers:
## create input vector with random scores associated with the candidate genes
genes=sample(1:50,12)
names(genes)=c('ENSG00000168036', 'ENSG00000157764', 'ENSG00000163041', 'ENSG00000182158', 'ENSG00000147889', 'ENSG00000103126', 'ENSG00000182054', 'ENSG00000184634', 'ENSG00000134982', 'ENSG00000138413', 'ENSG00000133703', 'ENSG00000132475')
genes
## ENSG00000168036 ENSG00000157764 ENSG00000163041 ENSG00000182158 ENSG00000147889 ENSG00000103126
## 28 21 46 37 24 20
## ENSG00000182054 ENSG00000184634 ENSG00000134982 ENSG00000138413 ENSG00000133703 ENSG00000132475
## 35 44 8 48 49 15
## run enrichment analysis
res=aba_enrich(genes,dataset='adult',test='wilcoxon',cutoff_quantiles=c(0.2,0.5,0.8),n_randsets=100)
## see the 5 brain regions with the lowest FWERs
res[[1]][1:5,]
## age_category structure_id structure times_FWER_under_0.05 mean_FWER min_FWER
## 1 5 Allen:9222 cc_corpus callosum 0 0.6666667 0.15
## 2 5 Allen:4775 He-VIIIA_VIIIA, Right Lateral Hemisphere 0 0.6666667 0.15
## 3 5 Allen:9241 cgb_cingulum bundle, Left 0 0.6766667 0.17
## 4 5 Allen:4675 LM_Lateral Mammillary Nucleus, Left 0 0.6766667 0.58
## 5 5 Allen:4671 MB_Mammillary Body, Left 0 0.6800000 0.54
## equivalent_structures FWERs
## 1 Allen:9222;Allen:9220 0.15;0.99;0.86
## 2 Allen:4775 0.15;0.99;0.86
## 3 Allen:9241 0.17;1;0.86
## 4 Allen:4675 0.59;0.58;0.86
## 5 Allen:4671 0.64;0.54;0.86
Plotting the expression for the output brain regions with the option dendro=FALSE
results in a side bar with genes and its scores that were used for the initial enrichment test:
## plot expression of the 5 brain strcutures with the lowest FWERs, with genes ordered by user defined score from Wilcoxon rank test
plot_expression(res[[1]][1:5,"structure_id"],dendro=FALSE)
In the previous examples genes got annotated to brain regions based on their expression. Besides the two gene expression datasets 'adult' and '5_stages', the dataset 'dev_effect' can be used, which provides scores for an age effect for genes based on their expression change during development. Using this dataset the same analyses as above are performed, except that a gene is annotated to a brain region when its developmental effect score in that region is a above the cutoff_quantiles
.
To test the same genes and scores as used above for enrichment of high scoring genes in the set of all genes with a developmental effect score above cutoff, the dataset
parameter has to be set to 'dev_effect':
## run enrichment analysis with developmental effect score
res=aba_enrich(genes,dataset='dev_effect',test='wilcoxon',cutoff_quantiles=c(0.2,0.5,0.8),n_randsets=100)
The output of the developmental effect enrichment analysis is equal to that of the expression enrichment analysis:
## see the 5 brain regions with the lowest FWERs
res[[1]][1:5,]
## age_category structure_id structure times_FWER_under_0.05 mean_FWER
## 1 0 Allen:10657 CBC_cerebellar cortex 0 0.5200000
## 2 0 Allen:10163 M1C_primary motor cortex (area M1, area 4) 0 0.5800000
## 3 0 Allen:10333 STR_striatum 0 0.5833333
## 4 0 Allen:10225 IPC_posteroventral (inferior) parietal cortex 0 0.5900000
## 5 0 Allen:10236 A1C_primary auditory cortex (core) 0 0.5900000
## min_FWER equivalent_structures FWERs
## 1 0.31 Allen:10657;Allen:10656;Allen:10655;Allen:10654;Allen:10653 0.74;0.31;0.51
## 2 0.30 Allen:10163;Allen:10162 0.93;0.3;0.51
## 3 0.15 Allen:10333;Allen:10332 0.98;0.62;0.15
## 4 0.15 Allen:10225;Allen:10214 0.89;0.73;0.15
## 5 0.15 Allen:10236 0.89;0.73;0.15
Again, the developmental effect scores can be retrieved with the functions get_expression
and plotted with plot_expression
:
## plot developmental effect score of the 5 brain strcutures with the lowest FWERs
plot_expression(res[[1]][1:5,"structure_id"])
sessionInfo()
## R version 3.3.0 (2016-05-03)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 14.04.4 LTS
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
## [4] LC_COLLATE=C LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
## [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] ABAEnrichment_1.2.2 BiocStyle_2.0.2
##
## loaded via a namespace (and not attached):
## [1] magrittr_1.5 gplots_3.0.1 formatR_1.4 tools_3.3.0 ABAData_1.2.0
## [6] Rcpp_0.12.5 KernSmooth_2.23-15 stringi_1.0-1 gdata_2.17.0 knitr_1.13
## [11] caTools_1.17.1 stringr_1.0.0 bitops_1.0-6 gtools_3.5.0 evaluate_0.9
[1] Hawrylycz, M.J. et al. (2012) An anatomically comprehensive atlas of the adult human brain transcriptome, Nature 489: 391-399. [doi:10.1038/nature11405]
[2] Miller, J.A. et al. (2014) Transcriptional landscape of the prenatal human brain, Nature 508: 199-206. [doi:10.1038/nature13185]
[3] Allen Institute for Brain Science. Allen Human Brain Atlas (Internet). Available from: [http://human.brain-map.org/]
[4] Allen Institute for Brain Science. BrainSpan Atlas of the Developing Human Brain (Internet). Available from: [http://brainspan.org/]
[5] Pruefer, K. et al. (2007) FUNC: A package for detecting significant associations between gene sets and ontological annotations, BMC Bioinformatics 8: 41. [doi:10.1186/1471-2105-8-41]