Skip to content
@deckyard/forensicgenetics

forensicgenetics cheatsheet

Every export of @deckyard/forensicgenetics. The module pages (forensicgenetics, kinship, pedigree, lineage) list each module's rules and errors.

jennifer
import "@deckyard/forensicgenetics/" as forensicgenetics;
import "@deckyard/forensicgenetics/kinship.j" as kinship;
import "@deckyard/forensicgenetics/lineage.j" as lineage;
import "@deckyard/forensicgenetics/pedigree.j" as pedigree;

tools/check-docs.sh checks every signature, field and constant value on this page against the code.

forensicgenetics

FunctionReturnsDoes
forensicgenetics.alleleValue(allele)floatRepeat count of an allele label; throws if not numeric.
forensicgenetics.isNumericAllele(allele)boolWhether the label is digits with at most one ..
forensicgenetics.db(name)FrequencyDbEmpty database.
forensicgenetics.withLocus(fdb, locus, n, freqs)FrequencyDbCopy with one locus added or replaced; validates the table.
forensicgenetics.combineFrequencies(dbs, name)FrequencyDbTables pooled by allele counts over their shared loci.
forensicgenetics.loci(fdb)list of stringLocus names, insertion order.
forensicgenetics.hasLocus(fdb, locus)boolWhether the locus is present.
forensicgenetics.sampleSize(fdb, locus)intN at the locus; 0 if unknown.
forensicgenetics.minFrequency(fdb, locus)float5/(2N); 0.0 when N is 0.
forensicgenetics.alleleFrequency(fdb, locus, allele)floatFrequency floored at 5/(2N), capped at 1.
forensicgenetics.genotype(locus, a, b)GenotypeGenotype with the pair in canonical order.
forensicgenetics.isHomozygous(g)boolWhether both alleles are equal.
forensicgenetics.alleles(g)list of stringDistinct alleles: one or two labels.
forensicgenetics.profile(id, genotypes)ProfileProfile from one genotype per locus.
forensicgenetics.withGenotype(p, g)ProfileCopy with the genotype set at its locus.
forensicgenetics.profileLoci(p)list of stringLocus names, insertion order.
forensicgenetics.hasGenotype(p, locus)boolWhether the profile is typed at the locus.
forensicgenetics.genotypeAt(p, locus)GenotypeGenotype at the locus; throws if untyped.
forensicgenetics.commonLoci(fdb, p)list of stringLoci both cover, in profile order.
forensicgenetics.restrict(p, keep)ProfileCopy keeping only the named loci.
forensicgenetics.genotypeFrequency(fdb, g, theta)floatNRC II rec. 4.2 genotype frequency, capped at 1.
forensicgenetics.randomMatchProbability(fdb, p, theta)floatRMP: product of genotypeFrequency over the profile.
forensicgenetics.log10RandomMatchProbability(fdb, p, theta)floatlog10 RMP, summed per locus.
forensicgenetics.matchLikelihoodRatio(fdb, p, theta)float1 / RMP.
forensicgenetics.randomMatchProbabilityAcross(dbs, weights, p, theta)floatΣ w_i · RMP_i over candidate populations.
forensicgenetics.matchLikelihoodRatioAcross(dbs, weights, p, theta)float1 / randomMatchProbabilityAcross.
forensicgenetics.mixture(id, observed)MixtureMixture; repeated alleles collapse.
forensicgenetics.mixtureLoci(m)list of stringLocus names, insertion order.
forensicgenetics.inclusionProbability(fdb, locus, observed)floatPI = (Σ p)², sum capped at 1.
forensicgenetics.exclusionProbability(fdb, locus, observed)floatPE = 1 - PI.
forensicgenetics.cpi(fdb, m)floatCPI: product of PI over loci.
forensicgenetics.cpe(fdb, m)floatCPE = 1 - CPI.
forensicgenetics.isIncluded(p, m)boolWhether p is not excluded at any shared locus.
ConstantTypeValueMeans
forensicgenetics.THETA_GENERALfloat0.01NRC II, broad well-mixed population.
forensicgenetics.THETA_ISOLATEDfloat0.03NRC II, small, isolated or endogamous population.
forensicgenetics.THETA_NONEfloat0.0Plain product rule; not for casework.
forensicgenetics.MIN_ALLELE_COUNTfloat5.0The 5 in 5/(2N).
forensicgenetics.MAX_FREQUENCY_SUMfloat1.05Largest locus frequency sum withLocus accepts.

forensicgenetics.LocusFrequencies

One locus of a reference table.

FieldHolds
locus as stringthe locus name, e.g. "D3S1358"
n as intindividuals typed (2N alleles); 0 if unknown
alleles as map of string to floatallele label -> published frequency

forensicgenetics.FrequencyDb

A reference allele-frequency table, keyed by locus.

