{"id":32202721,"url":"https://github.com/k96nb01/immunogenetr_package","last_synced_at":"2026-05-27T12:01:19.574Z","repository":{"id":244262646,"uuid":"814723176","full_name":"k96nb01/immunogenetr_package","owner":"k96nb01","description":"An R library for HLA informatics","archived":false,"fork":false,"pushed_at":"2026-05-26T05:57:54.000Z","size":10193,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-05-26T06:31:46.607Z","etag":null,"topics":["hla","hla-typing","informatics","r","tidyverse"],"latest_commit_sha":null,"homepage":"https://k96nb01.github.io/immunogenetr_package/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/k96nb01.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-06-13T15:12:14.000Z","updated_at":"2026-05-26T04:44:51.000Z","dependencies_parsed_at":"2024-09-13T06:19:57.506Z","dependency_job_id":"4e9410be-1db2-4388-904e-7014c9e42a55","html_url":"https://github.com/k96nb01/immunogenetr_package","commit_stats":null,"previous_names":["k96nb01/immunogenetr_package"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/k96nb01/immunogenetr_package","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k96nb01%2Fimmunogenetr_package","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k96nb01%2Fimmunogenetr_package/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k96nb01%2Fimmunogenetr_package/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k96nb01%2Fimmunogenetr_package/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k96nb01","download_url":"https://codeload.github.com/k96nb01/immunogenetr_package/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k96nb01%2Fimmunogenetr_package/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33564850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["hla","hla-typing","informatics","r","tidyverse"],"created_at":"2025-10-22T04:10:57.473Z","updated_at":"2026-05-27T12:01:19.565Z","avatar_url":"https://github.com/k96nb01.png","language":"R","funding_links":[],"categories":["🧬 HLA Analysis"],"sub_categories":["Peptide Prediction"],"readme":"---\noutput:\n  github_document:\n    # Disable pandoc's 'superscript' extension so '^' characters inside\n    # GL-string cells stay as literal '^' in the rendered output instead\n    # of being wrapped in \u003csup\u003e HTML tags. Same reason we disable\n    # 'subscript' (paranoia; GL strings don't use '~' but could in theory).\n    md_extensions: -superscript-subscript\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r setup, include=FALSE}\nknitr::opts_chunk$set(\n  echo    = TRUE,\n  message = FALSE,   # suppress library() startup messages\n  warning = FALSE    # suppress dplyr summarise/grouping messages\n)\n\n# kable_hla(): wrap knitr::kable, rendering each character cell as a\n# code span (backtick-wrapped). HLA GL strings contain '*' and '^', both\n# of which trigger markdown formatting downstream: GitHub Flavored Markdown\n# turns '*...*' into italics, and pandoc's superscript extension (enabled\n# by default in pkgdown's render pipeline) turns '^...^' into \u003csup\u003e...\u003c/sup\u003e.\n# Wrapping cell values in backticks bypasses both because content inside\n# a code span is treated as literal text by every markdown renderer.\n# This survives the github_document -\u003e README.md -\u003e pkgdown round-trip,\n# which '\\\\*' / '\\\\^' escaping does not (pandoc drops the redundant '\\\\^'\n# escape when superscript is disabled, leaving a bare '^' that pkgdown\n# then re-interprets).\n#\n# Uses an explicit column loop rather than `df[] \u003c- lapply(df, ...)` so the\n# function is robust to tibble-specific [\u003c- methods.\nkable_hla \u003c- function(df) {\n  for (nm in names(df)) {\n    if (is.character(df[[nm]])) {\n      df[[nm]] \u003c- paste0(\"`\", df[[nm]], \"`\")\n    }\n  }\n  knitr::kable(df)\n}\n```\n\n# immunogenetr \u003cimg src='man/figures/immunogenetr_sticker.png' align=\"right\" width=\"120\" height=\"139\" style=\"height:139px; width:auto; max-width:120px;\" alt=\"immunogenetr hex sticker\" /\u003e\n\n\u003c!-- badges: start --\u003e\n\n[![codecov](https://codecov.io/gh/k96nb01/immunogenetr_package/graph/badge.svg?token=16D4U43VET)](https://app.codecov.io/gh/k96nb01/immunogenetr_package)\n[![R-CMD-check](https://github.com/k96nb01/immunogenetr_package/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/k96nb01/immunogenetr_package/actions/workflows/R-CMD-check.yaml)\n\u003c!-- badges: end --\u003e\n\nimmunogenetr is a comprehensive toolkit for clinical HLA informatics. It is built on tidyverse principles and makes use of genotype list string (GL string, https://glstring.org/) for storing and using HLA genotype data. \n\nSpecific functionalities of this library include:\n\n- **Coercion of HLA data** in tabular format to and from GL string.\n- **Calculation of matching and mismatching** in all directions, with multiple output formats.\n- **Automatic formatting of HLA data** for searching within a GL string.\n- **Truncation of molecular HLA data** to a specific number of fields.\n- **Reading HLA genotypes in HML files** and extracting the GL string.\n  \n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Citation](#citation)\n- [License](#license)\n- [Disclaimer](#disclaimer)\n\n## Installation\n\nYou may install immunogenetr from CRAN with the below line of code:\n\n```{r install, eval = FALSE}\ninstall.packages(\"immunogenetr\")\n```\n\n## Usage\n\nTo demonstrate some functionality of `immunogenetr` we will use an internal dataset to perform match grades for a putative recipient/donor pair.\n```{r load-package}\nlibrary(immunogenetr)\nlibrary(tidyverse)\n\n# The \"HLA_typing_1\" dataset is installed with immunogenetr, and contains high resolution typing at all classical\n# HLA loci for ten individuals.\n\nkable_hla(HLA_typing_1)\n```\n\n\n\nimmunogenetr uses genotype list strings (GL strings) for most functions, including the matching and mismatching functions. To easily convert the genotypes found in \"HLA_typing_1\" to GL strings we can use the `HLA_columns_to_GLstring` function:\n\n```{r build-gl-string}\nHLA_typing_1_GLstring \u003c- HLA_typing_1 %\u003e%\n  mutate(GL_string = HLA_columns_to_GLstring(., HLA_typing_columns = A1:DPB1_2), .after = patient) %\u003e%\n  # Note the syntax for the `HLA_columns_to_GLstring` arguments - when this function is used inside\n  # of a `mutate` function to make a new column in a data frame, \".\" is used in the first argument\n  # to tell the function to use the working data frame as the source of the HLA typing columns.\n  select(patient, GL_string)\n\nkable_hla(HLA_typing_1_GLstring)\n```\n\n\nThe \"HLA_typing_1_GLstring\" data frame now contains a row with a GL string for each individual, containing their full HLA genotype in a single string. Let's select one individual to act as a recipient, and one to act as a donor.\n\n\n```{r recip-donor}\n# Select one case each for recipient and donor.\nHLA_typing_1_GLstring_recipient \u003c- HLA_typing_1_GLstring %\u003e%\n  filter(patient == 7) %\u003e%\n  rename(GL_string_recipient = GL_string, case = patient)\n\nHLA_typing_1_GLstring_donor \u003c- HLA_typing_1_GLstring %\u003e%\n  filter(patient == 9) %\u003e%\n  rename(GL_string_donor = GL_string) %\u003e%\n  select(-patient)\n\n# Combine the tables so recipient and donor are on the same row.\nHLA_typing_1_recip_donor \u003c- bind_cols(\n  HLA_typing_1_GLstring_recipient,\n  HLA_typing_1_GLstring_donor\n  )\n\nkable_hla(HLA_typing_1_recip_donor)\n```\n\n\n\nWe now have a data frame with a recipient and donor HLA genotype on one row. Let's try out some of the mismatching functions on this data.\n\n```{r mismatches-logical}\nHLA_typing_1_recip_donor_mismatches \u003c- HLA_typing_1_recip_donor %\u003e%\n  mutate(A_MM_GvH = HLA_mismatch_logical(\n                      GL_string_recipient,\n                      GL_string_donor,\n                      \"HLA-A\",\n                      direction = \"GvH\"),\n                    .after = case) %\u003e%\n  mutate(A_MM_HvG = HLA_mismatch_logical(\n                      GL_string_recipient,\n                      GL_string_donor,\n                      \"HLA-A\",\n                      direction = \"HvG\"),\n                    .after = A_MM_GvH)\n\nkable_hla(HLA_typing_1_recip_donor_mismatches)\n```\n\nThe `HLA_mismatch_logical` function determines if there are any mismatches at a particular locus. We've determined that at the HLA-A locus there are not any mismatches in the graft-versus-host direction, but are in the host-versus-graft direction. We can use the `HLA_mismatched_alleles` function to tell us what those mismatches are:\n\n\n```{r mismatched-alleles}\nHLA_typing_1_recip_donor_mismatched_allles \u003c- HLA_typing_1_recip_donor %\u003e%\n  mutate(A_HvG_MMs = HLA_mismatched_alleles(\n                        GL_string_recipient,\n                        GL_string_donor,\n                        \"HLA-A\",\n                        direction = \"HvG\"),\n                      .after = case)\n\nkable_hla(HLA_typing_1_recip_donor_mismatched_allles)\n```\n\n\nThe `HLA_mismatched_alleles` function reported that the \"HLA-A*30:01\" allele was mismatched in the HvG direction. Sometimes, however, we simply want to know how many mismatches are at a particular locus. We can do that with the `HLA_mismatch_number` function:\n\n\n```{r mismatch-number}\n# Determine the number of bidirectional mismatches at several loci.\nHLA_typing_1_recip_donor_MM_number \u003c- HLA_typing_1_recip_donor %\u003e%\n  mutate(ABCDRB1_MM = HLA_mismatch_number(\n                        GL_string_recipient,\n                        GL_string_donor,\n                        c(\"HLA-A\", \"HLA-B\", \"HLA-C\", \"HLA-DRB1\"),\n                        direction = \"bidirectional\"),\n                      .after = case)\n\nkable_hla(HLA_typing_1_recip_donor_MM_number)\n```\n\n\nWe might want to calculate an HLA match summary for stem cell transplantation. We can use the `HLA_match_summarry_HCT` function for this:\n\n\n```{r match-summary-hct}\n# The match_grade argument of \"Xof8\" will return the number of matches at the HLA-A, B, C, and DRB1 loci.\nHLA_typing_1_recip_donor_8of8_matching \u003c- HLA_typing_1_recip_donor %\u003e%\n  mutate(ABCDRB1_matching = HLA_match_summary_HCT(\n                              GL_string_recipient,\n                              GL_string_donor,\n                              direction = \"bidirectional\",\n                              match_grade = \"Xof8\"),\n                            .after = case)\n\nkable_hla(HLA_typing_1_recip_donor_8of8_matching)\n```\n\n\nClearly, this recipient and donor are not a great match. Let's see how we could use this workflow to find the best-matched donor from several options. To do this, we'll choose a case from \"HLA_typing_1\" and compare it to all the cases in that data set:\n\n\n```{r donor-comparison}\n# Select one case to be the recipient.\nHLA_typing_1_GLstring_candidate \u003c- HLA_typing_1_GLstring %\u003e%\n  filter(patient == 3) %\u003e%\n  select(GL_string) %\u003e%\n  rename(GL_string_recip = GL_string)\n\n# Join the recipient to the 10-donor list and perform matching\nHLA_typing_1_GLstring_donors \u003c- HLA_typing_1_GLstring %\u003e%\n  rename(GL_string_donor = GL_string, donor = patient) %\u003e%\n  cross_join(HLA_typing_1_GLstring_candidate) %\u003e%\n  mutate(ABCDRB1_matching = HLA_match_summary_HCT(\n                              GL_string_recip,\n                              GL_string_donor,\n                              direction = \"bidirectional\",\n                              match_grade = \"Xof8\"),\n                            .after = donor) %\u003e%\n  arrange(desc(ABCDRB1_matching))\n\nkable_hla(HLA_typing_1_GLstring_donors)\n```\n\nWe can see that donor 3 is the only donor with an 8/8 match for the recipient.\n\n\n## Citation\n\nIf you use immunogenetr in your research, please cite:\n\nCoskun B, Brown NK. Immunogenetr: A comprehensive toolkit for clinical HLA informatics. *Human Immunology*. 2026;87(1):111619. doi:[10.1016/j.humimm.2025.111619](https://doi.org/10.1016/j.humimm.2025.111619)\n\nYou can also get the citation from R with `citation(\"immunogenetr\")`.\n\n## License\n\nThis project is licensed under the GNU General Public License v3.0.\n\n## Disclaimer\n\nThis library is intended for research use. Any application making use of this package in a clinical setting will need to be independently validated according to local regulations.\n\n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk96nb01%2Fimmunogenetr_package","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk96nb01%2Fimmunogenetr_package","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk96nb01%2Fimmunogenetr_package/lists"}