marker_model: Marker model (S3)

View source: R/marker_model.R

marker_modelR Documentation

Marker model (S3)

Description

Constructor for a single-marker forensic genetic model. Bundles the pedigree, the marker identifier, the population allele frequencies, the mutation model, and (optionally) a linkage descriptor. The resulting object is the unit consumed by the per-marker engines (per_marker_kl, per_marker_lr_dist) that arrive in later milestones.

This is the public entry point for the F1 reference engine. The constructor only validates and stores its inputs; the actual joint CPT construction is done downstream.

Usage

marker_model(
  ped,
  marker_id,
  freqs,
  mutation = list(model = "none", rate = 0),
  linkage = NULL,
  tol = 1e-06
)

Arguments

ped

A pedtools::ped object describing the pedigree. Singletons and pedList objects are not accepted at this stage.

marker_id

Character scalar. Identifier used to label the marker (e.g. "D3S1358"). When ped already carries a marker with this name, downstream engines will read the genotypes of typed individuals from it; otherwise the model represents the prospective situation prior to typing.

freqs

Named numeric vector of population allele frequencies. Names are allele labels, values must lie in ⁠[0, 1]⁠ and sum to 1 within tol. At least two alleles are required.

mutation

List describing the mutation model. Required field model is one of "none", "equal", "stepwise", "asymmetric". For "none" no further fields are needed; for the other models a numeric rate in ⁠[0, 1)⁠ is required. "stepwise" additionally accepts ratio (geometric step ratio in ⁠(0, 1)⁠); "asymmetric" additionally accepts ratio and bias (u parameter, in ⁠[0, 1]⁠). Defaults to list(model = "none", rate = 0).

linkage

Either NULL (default; unlinked marker) or a list with fields partner (character, the marker identifier of the linked partner) and theta (recombination fraction in ⁠[0, 0.5]⁠). Linkage support is wired in milestone F5; F1 only validates the structure.

tol

Numeric tolerance used when checking that freqs sums to 1. Defaults to 1e-6.

Value

An object of class "marker_model" carrying the validated inputs as components ped, marker_id, freqs, mutation, linkage, and alleles (names(freqs)).

Examples

if (requireNamespace("pedtools", quietly = TRUE)) {
  ped <- pedtools::nuclearPed(1)
  freqs <- c("12" = 0.2, "13" = 0.3, "14" = 0.5)
  mm <- marker_model(
    ped = ped,
    marker_id = "M1",
    freqs = freqs,
    mutation = list(model = "equal", rate = 1e-3)
  )
  print(mm)
}

mispitools documentation built on Aug. 26, 2026, 1:08 a.m.