FieldHolds
name as stringthe population or dataset label
loci as map of string to LocusFrequencieslocus name -> its frequencies

forensicgenetics.Genotype

An unordered allele pair at one autosomal locus; build with genotype.

FieldHolds
locus as stringthe locus name
a as stringthe lower allele in canonical order
b as stringthe higher allele; equal to a for a homozygote

forensicgenetics.Profile

A single-source STR profile: one genotype per locus.

FieldHolds
id as stringa caller-chosen label for the profile
loci as map of string to Genotypelocus name -> the genotype seen there

forensicgenetics.Mixture

The alleles seen at each locus of a mixed stain.

FieldHolds
id as stringa caller-chosen label
loci as map of string to list of stringlocus name -> the alleles observed

kinship

FunctionReturnsDoes
kinship.relationship(name, k0, k1, k2)RelationshipRelationship from (k0, k1, k2); validated.
kinship.transmissionProbability(g, allele)floatMendelian transmission: 1.0, 0.5 or 0.0.
kinship.mutationModel(rate, decay)MutationModelStepwise model; rate and decay in [0, 1).
kinship.withLocusRate(model, locus, rate)MutationModelCopy with a per-locus rate.
kinship.mutationProbability(model, locus, source, target)floatP(source transmitted as target).
kinship.jointGenotypeProbability(db, ga, gb, rel)floatk0·P(Ga)P(Gb) + k1·T1 + k2·[Ga==Gb]·P(Ga).
kinship.kinshipLRAt(db, ga, gb, rel, alt)floatOne-locus LR, rel over alt.
kinship.pairLoci(db, a, b)list of stringLoci both profiles and the table share, in a's order.
kinship.kinshipLR(a, b, rel, db)floatLR of rel against UNRELATED over pairLoci.
kinship.kinshipLRAgainst(a, b, rel, alt, db)floatLR of rel against alt over pairLoci.
kinship.paternityIndexAt(db, mother, child, father, model)floatOne-locus PI, X / Y.
kinship.trioLoci(db, mother, child, father)list of stringLoci all three and the table share, in the child's order.
kinship.paternityIndex(mother, child, allegedFather, db)floatCPI under DEFAULT_MUTATION.
kinship.paternityIndexWith(mother, child, allegedFather, db, model)floatCPI under model.
kinship.inconsistentLoci(mother, child, allegedFather, db)list of stringLoci with PI 0 under NO_MUTATION.
kinship.probabilityOfPaternity(cpi)floatW = CPI / (CPI + 1), prior 0.5.
kinship.probabilityOfPaternityPrior(cpi, prior)floatW under a prior in (0, 1).
ConstantTypeValueMeans
kinship.UNRELATEDRelationshipRelationship{name: "unrelated", k0: 1.0, k1: 0.0, k2: 0.0}(1, 0, 0); the default alternative.
kinship.PARENT_CHILDRelationshipRelationship{name: "parent-child", k0: 0.0, k1: 1.0, k2: 0.0}(0, 1, 0).
kinship.FULL_SIBLINGSRelationshipRelationship{name: "full siblings", k0: 0.25, k1: 0.5, k2: 0.25}(1/4, 1/2, 1/4).
kinship.HALF_SIBLINGSRelationshipRelationship{name: "half siblings", k0: 0.5, k1: 0.5, k2: 0.0}(1/2, 1/2, 0).
kinship.GRANDPARENTRelationshipRelationship{name: "grandparent", k0: 0.5, k1: 0.5, k2: 0.0}(1/2, 1/2, 0), as half siblings.
kinship.AVUNCULARRelationshipRelationship{name: "avuncular", k0: 0.5, k1: 0.5, k2: 0.0}(1/2, 1/2, 0), as half siblings.
kinship.FIRST_COUSINSRelationshipRelationship{name: "first cousins", k0: 0.75, k1: 0.25, k2: 0.0}(3/4, 1/4, 0).
kinship.IDENTICALRelationshipRelationship{name: "identical", k0: 0.0, k1: 0.0, k2: 1.0}(0, 0, 1): same person or monozygotic twins.
kinship.NO_MUTATIONMutationModelMutationModel{rate: 0.0, decay: 0.0, perLocus: {}}Mendelian only.
kinship.DEFAULT_MUTATIONMutationModelMutationModel{rate: 0.002, decay: 0.1, perLocus: {}}Placeholder, not a published rate.

kinship.Relationship

A relationship, as its IBD coefficients.

FieldHolds
name as stringa label for the relationship
k0 as floatthe probability of sharing no allele identical by descent
k1 as floatthe probability of sharing exactly one
k2 as floatthe probability of sharing both

kinship.MutationModel

A stepwise STR mutation model. A k-step change in one direction has probability rate · (1 - decay) · decay^(k-1) / 2.

