Overview

The human leukocyte antigen (HLA) system, located in the major histocompatibility complex (MHC) on chromosome 6p21.3, is highly polymorphic. This region has been shown to be important in human disease, adverse drug reactions and organ transplantation (Shiina et al. 2009). HLA genes play a role in the immune system and autoimmunity as they are central to the presentation of antigens for recognition by T cells. Since they have to provide defense against a great diversity of environmental microbes, HLA genes must be able to present a wide range of peptides. Evolutionary pressure at these loci have given rise to a great deal of functional diversity. For example, the HLA–B locus has 1,898 four-digit alleles listed in the April 2012 release of the IMGT-HLA Database (Robinson et al. 2013) (http://www.ebi.ac.uk/imgt/hla/).

Classical HLA genotyping methodologies have been predominantly developed for tissue typing purposes, with sequence based typing (SBT) approaches currently considered the gold standard. While there is widespread availability of vendors offering HLA genotyping services, the complexities involved in performing this to the standard required for diagnostic purposes make using a SBT approach time-consuming and cost-prohibitive for most research studies wishing to look in detail at the involvement of classical HLA genes in disease.

Here we introduce a new prediction method for HLA Imputation using attribute BAGging, HIBAG, that is highly accurate, computationally tractable, and can be used with published parameter estimates, eliminating the need to access large training samples (Zheng et al. 2014). It relies on a training set with known HLA and SNP genotypes, and combines the concepts of attribute bagging with haplotype inference from unphased SNPs and HLA types. Attribute bagging is a technique for improving the accuracy and stability of classifier ensembles using bootstrap aggregating and random variable selection (Breiman 1996, 2001; Bryll, Gutierrez-Osuna, and Quek 2003). In this case, individual classifiers are created which utilize a subset of SNPs to predict HLA types and haplotype frequencies estimated from a training data set of SNPs and HLA types. Each of the classifiers employs a variable selection algorithm with a random component to select a subset of the SNPs. HLA type predictions are determined by maximizing the average posterior probabilities from all classifiers.

Features

Examples

## HIBAG (HLA Genotype Imputation with Attribute Bagging)
## Kernel Version: v1.5 (64-bit, AVX512BW)

Pre-fit HIBAG Models for HLA Imputation

## Gene: HLA-A
## Training dataset: 60 samples X 266 SNPs
##     # of HLA alleles: 14
##     # of individual classifiers: 100
##     total # of SNPs used: 245
##     avg. # of SNPs in an individual classifier: 15.92
##         (sd: 2.43, min: 10, max: 24, median: 16.00)
##     avg. # of haplotypes in an individual classifier: 39.89
##         (sd: 14.28, min: 18, max: 87, median: 37.00)
##     avg. out-of-bag accuracy: 93.77%
##         (sd: 4.56%, min: 78.95%, max: 100.00%, median: 94.74%)
## Genome assembly: hg19

## [1] "rs2523442" "rs9257863" "rs2107191" "rs4713226" "rs2746150" "rs1233492"
## [1] 29417816 29425583 29434294 29434413 29442700 29458476

Build a HIBAG Model for HLA Genotype Imputation

## Gene: HLA-A
## Training dataset: 60 samples X 266 SNPs
##     # of HLA alleles: 14
##     # of individual classifiers: 100
##     total # of SNPs used: 245
##     avg. # of SNPs in an individual classifier: 15.92
##         (sd: 2.43, min: 10, max: 24, median: 16.00)
##     avg. # of haplotypes in an individual classifier: 39.89
##         (sd: 14.28, min: 18, max: 87, median: 37.00)
##     avg. out-of-bag accuracy: 93.77%
##         (sd: 4.56%, min: 78.95%, max: 100.00%, median: 94.74%)
## Genome assembly: hg19

Evaluate Overall Accuracy, Sensitivity, Specificity, etc

The function hlaReport() can be used to automatically generate a tex or HTML report when a validation dataset is available.

## [1] "training"   "validation"
## Gene: HLA-A
## Range: [29910247bp, 29913661bp] on hg19
## # of samples: 34
## # of unique HLA alleles: 14
## # of unique HLA genotypes: 23
## Gene: HLA-A
## Range: [29910247bp, 29913661bp] on hg19
## # of samples: 26
## # of unique HLA alleles: 12
## # of unique HLA genotypes: 14
## [1] 275
## SNP genotypes: 
##     34 samples X 275 SNPs
##     SNPs range from 29417816bp to 30410205bp on hg19
## Missing rate per SNP:
##     min: 0, max: 0.0882353, mean: 0.0863102, median: 0.0882353, sd: 0.0124152
## Missing rate per sample:
##     min: 0, max: 0.974545, mean: 0.0863102, median: 0, sd: 0.280474
## Minor allele frequency:
##     min: 0, max: 0.5, mean: 0.218176, median: 0.193548, sd: 0.136552
## Allelic information:
## C/T A/G G/T A/C 
## 125  97  32  21
## Gene: HLA-A
## Training dataset: 34 samples X 266 SNPs
##     # of HLA alleles: 14
##     # of individual classifiers: 100
##     total # of SNPs used: 244
##     avg. # of SNPs in an individual classifier: 14.60
##         (sd: 2.76, min: 10, max: 21, median: 14.00)
##     avg. # of haplotypes in an individual classifier: 39.68
##         (sd: 16.31, min: 15, max: 84, median: 37.50)
##     avg. out-of-bag accuracy: 83.80%
##         (sd: 8.69%, min: 62.50%, max: 100.00%, median: 84.62%)
## Matching proportion:
##         Min.     0.1% Qu.       1% Qu.      1st Qu.       Median      3rd Qu.         Max.         Mean 
## 0.0009366995 0.0009474879 0.0010445837 0.0054325672 0.0100158851 0.0158869387 0.4092814785 0.0388578948 
##           SD 
## 0.0926409732 
## Genome assembly: hg19
## HIBAG model for HLA-A:
##     100 individual classifiers
##     266 SNPs
##     14 unique HLA alleles: 01:01, 02:01, 02:06, ...
## Prediction:
##     based on the averaged posterior probabilities
## Model assembly: hg19, SNP assembly: hg19
## Matching the SNPs between the model and the test data:
##     match.type="--"   missing SNPs #                
##            Position         0 (0.0%) *being used [1]
##          Pos+Allele         0 (0.0%)             [2]
##     RefSNP+Position         0 (0.0%)                
##              RefSNP         0 (0.0%)                
##       [1]: useful if ambiguous strands on array-based platforms
##       [2]: suggested if the model and test data have been matched to the same reference genome
##     Model platform: not applicable
## No allelic strand or A/B allele is flipped.
## # of samples: 26
## CPU flags: 64-bit, AVX512BW
## # of threads: 1
## Predicting (2022-01-18 04:34:42) 0%
## Predicting (2022-01-18 04:34:42) 100%
## Gene: HLA-A
## Range: [29910247bp, 29913661bp] on hg19
## # of samples: 26
## # of unique HLA alleles: 12
## # of unique HLA genotypes: 14
## Posterior probability:
##   [0,0.25) [0.25,0.5) [0.5,0.75)   [0.75,1] 
##   2 (7.7%)   2 (7.7%)   2 (7.7%) 20 (76.9%) 
## Matching proportion of SNP haplotype:
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## 0.0004095 0.0053788 0.0085626 0.0287638 0.0271491 0.4000244 
## Dosages:
## $dosage - num [1:14, 1:26] 1.78e-02 1.30e-02 5.25e-02 9.42e-01 6.24e-07 ...
##  - attr(*, "dimnames")=List of 2
##   ..$ : chr [1:14] "01:01" "02:01" "02:06" "03:01" ...
##   ..$ : chr [1:26] "NA11881" "NA11992" "NA11994" "NA12249" ...
##   total.num.ind crt.num.ind crt.num.haplo   acc.ind acc.haplo call.threshold n.call call.rate
## 1            26          24            50 0.9230769 0.9615385              0     26         1

Evaluation in Figures

The distance matrix is calculated based on the haplotype similarity carrying HLA alleles:

Matching proportion is a measure or proportion describing how the SNP profile matches the SNP haplotypes observed in the training set, i.e., the likelihood of SNP profile in a random-mating population consisting of training haplotypes. It is not directly related to confidence score, but a very low value of matching indicates that it is underrepresented in the training set.

Report in Text

Output to plain text format:

## Allele   Num.    Freq.   Num.    Freq.   CR  ACC SEN SPE PPV NPV Miscall
##  Train   Train   Valid.  Valid.  (%) (%) (%) (%) (%) (%) (%)
## ----
## Overall accuracy: 96.2%, Call rate: 100.0%
## 01:01 14 0.2059 12 0.2308 100.0 98.1 100.0 97.5 92.3 100.0 --
## 02:01 23 0.3382 22 0.4231 100.0 98.1 95.5 100.0 100.0 96.8 29:02 (100)
## 02:06 1 0.0147 0 0 -- -- -- -- -- -- --
## 03:01 4 0.0588 5 0.0962 100.0 100.0 100.0 100.0 100.0 100.0 --
## 11:01 3 0.0441 2 0.0385 100.0 100.0 100.0 100.0 100.0 100.0 --
## 23:01 2 0.0294 2 0.0385 100.0 100.0 100.0 100.0 100.0 100.0 --
## 24:02 6 0.0882 3 0.0577 100.0 98.1 66.7 100.0 100.0 98.0 01:01 (100)
## 24:03 1 0.0147 0 0 -- -- -- -- -- -- --
## 25:01 3 0.0441 1 0.0192 100.0 100.0 100.0 100.0 100.0 100.0 --
## 26:01 2 0.0294 1 0.0192 100.0 100.0 100.0 100.0 100.0 100.0 --
## 29:02 3 0.0441 1 0.0192 100.0 98.1 100.0 98.0 50.0 100.0 --
## 31:01 2 0.0294 1 0.0192 100.0 100.0 100.0 100.0 100.0 100.0 --
## 32:01 2 0.0294 1 0.0192 100.0 100.0 100.0 100.0 100.0 100.0 --
## 68:01 2 0.0294 1 0.0192 100.0 100.0 100.0 100.0 100.0 100.0 --

Report in Markdown

Output to a markdown file:

Overall accuracy: 96.2%, Call rate: 100.0%

Allele # Train Freq. Train # Valid. Freq. Valid. CR (%) ACC (%) SEN (%) SPE (%) PPV (%) NPV (%) Miscall (%)
01:01 14 0.2059 12 0.2308 100.0 98.1 100.0 97.5 92.3 100.0
02:01 23 0.3382 22 0.4231 100.0 98.1 95.5 100.0 100.0 96.8 29:02 (100)
02:06 1 0.0147 0 0
03:01 4 0.0588 5 0.0962 100.0 100.0 100.0 100.0 100.0 100.0
11:01 3 0.0441 2 0.0385 100.0 100.0 100.0 100.0 100.0 100.0
23:01 2 0.0294 2 0.0385 100.0 100.0 100.0 100.0 100.0 100.0
24:02 6 0.0882 3 0.0577 100.0 98.1 66.7 100.0 100.0 98.0 01:01 (100)
24:03 1 0.0147 0 0
25:01 3 0.0441 1 0.0192 100.0 100.0 100.0 100.0 100.0 100.0
26:01 2 0.0294 1 0.0192 100.0 100.0 100.0 100.0 100.0 100.0
29:02 3 0.0441 1 0.0192 100.0 98.1 100.0 98.0 50.0 100.0
31:01 2 0.0294 1 0.0192 100.0 100.0 100.0 100.0 100.0 100.0
32:01 2 0.0294 1 0.0192 100.0 100.0 100.0 100.0 100.0 100.0
68:01 2 0.0294 1 0.0192 100.0 100.0 100.0 100.0 100.0 100.0

Report in LaTeX

Output to a tex file, and please add \usepackage{longtable} to your tex file:

## % -------- BEGIN TABLE --------
## \begin{longtable}{rrrrr | rrrrrrl}
## \caption{The sensitivity (SEN), specificity (SPE), positive predictive value (PPV), negative predictive value (NPV) and call rate (CR).}
## \label{tab:accuracy} \\
## Allele & Num. & Freq. & Num. & Freq. & CR & ACC & SEN & SPE & PPV & NPV & Miscall \\
##  & Train & Train & Valid. & Valid. & (\%) & (\%) & (\%) & (\%) & (\%) & (\%) & (\%) \\
## \hline\hline
## \endfirsthead
## \multicolumn{12}{c}{{\normalsize \tablename\ \thetable{} -- Continued from previous page}} \\
## Allele & Num. & Freq. & Num. & Freq. & CR & ACC & SEN & SPE & PPV & NPV & Miscall \\
##  & Train & Train & Valid. & Valid. & (\%) & (\%) & (\%) & (\%) & (\%) & (\%) & (\%) \\
## \hline\hline
## \endhead
## \hline
## \multicolumn{12}{r}{Continued on next page ...} \\
## \hline
## \endfoot
## \hline\hline
## \endlastfoot
## \multicolumn{12}{l}{\it Overall accuracy: 96.2\%, Call rate: 100.0\%} \\
## 01:01 & 14 & 0.2059 & 12 & 0.2308 & 100.0 & 98.1 & 100.0 & 97.5 & 92.3 & 100.0 & -- \\
## 02:01 & 23 & 0.3382 & 22 & 0.4231 & 100.0 & 98.1 & 95.5 & 100.0 & 100.0 & 96.8 & 29:02 (100) \\
## 02:06 & 1 & 0.0147 & 0 & 0 & -- & -- & -- & -- & -- & -- & -- \\
## 03:01 & 4 & 0.0588 & 5 & 0.0962 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & -- \\
## 11:01 & 3 & 0.0441 & 2 & 0.0385 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & -- \\
## 23:01 & 2 & 0.0294 & 2 & 0.0385 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & -- \\
## 24:02 & 6 & 0.0882 & 3 & 0.0577 & 100.0 & 98.1 & 66.7 & 100.0 & 100.0 & 98.0 & 01:01 (100) \\
## 24:03 & 1 & 0.0147 & 0 & 0 & -- & -- & -- & -- & -- & -- & -- \\
## 25:01 & 3 & 0.0441 & 1 & 0.0192 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & -- \\
## 26:01 & 2 & 0.0294 & 1 & 0.0192 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & -- \\
## 29:02 & 3 & 0.0441 & 1 & 0.0192 & 100.0 & 98.1 & 100.0 & 98.0 & 50.0 & 100.0 & -- \\
## 31:01 & 2 & 0.0294 & 1 & 0.0192 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & -- \\
## 32:01 & 2 & 0.0294 & 1 & 0.0192 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & -- \\
## 68:01 & 2 & 0.0294 & 1 & 0.0192 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & -- \\
## \end{longtable}
## % -------- END TABLE --------

Resources

Session Info

## R version 4.1.2 (2021-11-01)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.3 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.14-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.14-bioc/R/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB             
##  [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] HIBAG_1.30.2
## 
## loaded via a namespace (and not attached):
##  [1] highr_0.9          bslib_0.3.1        compiler_4.1.2     pillar_1.6.4       jquerylib_0.1.4   
##  [6] tools_4.1.2        digest_0.6.29      jsonlite_1.7.3     evaluate_0.14      lifecycle_1.0.1   
## [11] tibble_3.1.6       gtable_0.3.0       pkgconfig_2.0.3    rlang_0.4.12       DBI_1.1.2         
## [16] yaml_2.2.1         xfun_0.29          fastmap_1.1.0      withr_2.4.3        stringr_1.4.0     
## [21] dplyr_1.0.7        knitr_1.37         generics_0.1.1     sass_0.4.0         vctrs_0.3.8       
## [26] grid_4.1.2         tidyselect_1.1.1   glue_1.6.0         R6_2.5.1           fansi_1.0.2       
## [31] rmarkdown_2.11     farver_2.1.0       purrr_0.3.4        ggplot2_3.3.5      magrittr_2.0.1    
## [36] scales_1.1.1       htmltools_0.5.2    ellipsis_0.3.2     assertthat_0.2.1   colorspace_2.0-2  
## [41] labeling_0.4.2     utf8_1.2.2         stringi_1.7.6      RcppParallel_5.1.5 munsell_0.5.0     
## [46] crayon_1.4.2

References

Breiman, Leo. 1996. “Bagging Predictors.” Mach. Learn. 24 (2): 123–40. https://doi.org/10.1023/A:1018054314350.

———. 2001. “Random Forests.” Mach. Learn. 45 (1): 5–32. https://doi.org/10.1023/A:1010933404324.

Bryll, Robert, Ricardo Gutierrez-Osuna, and Francis Quek. 2003. “Attribute Bagging: Improving Accuracy of Classifier Ensembles by Using Random Feature Subsets.” Pattern Recognition 36 (6): 1291–1302. https://doi.org/10.1016/S0031-3203(02)00121-8.

Robinson, James, Jason A. Halliwell, Hamish McWilliam, Rodrigo Lopez, Peter Parham, and Steven G.E. Marsh. 2013. “The IMGT/HLA Database.” Nucleic Acids Res 41 (Database issue): 1222–7. https://doi.org/10.1093/nar/gks949.

Shiina, Takashi, Kazuyoshi Hosomichi, Hidetoshi Inoko, and Jerzy Kulski. 2009. “The HLA Genomic Loci Map: Expression, Interaction, Diversity and Disease.” Journal of Human Genetics 54 (1): 15–39. https://doi.org/10.1038/jhg.2008.5.

Zheng, Xiuwen, Judong Shen, Charles Cox, Jonathan C. Wakefield, Margaret G. Ehm, Matthew R. Nelson, and Bruce S. Weir. 2014. “HIBAG – HLA Genotype Imputation with Attribute Bagging.” Pharmacogenomics J. https://doi.org/10.1038/tpj.2013.18.