Software report · preprint, not peer reviewedOpen access
kir-wgs: copy number and alleles of every KIR gene from whole-genome sequencing, with a statement of what is certain
Affiliations and notes
- 1 PJ Labs, Austria
- Correspondence: info@pjlabs.dev
- Lead contact: Peter Jungwirth, MSc
Article information
- Publication history
- Published 29 November 2026
- Peer review
- not peer reviewed
- Version
- 1.0.0
- Licence
- MIT
Highlights
- One program without external tools at run time: FASTQ, BAM or CRAM in; copy number, alleles and the KIR A/B genotype out
- Copy number right for 98.8 % of genes in 57 unseen genomes (901 of 912)
- Every copy comes with the number of digits the reads support; 98.6 % of 3-digit statements right in unseen genomes (11 of 771 wrong)
- Fewer extra alleles than T1K on the same reads and the same truth (67 against 96 of 954 distinct 3-digit alleles)
- Research use only
In brief kir-wgs estimates the copy number of 16 KIR genes from short-read whole-genome sequencing, assigns one allele to every copy and states for every copy how many digits of the name the reads support. It is a research tool and does not replace an accredited laboratory.
Summary
The killer-cell immunoglobulin-like receptor (KIR) genes differ between people in which genes are present, in how many copies, and in their alleles. Short reads from whole-genome sequencing cover the region, but the genes are so similar that copy number and alleles are hard to separate. kir-wgs is a single Rust program that reads paired FASTQ, BAM or CRAM, estimates the copy number of 16 KIR genes from gene-specific 31-mers against the depth of the flanking sequence, and assigns one allele to every copy with one mixture model over all copies of all genes. For every copy it states how many digits of the name the reads support. It was developed on haplotype-resolved assemblies of the Human Pangenome Reference Consortium [12] and compared with T1K [11]. On 57 genomes of the Human Genome Structural Variation Consortium [15] that were never used in development, the copy number was right for 901 of 912 genes; of 954 distinct 3-digit alleles in the truth, kir-wgs found 893 with 67 extra, and T1K 880 with 96 extra. Of the copies it reported as certain at 3 digits, 11 of 771 were wrong.
Graphical abstract
Keywords
- KIR typing
- killer-cell immunoglobulin-like receptor
- copy number
- whole-genome sequencing
- IPD-KIR
- KIR A/B genotype
- HPRC
- HGSVC
- T1K
- Rust
Introduction
The KIR genes on chromosome 19q13.4 encode receptors of natural killer cells that recognise HLA class I molecules [1]. The region varies between haplotypes in gene content, and individuals carry different sets of genes [2]; haplotypes are grouped into A and B by gene content, and copy number variation adds to the diversity of B haplotypes in particular [3]. Alleles are named with up to seven digits: three for the protein, two for synonymous changes in the coding sequence and two for changes outside it [4]. The IPD-KIR database collects the known alleles [5]. KIR genotypes have been associated with the outcome of haematopoietic cell transplantation [6] and with disorders of pregnancy [7].
The genes are highly similar to each other, which makes typing from short reads difficult. Approaches include targeted sequencing with dedicated interpretation pipelines [8] [9], k-mer signatures for gene content and haplotypes [10] and T1K, which genotypes KIR and HLA from whole-genome, exome and RNA sequencing [11]. Whole-genome sequencing is now common, and the haplotype-resolved assemblies of the Human Pangenome Reference Consortium (HPRC) [12] contain the complete KIR region of both haplotypes for samples that also have 30× short-read sequencing from the 1000 Genomes Project [13]. This gives a truth that is independent of any typing program: which genes are present on each haplotype, how many copies, and the sequence of each copy.
kir-wgs was built from the design of hla-wgs [14], a program of the same author for HLA, and keeps its principle: a correct type where the data allow it, and per copy an explicit statement of how far the name can be trusted.
Results
Design
kir-wgs is one Rust program without run-time dependencies (Figure 1). It reads paired FASTQ files or a coordinate-sorted BAM or CRAM file on GRCh38 or GRCh37; from alignments it takes the KIR region of chromosome 19, the chromosome 19 alternative contigs and the unmapped reads. It reports 16 copy-number groups: the 15 genes KIR2DL1 to KIR3DS1 and KIR2DL5, whose two loci KIR2DL5A and KIR2DL5B are counted together.
The output gives the copy number of every gene with the measured ratio and whether it is certain, one allele per copy with the name cut to the digits the reads support (resolution gene, 3, 5 or 7), the alleles that are equally good or not ruled out, and the A/B genotype. It is written as TSV, JSON, a report part for a combined genome report and a result page in German and English.
Copy number
The copy number was compared with the number of gene copies found in both assembled haplotypes, for every sample and all 16 groups, including the absence of a gene. It was right for 1,235 of 1,248 genes in 78 development samples, 2,288 of 2,320 in 145 check samples and 901 of 912 (98.8 %) in 57 unseen samples. T1K reports the alleles present, not a copy number; for presence or absence of a gene, it agreed with the truth for 910 of 912 genes and kir-wgs for 909.
Alleles
Where the copy number was right, the calls of a gene were matched to its assembled copies. Of the copies whose protein is in IPD-KIR, kir-wgs named 1,357 of 1,409 right at 3 digits in the development samples, 2,597 of 2,684 in the check samples and 983 of 1,035 (95.0 %) in the unseen samples. 25 copies of the unseen samples carry a protein that is not in the database and cannot be named right at 3 digits.
Because T1K reports distinct alleles per gene rather than one allele per copy, both programs were also compared on the set of distinct 3-digit alleles of every gene (Figure 2). Of 954 distinct alleles in the truth of the unseen samples, kir-wgs found 893 (93.6 %) and reported 67 that are not in the truth; T1K 1.0.10, run on the same reads with an index from the same IPD-KIR release, found 880 (92.2 %) with 96 extra (Table 1).
Certainty
A copy is reported as certain at 3 digits when every allele that is not ruled out shares the first three digits with the call. Of these statements, 13 of 1,091 were wrong in the development samples, 11 of 2,150 in the check samples and 11 of 771 in the unseen samples (Table 1). At 5 digits, 11 of 730 statements were wrong in the unseen samples.
| Gene | Copy number right | Copies | 3 digits right (known protein) | Certain, wrong | Extra kir-wgs | Extra T1K |
|---|---|---|---|---|---|---|
| KIR2DL1 | 53 / 57 | 84 | 83 / 83 | 0 / 64 | 2 | 7 |
| KIR2DL2 | 56 / 57 | 37 | 37 / 37 | 0 / 32 | 0 | 0 |
| KIR2DL3 | 57 / 57 | 74 | 74 / 74 | 0 / 61 | 0 | 0 |
| KIR2DL4 | 55 / 57 | 108 | 101 / 104 | 4 / 96 | 4 | 9 |
| KIR2DL5 | 57 / 57 | 35 | 28 / 34 | 3 / 17 | 6 | 15 |
| KIR2DP1 | 57 / 57 | 91 | 84 / 86 | 0 / 72 | 3 | 3 |
| KIR2DS1 | 57 / 57 | 19 | 19 / 19 | 0 / 17 | 0 | 1 |
| KIR2DS2 | 57 / 57 | 37 | 34 / 36 | 0 / 27 | 2 | 3 |
| KIR2DS3 | 57 / 57 | 13 | 13 / 13 | 0 / 10 | 0 | 2 |
| KIR2DS4 | 55 / 57 | 90 | 84 / 84 | 0 / 61 | 5 | 0 |
| KIR2DS5 | 57 / 57 | 22 | 20 / 21 | 0 / 18 | 2 | 1 |
| KIR3DL1 | 57 / 57 | 95 | 95 / 95 | 0 / 94 | 0 | 2 |
| KIR3DL2 | 57 / 57 | 112 | 104 / 112 | 0 / 40 | 7 | 9 |
| KIR3DL3 | 57 / 57 | 114 | 94 / 114 | 0 / 57 | 20 | 29 |
| KIR3DP1 | 57 / 57 | 114 | 98 / 108 | 4 / 90 | 14 | 13 |
| KIR3DS1 | 55 / 57 | 15 | 15 / 15 | 0 / 15 | 2 | 2 |
| All genes | 901 / 912 | 1,060 | 983 / 1,035 | 11 / 771 | 67 | 96 |
Copy number right: genes with the right number of copies, including absent genes. 3 digits right: copies with a known protein named right. Certain, wrong: wrong 3-digit statements among those reported as certain. Extra: distinct 3-digit alleles reported but not in the truth.
Lower sequencing depth
For 10 development samples, half and a third of the read pairs were kept (about 15× and 10×), chosen by a checksum of the read name so that both programs saw the same reads. The copy number was right for 160, 159 and 159 of 160 genes at 30×, 15× and 10×, and the alleles of 169, 167 and 165 copies were right at 3 digits. With less data, kir-wgs reported fewer copies as certain (147, 115 and 65), of which 0, 0 and 0 were wrong. Of 162 distinct 3-digit alleles, kir-wgs found 153, 153 and 149 with 12, 12 and 14 extra, and T1K 150, 148 and 144 with 14, 17 and 19 extra (Table 2).
| Depth | Copy number right | Copies right at 3 digits | Certain at 3 digits | of these wrong | Distinct alleles kir-wgs · extra | Distinct alleles T1K · extra |
|---|---|---|---|---|---|---|
| 30× | 160 / 160 | 169 | 147 | 0 | 153 / 162 · 12 | 150 / 162 · 14 |
| 15× | 159 / 160 | 167 | 115 | 0 | 153 / 162 · 12 | 148 / 162 · 17 |
| 10× | 159 / 160 | 165 | 65 | 0 | 149 / 162 · 14 | 144 / 162 · 19 |
Half and a third of the read pairs were kept, chosen by a checksum of the read name, so that both programs saw the same reads. Distinct alleles: found of 162 distinct 3-digit alleles in the truth, then the number reported but not in the truth.
Run time
On the reads of the KIR region of 5 samples (15 runs per tool; 4 threads each, Linux VM with 4 vCPU (Intel Xeon 2.1 GHz), FASTQ of the reads of the KIR region from the 1000 Genomes alignments, no other load), kir-wgs took a median of 15.4 s wall time and 47.1 s CPU time with at most 465 MB of memory, and T1K 19.4 s and 65.2 s with at most 755 MB (Figure 3). Both were started the same way through the same measuring command.
Discussion
kir-wgs types the KIR genes from the short reads of a whole genome with one program and a statement of certainty for every copy. The copy number, which decides how many alleles a gene carries, comes from the depth of gene-specific 31-mers alone and does not depend on the alleles. The alleles of all genes are then fitted together, so that a read that fits two genes is shared between them in proportion to how well it fits.
Compared with T1K on the same truth, kir-wgs reports fewer alleles that are not there. Where it cannot separate alleles, it cuts the name to the common digits instead of choosing one. A user can tell from the output which part of a name the reads support. For the presence of a gene the two programs agreed about equally often with the truth (909 and 910 of 912), and kir-wgs needed less time and memory on the same reads.
On the unseen samples 1.4 % (95 % interval 0.8 to 2.5 %) of the certain 3-digit statements were wrong (11 of 771), against 1.2 % (95 % interval 0.7 to 2.0 %) in the development and 0.5 % (95 % interval 0.3 to 0.9 %) in the check samples. The share is as in development and higher than in the check samples, whose errors had led to the three checks on the reads. The wrong statements of the unseen samples fall on KIR2DL4, KIR2DL5 and the pseudogene KIR3DP1 (Table 1), and about half of them are copies with a coding sequence that is not in IPD-KIR and that the reads did not reveal. With two copies of a gene, a base of the new copy that the other called allele also has cannot be told apart with short reads. KIR3DL3 and KIR3DL2, the genes with the most alleles, have the fewest copies named right, but kir-wgs reports most of their copies as uncertain.
Limitations of the study
- The truth comes from HPRC and HGSVC assemblies and is limited to the populations of the 1000 Genomes Project.
- The development and check samples were used to set the parameters and to decide changes; only the unseen set measures a frozen version, once.
- An assembly can itself be wrong in this region, and such errors count against both programs. Copies whose protein is not in IPD-KIR cannot be named right and are counted separately.
- kir-wgs was evaluated on 30× Illumina genomes; lower depth was measured only on 10 samples down to about 10×, and other read lengths and sequencing chemistries were not measured.
- KIR2DL5A and KIR2DL5B are reported as one group.
Resource availability
Lead contact
Requests for further information and resources should be directed to the lead contact, Peter Jungwirth (info@pjlabs.dev).
Materials availability
This study did not generate new materials.
Data and code availability
The source code of kir-wgs and kir-wgs-validate, the sample lists and all result tables are available under the MIT licence at github.com/pjlabsdev/kir-wgs, release v1.0.0. Archived on Zenodo: doi:10.5281/zenodo.24661388 (all versions; version 1.0.0: doi:10.5281/zenodo.24661389).
The HPRC and HGSVC assemblies and the 1000 Genomes alignments are public. The reference is built locally from the IPD-KIR release [5]; IPD-KIR is available from the IPD project under its own terms and is not redistributed.
Acknowledgments
The author thanks the Human Pangenome Reference Consortium, the Human Genome Structural Variation Consortium, the 1000 Genomes Project and the IPD-KIR curators for making their data available.
Declaration of interests
The author declares no competing interests.
Methods
Key resources table
| Resource | Version | Source |
|---|---|---|
| Deposited data | ||
| IPD-KIR | 2.15.0 | ebi.ac.uk/ipd/kir |
| 1000 Genomes, high-coverage genomes | NYGC 30× | internationalgenome.org |
| HPRC assemblies | 223 samples | humanpangenome.org |
| HGSVC assemblies | HGSVC3 | hgsvc.org |
| Software and algorithms | ||
| kir-wgs | 1.0.0 | github.com/pjlabsdev/kir-wgs |
| T1K | 1.0.10 | github.com/mourisl/T1K |
Data and study participant details
No new human samples were collected and no patient data were used. Public data: 1000 Genomes high-coverage genomes [13], HPRC assemblies [12] and HGSVC3 assemblies [15]. 223 HPRC samples were split once into 78 development and 145 check samples; 57 HGSVC3 samples that are not among the HPRC samples form the unseen set.
Method details
Reference
kir-wgs build-db reads kir.dat of IPD-KIR 2.15.0 (2,304 entries, 2,285 with a coding sequence). Alleles known only by their coding sequence get the introns of the nearest genomic allele. For every copy-number group the 31-mers that occur in all of its alleles and in no other gene are kept for the copy number, and 31-mers of the flanking sequence on GRCh38 serve as the depth of two copies.
Reads and copy number
Every read pair is scanned for 31-mers; a pair is kept when one mate shares at least 20 31-mers with a KIR allele. The copy number of a gene is two times the median count of its 31-mers divided by the median count of the flank 31-mers, rounded; it is uncertain when the ratio lies more than 0.3 from a whole number.
Alleles
The kept pairs are aligned to one representative per 3-digit group and then to all alleles of the groups that fit best; the cost of a pair under an allele is the summed edit distance of both mates, with edits outside the exons weighted 0.03. An allele whose entry lacks introns or flanks that other alleles of the gene have is completed with those of the nearest complete allele, so that all alleles of a gene are compared over the same sequence. The genotype is the set of alleles, as many per group as it has copies, that maximises the likelihood of all pairs under one mixture over all copies, with a cost of 4.6 per edit and a background of 1 edit for pairs from elsewhere. It is found by a greedy start and coordinate ascent, and for two copies of a gene by a joint search over the 40 best pairs of alleles. Any allele or pair whose fit in place of the call, counted on exon edits alone, is less than 7 log-likelihood units worse is not ruled out, and a second fit with intron weight 0.125 must reach the same alleles; the resolution is the longest common prefix of the call with all of them.
Checks on the reads
Three checks on the reads can shorten the resolution further. First, all pairs are aligned to the called alleles alone, and a coding position where at least a quarter of the reads of an allele (at least 4 of at least 8, each with at most 3 differences) carry another base marks the copy as a new allele: certain at 3 digits when the amino acid stays the same, otherwise only as a gene. Pairs that fit another called gene almost as well do not count, and a base that another called allele of the same gene has at that position does not count either. Pairs that fit alleles of two genes equally count where the read differs from all of them at the same place; such a site goes to the gene whose own reads carry it.
Second, a called allele is certain only as a gene when at two or more coding positions where it differs from every other called allele of its gene no read fits only it. Third, an allele whose entry does not contain all exons is certain only as a gene.
Quick start
# build the reference once (kir.dat of the IPD-KIR release)
git clone https://github.com/pjlabsdev/kir-wgs && cd kir-wgs
cargo build --release
kir-wgs build-db kir.dat ref/kirdb
# type a sample (BAM or CRAM, or paired FASTQ)
kir-wgs ref/kirdb sample.bam out/sample 8
kir-wgs ref/kirdb sample.cram out/sample 8 GRCh38.fa
kir-wgs ref/kirdb sample_R1.fq.gz sample_R2.fq.gz out/sample 8Truth and evaluation
For each sample, the contigs of both haplotypes that contain KIR coding 31-mers are cut to the region, and every gene copy is located by aligning the genomic alleles; the coding sequence of each copy is compared with all alleles to find those with the same coding sequence (5 digits), the same protein (3 digits) or, for a new coding sequence, the nearest. The 223 HPRC samples with an assembly and a 30× genome of the 1000 Genomes Project were split once into three parts. 78 development samples set the parameters. The other two parts are the check samples (145): 30 decided every change, and 115 were first measured once with an earlier frozen version; the errors found there led to the three checks above, so they are no longer unseen. The unseen set are 57 samples of the Human Genome Structural Variation Consortium (HGSVC3, Verkko assemblies) [15] that are not among the HPRC samples and have a 30× genome of the 1000 Genomes Project; two further samples were left out because one haplotype has no contig with the KIR region. The final version was frozen and measured on them once. A copy that kir-wgs reports as certain counts as wrong also when its protein is not in IPD-KIR. The reads were taken from the 1000 Genomes alignments: the KIR region on GRCh38, the chromosome 19 alternative contigs and the unmapped pairs. T1K 1.0.10 was run with --preset kir-wgs and an index built with t1k-build.pl from the same kir.dat. All numbers in the report are produced by kir-wgs-validate from the files under validation/results.
Supplemental information
References
- Parham P. MHC class I molecules and KIRs in human history, health and survival. Nat Rev Immunol. 2005;5(3):201-214.
- Uhrberg M, Valiante NM, Shum BP, et al. Human diversity in killer cell inhibitory receptor genes. Immunity. 1997;7(6):753-763.
- Jiang W, Johnson C, Jayaraman J, et al. Copy number variation leads to considerable diversity for B but not A haplotypes of the human KIR genes encoding NK cell receptors. Genome Res. 2012;22(10):1845-1854.
- Marsh SGE, Parham P, Dupont B, et al. Killer-cell immunoglobulin-like receptor (KIR) nomenclature report, 2002. Tissue Antigens. 2003;62(1):79-86.
- Robinson J, Waller MJ, Stoehr P, Marsh SGE. IPD: the Immuno Polymorphism Database. Nucleic Acids Res. 2005;33:D523-D526.
- Cooley S, Weisdorf DJ, Guethlein LA, et al. Donor selection for natural killer cell receptor genes leads to superior survival after unrelated transplantation for acute myelogenous leukemia. Blood. 2010;116(14):2411-2419.
- Hiby SE, Walker JJ, O'Shaughnessy KM, et al. Combinations of maternal KIR and fetal HLA-C genes influence the risk of preeclampsia and reproductive success. J Exp Med. 2004;200(8):957-965.
- Norman PJ, Hollenbach JA, Nemat-Gorgani N, et al. Defining KIR and HLA class I genotypes at highest resolution via high-throughput sequencing. Am J Hum Genet. 2016;99(2):375-391.
- Marin WM, Dandekar R, Augusto DG, et al. High-throughput interpretation of killer-cell immunoglobulin-like receptor short-read sequencing data with PING. PLoS Comput Biol. 2021;17(8):e1008904.
- Roe D, Kuang R. Accurate and efficient KIR gene and haplotype inference from genome sequencing reads with novel k-mer signatures. Front Immunol. 2020;11:583013.
- Song L, Bai G, Liu XS, Li B, Li H. Efficient and accurate KIR and HLA genotyping with massively parallel sequencing data. Genome Res. 2023;33(6):923-931.
- Liao WW, Asri M, Ebler J, et al. A draft human pangenome reference. Nature. 2023;617:312-324.
- Byrska-Bishop M, Evani US, Zhao X, et al. High-coverage whole-genome sequencing of the expanded 1000 Genomes Project cohort including 602 trios. Cell. 2022;185(18):3426-3440.
- Jungwirth P. hla-wgs: HLA typing from whole-genome sequencing that states how many fields of each allele are certain. PJ Labs software report. 2026. doi:10.5281/zenodo.24367469.
- Logsdon GA, Ebert P, Audano PA, et al. Complex genetic variation in nearly complete human genomes. Nature. 2025;644:430-441.