FieldHolds
rate as floatthe per-locus, per-meiosis mutation rate
decay as floatthe geometric decay per additional repeat step, in [0, 1)
perLocus as map of string to floatlocus -> rate, overriding rate

lineage

FunctionReturnsDoes
lineage.haplotypeFrequency(k, n)floatPoint estimate k / N; not for reporting.
lineage.haplotypeUpperBound(k, n, confidence)floatClopper-Pearson one-sided upper bound.
lineage.lineageMatchProbability(k, n)floatThe bound at DEFAULT_CONFIDENCE.
lineage.lineageLikelihoodRatio(k, n)float1 / lineageMatchProbability.
lineage.parseDifference(text)DifferenceParse 16189C, 315.1C, 249d and variants.
lineage.formatDifference(d)stringDesignation string.
lineage.mtHaplotype(id, ranges, text)MtHaplotypeHaplotype from whitespace-separated designations.
lineage.mtDesignations(h)list of stringDesignations in position order.
lineage.mtMatches(a, b)boolSame differences; ranges ignored.
lineage.mtDistance(a, b)intSize of the symmetric difference.
lineage.mtRangesAgree(a, b)boolSame ranges, any order.
lineage.align(reference, sample, refStart)list of DifferenceNeedleman-Wunsch differences, indels 3'.
lineage.mtHaplotypeFrom(id, reference, sample, refStart)MtHaplotypealign plus the covered range.
lineage.yHaplotype(id, loci)YHaplotypeY haplotype; alleles validated.
lineage.yLoci(h)list of stringLocus names, insertion order.
lineage.ySharedLoci(a, b)list of stringShared loci, in a's order.
lineage.yMatches(a, b)boolExact at every shared locus.
lineage.yStepDistance(a, b)floatSummed repeat differences over shared loci.
lineage.yMatchesWithin(a, b, steps)boolyStepDistance <= steps.
ConstantTypeValueMeans
lineage.DEFAULT_CONFIDENCEfloat0.95One-sided level of lineageMatchProbability.
lineage.MAX_ALIGN_LENGTHint5000Longest sequence align accepts, in bases.

lineage.Difference

One difference from the reference sequence, in rCRS nomenclature.

FieldHolds
position as intthe 1-based reference position
insertion as int0 for a substitution or deletion; 1, 2, ... for the n-th base inserted after position
base as stringthe observed base; "" for a deletion
kind as string"sub", "ins" or "del"

lineage.MtHaplotype

The sequenced ranges and the differences from the reference within them.

FieldHolds
id as stringa caller-chosen label
ranges as list of stringthe sequenced regions, e.g. ["16024-16365", "73-340"]
differences as list of Differencethe differences from the reference, in ascending position order

lineage.YHaplotype

A repeat count per locus; multi-copy loci as "11,14" or "11/14".

FieldHolds
id as stringa caller-chosen label
loci as map of string to stringlocus name -> allele designation(s)

pedigree

FunctionReturnsDoes
pedigree.pedigree(name)PedigreeEmpty pedigree.
pedigree.withFounder(ped, id, sex)PedigreeCopy with a founder added.
pedigree.withChild(ped, id, sex, father, mother)PedigreeCopy with a child of father and mother.
pedigree.members(ped)list of stringMember ids, insertion order.
pedigree.hasMember(ped, id)boolWhether the id is a member.
pedigree.personOf(ped, id)PersonThe member; throws if absent.
pedigree.isFounder(ped, id)boolWhether the member has no parents in the pedigree.
pedigree.childrenOf(ped, id)list of stringChildren's ids, member order.
pedigree.validate(ped)-Throws on a missing parent, an ancestor cycle or a loop.
pedigree.isSimple(ped)boolNon-throwing validate.
pedigree.locusLikelihood(ped, genotypes, db, locus)floatLikelihood at one locus, untyped members summed out.
pedigree.pedigreeLoci(ped, profiles, db)list of stringLoci the table covers and a member is typed at.
pedigree.pedigreeLikelihood(ped, profiles, db)floatProduct of locusLikelihood over pedigreeLoci.
pedigree.log10PedigreeLikelihood(ped, profiles, db)floatlog10 likelihood, summed per locus.
pedigree.pedigreeLR(numerator, denominator, profiles, db)floatLR of two pedigrees, locus by locus.
pedigree.typedMembers(ped, profiles)list of stringMembers with a non-empty profile.

pedigree.Person

One member. A founder has "" for both parents.

FieldHolds
id as stringthe member's identifier, unique within the pedigree
sex as string"m", "f" or ""; not used by the calculation
father as stringthe father's id, or "" for a founder
mother as stringthe mother's id, or "" for a founder

pedigree.Pedigree

A pedigree: a set of members and the parentages joining them.

FieldHolds
name as stringa label for the pedigree, used in error messages
members as map of string to Personid -> member