{"id":17223372,"url":"https://github.com/slowkow/allelefrequencies","last_synced_at":"2025-04-14T00:22:23.297Z","repository":{"id":143112480,"uuid":"614108789","full_name":"slowkow/allelefrequencies","owner":"slowkow","description":"📂 HLA allele frequencies in tab-delimited format, downloaded from AFND.","archived":false,"fork":false,"pushed_at":"2024-04-23T01:02:55.000Z","size":25972,"stargazers_count":20,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-27T14:21:55.972Z","etag":null,"topics":["bioinformatics","genetics","hla","hla-database"],"latest_commit_sha":null,"homepage":"http://www.allelefrequencies.net/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slowkow.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-03-14T22:59:12.000Z","updated_at":"2025-02-13T14:39:24.000Z","dependencies_parsed_at":"2024-02-13T07:15:07.641Z","dependency_job_id":null,"html_url":"https://github.com/slowkow/allelefrequencies","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slowkow%2Fallelefrequencies","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slowkow%2Fallelefrequencies/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slowkow%2Fallelefrequencies/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slowkow%2Fallelefrequencies/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slowkow","download_url":"https://codeload.github.com/slowkow/allelefrequencies/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248800048,"owners_count":21163404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bioinformatics","genetics","hla","hla-database"],"created_at":"2024-10-15T04:08:09.662Z","updated_at":"2025-04-14T00:22:23.256Z","avatar_url":"https://github.com/slowkow.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput:\n  md_document:\n    variant: \"gfm\"\n    standalone: true\n    toc: false\n    toc_depth: 2\n  html_document:\n    toc: false\n    toc_depth: 2\n    self_contained: true\n---\n\n# HLA allele frequencies in tab-delimited format\n\n\u003ca href=\"https://zenodo.org/badge/latestdoi/614108789\"\u003e\u003cimg src=\"https://zenodo.org/badge/614108789.svg\" alt=\"DOI\"\u003e\u003c/a\u003e\n\nKamil Slowikowski\n\n`r format(Sys.Date())`\n\n```{r,include=FALSE}\noptions(width=100)\nlibrary(data.table)\nlibrary(dplyr)\nlibrary(glue)\nlibrary(readr)\nlibrary(magrittr)\nlibrary(ggplot2)\nlibrary(ggstance)\ndevtools::source_gist(\"c83e078bf8c81b035e32c3fc0cf04ee8\", filename = 'render_toc.R')\nfile_size \u003c- function(x) glue(\"{fs::file_size(x)}B\")\nd \u003c- fread(\"afnd.tsv\")\nn_hla \u003c- d %\u003e% filter(group == \"hla\") %\u003e% count(gene) %\u003e% nrow\nn_kir \u003c- d %\u003e% filter(group == \"kir\") %\u003e% count(gene) %\u003e% nrow\nn_mic \u003c- d %\u003e% filter(group == \"mic\") %\u003e% count(gene) %\u003e% nrow\nn_cyt \u003c- d %\u003e% filter(group == \"cyt\") %\u003e% count(gene) %\u003e% nrow\n```\n\n\n**Table of Contents**\n\n```{r toc, echo=FALSE} \nrender_toc(\"README.Rmd\", toc_depth = 2)\n```\n\n\n## Introduction\n\nHere, we share a single file [afnd.tsv](afnd.tsv) (`r file_size(\"afnd.tsv\")`) in tab-delimited format with all allele frequencies for `r n_hla` HLA genes, `r n_kir` KIR genes, `r n_mic` MIC genes, and `r n_cyt` cytokine genes from [Allele Frequency Net Database](http://allelefrequencies.net) (AFND).\n\nThe script [allelefrequencies.py](allelefrequencies.py) automatically downloads allele frequencies from the website.\n\n[What is the Allele Frequency Net Database?](http://www.allelefrequencies.net/faqs.asp)\n\n\u003e The Allele Frequency Net Database (AFND) is a public database which contains\n\u003e frequency information of several immune genes such as Human Leukocyte\n\u003e Antigens (HLA), Killer-cell Immunoglobulin-like Receptors (KIR), Major\n\u003e histocompatibility complex class I chain-related (MIC) genes, and a number of\n\u003e cytokine gene polymorphisms.\n\nThe [afnd.tsv](afnd.tsv) file looks like this:\n\n```{r}\nd \u003c- fread(\"afnd.tsv\")\nhead(d)\n```\n\nDefinitions:\n\n- `alleles_over_2n` (Alleles / 2n)\n  Allele Frequency: total number of copies of\n  the allele in the population sample in three decimal format.\n\n- `indivs_over_n` (100 \\* Individuals / n)\n  Percentage of individuals who have the allele or gene.\n\n- `n` (Individuals)\n  Number of individuals sampled from the population.\n\n\n## Examples\n\nHere are a few examples of how we can use R to analyze these data.\n\nView the largest and smallest populations available in the data:\n\n```{r}\nd %\u003e%\n  mutate(n = parse_number(n)) %\u003e%\n  select(population, n) %\u003e%\n  unique() %\u003e%\n  arrange(-n)\n```\n\nCount the number of alleles for each gene:\n\n```{r}\nd %\u003e%\n  count(group, gene, allele) %\u003e%\n  count(group, gene) %\u003e%\n  arrange(-n) %\u003e%\n  head(15)\n```\n\nSum the allele frequencies for each gene in each population. This allows us to\nsee which populations have a set of allele frequencies that adds up to 100\npercent:\n\n```{r}\nd %\u003e%\n  mutate(alleles_over_2n = parse_number(alleles_over_2n)) %\u003e%\n  filter(alleles_over_2n \u003e 0) %\u003e%\n  group_by(group, gene, population) %\u003e%\n  summarize(sum = sum(alleles_over_2n)) %\u003e%\n  count(sum == 1)\n```\n\n```{r, include = FALSE}\ntheme_set(\n  theme_bw(base_size = 14) +\n  theme(\n    plot.caption.position = \"plot\"\n  )  \n)\n```\n\nPlot the frequency of a specific allele in populations with more than 1000\nsampled individuals:\n\n```{r, dpi = 300, fig.width = 9, fig.height = 7}\n\nmy_allele \u003c- \"DQB1*02:01\"\nmy_d \u003c- d %\u003e% filter(allele == my_allele) %\u003e%\n  mutate(\n    n = parse_number(n),\n    alleles_over_2n = parse_number(alleles_over_2n)\n  ) %\u003e%\n  filter(n \u003e 1000) %\u003e%\n  arrange(-alleles_over_2n)\n\nggplot(my_d) +\n  aes(x = alleles_over_2n, y = reorder(population, alleles_over_2n)) +\n  scale_y_discrete(position = \"right\") +\n  geom_colh() +\n  labs(\n    x = \"Allele Frequency (Alleles / 2N)\",\n    y = NULL,\n    title =  glue(\"Frequency of {my_allele} across populations\"),\n    caption = \"Data from AFND http://allelefrequencies.net\"\n  )\n```\n\n\n## Citation\n\nIf you use this data, please cite the latest manuscript about **Allele Frequency\nNet Database**:\n\n- Gonzalez-Galarza FF, McCabe A, Santos EJMD, Jones J, Takeshita L,\n  Ortega-Rivera ND, et al. [Allele frequency net database (AFND) 2020 update:\n  gold-standard data classification, open access genotype data and new query\n  tools.](https://pubmed.ncbi.nlm.nih.gov/31722398) Nucleic Acids Res. 2020;48:\n  D783–D788. doi:10.1093/nar/gkz1029\n\n```\n@ARTICLE{Gonzalez-Galarza2020,\n  title    = \"{Allele frequency net database (AFND) 2020 update: gold-standard\n              data classification, open access genotype data and new query\n              tools}\",\n  author   = \"Gonzalez-Galarza, Faviel F and McCabe, Antony and Santos, Eduardo\n              J Melo Dos and Jones, James and Takeshita, Louise and\n              Ortega-Rivera, Nestor D and Cid-Pavon, Glenda M Del and\n              Ramsbottom, Kerry and Ghattaoraya, Gurpreet and Alfirevic, Ana\n              and Middleton, Derek and Jones, Andrew R\",\n  journal  = \"Nucleic acids research\",\n  volume   =  48,\n  number   = \"D1\",\n  pages    = \"D783--D788\",\n  month    =  jan,\n  year     =  2020,\n  language = \"en\",\n  issn     = \"0305-1048, 1362-4962\",\n  pmid     = \"31722398\",\n  doi      = \"10.1093/nar/gkz1029\",\n  pmc      = \"PMC7145554\"\n}\n```\n\n## Related work\n\nHere are all of the resources I could find that have information about HLA\nallele frequencies in different populations.\n\n### HLAfreq\n\nhttps://github.com/Vaccitech/HLAfreq/\n\n- Wells DA, McAuley M. [HLAfreq: Download and combine HLA allele frequency data.](https://www.biorxiv.org/content/10.1101/2023.09.15.557761v1) bioRxiv. 2023. doi:10.1101/2023.09.15.557761\n\n### CIWD version 3.0.0\n\n- Hurley CK, Kempenich J, Wadsworth K, Sauter J, Hofmann JA, Schefzyk D, et al.\n  [Common, intermediate and well-documented HLA alleles in world populations:\n  CIWD version 3.0.0.](https://www.ncbi.nlm.nih.gov/pubmed/31970929) Hladnikia.\n  2020;95: 516–531. doi:10.1111/tan.13811\n\nThe authors provide xlsx files on this website:\n\n- https://www.ihiw18.org/component-immunogenetics/download-common-and-well-documented-alleles-3-0\n\nBut the frequency information is binned into categories:\n\n- C, common\n- I, intermediate\n- WD, well-documented\n- NA, not applicable\n\nThere is a tool called [HLA-Net](https://hla-net.eu/tools/cwd-viewer/results/)\nthat provides a visualization of the CIWD data.\n\n### IEDB Tools\n\nhttp://tools.iedb.org/population/download\n\nAt the IEDB Tools page, we can find a tool called **Population Coverage**. The\nauthors have downloaded the HLA frequency information from AFND and saved it in\na Python pickle file.\n\n### dbMHC\n\nhttps://www.ncbi.nlm.nih.gov/gv/mhc\n\nThe dbMHC database and website appears to be discontinued. But an archive of\nold files is still available via FTP.\n\n### NMDP\n\nhttps://bioinformatics.bethematchclinical.org/hla-resources/haplotype-frequencies/high-resolution-hla-alleles-and-haplotypes-in-the-us-population/\n\n- Maiers M, Gragert L, Klitz W. [High-resolution HLA alleles and haplotypes in\n  the United States population.](https://pubmed.ncbi.nlm.nih.gov/17869653) Hum\n  Immunol. 2007;68: 779–788. doi:10.1016/j.humimm.2007.04.005\n\n\n## Acknowledgments\n\nThanks to David A. Wells for sharing [scrapeAF][1], which inspired me to work\non this project.\n\n[1]: https://github.com/DAWells/scrapeAF\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslowkow%2Fallelefrequencies","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslowkow%2Fallelefrequencies","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslowkow%2Fallelefrequencies/lists"}