Predict KIR genotypes for a set of samples using a trained PONG2 attribute bagging model. This is the core prediction function used by the pong2 impute CLI command.

kirPredict(
  object,
  snp,
  cl = FALSE,
  type = c("response+dosage", "response", "prob", "response+prob"),
  vote = c("prob", "majority"),
  allele.check = TRUE,
  match.type = c("Position", "Pos+Allele", "RefSNP+Position", "RefSNP"),
  same.strand = FALSE,
  verbose = TRUE,
  verbose.match = TRUE
)

Arguments

object

a PONG2 model object of class hlaAttrBagClass as returned by kirParallelAttrBagging()

snp

a SNP genotype object of class hlaSNPGenoClass containing the target samples to impute

cl

a cluster object for parallel computation, or FALSE (default) for single-threaded prediction

type

character; type of prediction output. One of: "response+dosage" (default; predicted alleles + dosage scores), "response" (predicted alleles only), "prob" (posterior probabilities only), "response+prob" (predicted alleles + posterior probabilities)

vote

character; voting method for ensemble classifiers. One of "prob" (default; probability-weighted voting) or "majority" (majority vote)

allele.check

logical; if TRUE (default), check and validate allele names against the model

match.type

character; SNP matching method. One of "Position" (default), "Pos+Allele", "RefSNP+Position", or "RefSNP"

same.strand

logical; if TRUE, assume SNPs are on the same strand (default: FALSE)

verbose

logical; if TRUE (default), print progress messages

verbose.match

logical; if TRUE (default), print SNP matching summary

Value

An object of class hlaAlleleClass containing KIR imputation results. The object includes:

value

data frame with columns sample.id, allele1, allele2, and prob (posterior probability of the best call)

dosage

numeric matrix of allele dosage scores (samples x alleles); NULL if type = "response"

postprob

numeric matrix of posterior probabilities (alleles x samples); NULL unless type = "response+prob" or "prob"

Samples with posterior probability below the call threshold (CT) are assigned NA for both alleles.

Examples

# Load example data
data(PONG2_example)
#> Warning: data set ‘PONG2_example’ not found

# Load model from object
model <- hlaModelFromObj(example_mobj)

# Predict KIR genotypes
pred <- kirPredict(
  object  = model,
  snp     = example_snp,
  type    = "response+dosage",
  verbose = FALSE
)
#> Error in .C("PONG2_Predict_Resp_dosage", object$model, as.integer(snp),     n.samp, as.integer(vote_method), as.logical(verbose), H1 = integer(n.samp),     H2 = integer(n.samp), prob = double(n.samp), postprob = matrix(NaN,         nrow = n.hla * (n.hla + 1)/2, ncol = n.samp), err = integer(1),     NAOK = TRUE, PACKAGE = "PONG2"): "PONG2_Predict_Resp_dosage" not available for .C() for package "PONG2"

# View results
head(pred$value)
#>   sample.id     allele1     allele2      prob
#> 1        S1 KIR3DL1*002 KIR3DL1*015 0.4767310
#> 2        S2 KIR3DL1*007 KIR3DL1*007 0.4504548
#> 3        S3 KIR3DL1*002 KIR3DL1*015 0.6123777
#> 4        S4 KIR3DL1*002 KIR3DL1*015 0.6277634
#> 5        S5 KIR3DL1*002 KIR3DL1*005 0.6243871
#> 6        S6 KIR3DL1*002 KIR3DL1*002 0.7030016

# Clean up
hlaClose(model)