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

Peter Jungwirth, MSc1✉

Affiliations and notes
  1. 1 PJ Labs, Austria
  2. Correspondence: info@pjlabs.dev
  3. Lead contact: Peter Jungwirth, MSc
Article information
Publication history
Published 29 November 2026
Peer review
not peer reviewed
Version
1.0.0
Licence
MIT
Version
1.0.0
Published
29 November 2026

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

01Reference, oncebuild-db: IPD-KIR release, gene and flank 31-mers02InputFASTQ, BAM or CRAM (chr19 KIR, chr19 ALT, unmapped)03Collectkeep pairs with 20 31-mers shared with a KIR allele04Copy number2 × gene 31-mers / flank 31-mers (medians), 16 groups05Allelesone mixture model over all copies of all genes06Checks on the readsnew coding sites, unsupported or incomplete alleles07Outputcopy number, allele per copy, resolution, A/B, log

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.

01Reference, oncebuild-db: IPD-KIR release, gene and flank 31-mers02InputFASTQ, BAM or CRAM (chr19 KIR, chr19 ALT, unmapped)03Collectkeep pairs with 20 31-mers shared with a KIR allele04Copy number2 × gene 31-mers / flank 31-mers (medians), 16 groups05Allelesone mixture model over all copies of all genes06Checks on the readsnew coding sites, unsupported or incomplete alleles07Outputcopy number, allele per copy, resolution, A/B, log
Figure 1. How kir-wgs works. Once per installation, the reference is built from the IPD-KIR release. For every sample, read pairs that share 31-mers with a KIR allele are collected, the copy number of every gene is estimated from its own 31-mers against the flanks, and one mixture model over all copies assigns the alleles. Every step and every decision is written to the run log.

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).

A Missed (in the truth, not reported)0102030KIR2DL117KIR2DL210KIR2DL300KIR2DL405KIR2DL575KIR2DP132KIR2DS100KIR2DS202KIR2DS300KIR2DS450KIR2DS520KIR3DL102KIR3DL288KIR3DL32029KIR3DP11414KIR3DS100B Extra (reported, not in the truth)0102030KIR2DL127KIR2DL200KIR2DL300KIR2DL449KIR2DL5615KIR2DP133KIR2DS101KIR2DS223KIR2DS302KIR2DS450KIR2DS521KIR3DL102KIR3DL279KIR3DL32029KIR3DP11413KIR3DS122kir-wgsT1K 1.0.10
Figure 2. Comparison with T1K. Distinct 3-digit alleles per gene in the 57 unseen samples that are in the truth but not reported (missed), and reported but not in the truth (extra). Truth: alleles of both assembled haplotypes.

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.

Table 1. 57 unseen HGSVC samples against both assembled haplotypes.
GeneCopy number rightCopies3 digits right (known protein)Certain, wrongExtra kir-wgsExtra T1K
KIR2DL153 / 578483 / 830 / 6427
KIR2DL256 / 573737 / 370 / 3200
KIR2DL357 / 577474 / 740 / 6100
KIR2DL455 / 57108101 / 1044 / 9649
KIR2DL557 / 573528 / 343 / 17615
KIR2DP157 / 579184 / 860 / 7233
KIR2DS157 / 571919 / 190 / 1701
KIR2DS257 / 573734 / 360 / 2723
KIR2DS357 / 571313 / 130 / 1002
KIR2DS455 / 579084 / 840 / 6150
KIR2DS557 / 572220 / 210 / 1821
KIR3DL157 / 579595 / 950 / 9402
KIR3DL257 / 57112104 / 1120 / 4079
KIR3DL357 / 5711494 / 1140 / 572029
KIR3DP157 / 5711498 / 1084 / 901413
KIR3DS155 / 571515 / 150 / 1522
All genes901 / 9121,060983 / 1,03511 / 7716796

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).

Table 2. 10 development samples at lower sequencing depth.
DepthCopy number rightCopies right at 3 digitsCertain at 3 digitsof these wrongDistinct alleles kir-wgs · extraDistinct alleles T1K · extra
30×160 / 1601691470153 / 162 · 12150 / 162 · 14
15×159 / 1601671150153 / 162 · 12148 / 162 · 17
10×159 / 160165650149 / 162 · 14144 / 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.

0153045607590Wall timeCPU timesecondskir-wgsT1K 1.0.10
Figure 3. Run time per run. Wall time and CPU time (user plus system) of all 15 runs per tool: reads of the KIR region of 5 samples, 3 runs each, 4 threads, the same machine and the same measuring command. Box: lower to upper quartile, line: median, whiskers: last value within 1.5 × the interquartile range. The text gives the median of the per-sample medians. Drawn from validation/results/timing/raw.tsv.

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.

Author contributions

P.J. conceived the project, developed the software, carried out the validation and wrote the report.

Declaration of interests

The author declares no competing interests.

Methods

Key resources table

ResourceVersionSource
Deposited data
IPD-KIR2.15.0ebi.ac.uk/ipd/kir
1000 Genomes, high-coverage genomesNYGC 30×internationalgenome.org
HPRC assemblies223 sampleshumanpangenome.org
HGSVC assembliesHGSVC3hgsvc.org
Software and algorithms
kir-wgs1.0.0github.com/pjlabsdev/kir-wgs
T1K1.0.10github.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 8

Truth 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

Software report (PDF, 5 pages) with all figures and tables; validation program and result tables in the repository under validation/.

References

  1. Parham P. MHC class I molecules and KIRs in human history, health and survival. Nat Rev Immunol. 2005;5(3):201-214.
  2. Uhrberg M, Valiante NM, Shum BP, et al. Human diversity in killer cell inhibitory receptor genes. Immunity. 1997;7(6):753-763.
  3. 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.
  4. Marsh SGE, Parham P, Dupont B, et al. Killer-cell immunoglobulin-like receptor (KIR) nomenclature report, 2002. Tissue Antigens. 2003;62(1):79-86.
  5. Robinson J, Waller MJ, Stoehr P, Marsh SGE. IPD: the Immuno Polymorphism Database. Nucleic Acids Res. 2005;33:D523-D526.
  6. 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.
  7. 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.
  8. 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.
  9. 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.
  10. 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.
  11. 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.
  12. Liao WW, Asri M, Ebler J, et al. A draft human pangenome reference. Nature. 2023;617:312-324.
  13. 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.
  14. 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.
  15. Logsdon GA, Ebert P, Audano PA, et al. Complex genetic variation in nearly complete human genomes. Nature. 2025;644:430-441.