Package 'KLINK'

Title: Kinship Analysis with Linked Markers
Description: A 'shiny' application for forensic kinship testing, based on the 'pedsuite' R packages. 'KLINK' is closely aligned with the (non-R) software 'Familias' and 'FamLink', but offers several unique features, including visualisations and automated report generation. The calculation of likelihood ratios supports pairs of linked markers, and all common mutation models.
Authors: Magnus Dehli Vigeland [aut, cre]
Maintainer: Magnus Dehli Vigeland <[email protected]>
License: GPL (>= 3)
Version: 1.0.3.9002
Built: 2025-02-19 15:23:42 UTC
Source: https://github.com/magnusdv/klink

Help Index


Add totals to a data frame with LR results

Description

Adds a row with totals for the specified columns, formed by multiplying the values in each column.

Usage

addTotals(x, cols = c("LRlinked", "LRnolink", "LRnomut"))

Arguments

x

A data frame with LR results.

cols

A vector of column names, by default c("LRlinked", "LRnolink", "LRnomut")

Details

Note that for the multiplication to respect linked markers, the input table should include LR results for only one marker in each linkage group. This is the the case e.g. if the input was produced by linkedLR().

Value

The same data frame, but with an added row of total LRs.

Examples

res = linkedLR(paternity, KLINK::LINKAGEMAP) |> addTotals()

# No effect of linkage in this case:
stopifnot(all.equal(res[nrow(res), "LRlinked"],
                    res[nrow(res), "LRnolink"]))

Identify linked marker pairs

Description

This function returns a "maximal" set of disjoint pairs of linked markers, given a genetic marker map and a subset of the markers included in the map. The pairs are identified in a greedy manner, successively choosing the closest markers on each chromosome.

Usage

getLinkedPairs(markers, linkageMap, maxdist = Inf)

Arguments

markers

A character vector containing marker names.

linkageMap

A data frame with columns including Marker, Chr and cM.

maxdist

A positive number indicating the maximum linkage distance (in cM). Markers further apart than this are considered unlinked.

Value

A list of character vectors, each containing two marker names.

Examples

# Example using the built-in map of 50 STR markers
map = KLINK::LINKAGEMAP

getLinkedPairs(map$Marker, map, maxdist = 25)

Dataset for a case involving a putative half sibling.

Description

A list of two pedigrees forming opposing hypotheses about three individuals:

Usage

halfsib

Format

A list of two ped objects, named H1 and H2.

Details

  • H1: A and B are full sibs, and C is their half brother

  • H2: A and B are full siblings, and C is unrelated to them

The individuals are typed with 50 markers, but some genotypes are missing.

Examples

library(pedtools)
plotPedList(halfsib, hatched = typedMembers)
markerSummary(halfsib)
linkedLR(halfsib, KLINK::LINKAGEMAP)

Launch KLINK

Description

This launches the KLINK app. runKLINK() is a synonym for launchApp(), but with an additional argument version.

Usage

launchApp()

runKLINK(version = NULL)

Arguments

version

A character, e.g. "1.0.0". If the installed version of KLINK differs from this, the program aborts with an error.

Value

No return value, called for side effects.

Examples

## Not run: 
launchApp()

## End(Not run)

Built-in linkage map

Description

A genetic map including 50 autosomal STR markers.

Usage

LINKAGEMAP

Format

A data frame with 50 rows and 4 columns: Marker, Kit, Chr, cM.


LR with pairwise linked markers

Description

This function does the main LR calculations of the KLINK app.

Usage

linkedLR(
  pedigrees,
  linkageMap,
  linkedPairs = NULL,
  maxdist = Inf,
  markerData = NULL,
  mapfun = "Kosambi",
  lumpSpecial = TRUE,
  verbose = TRUE,
  debug = FALSE
)

Arguments

pedigrees

A list of two pedigrees.

linkageMap

A data frame with columns including Marker, Chr and cM.

linkedPairs

A list of marker pairs. If not supplied, calculated as getLinkedPairs(markerData$Marker, linkageMap, maxdist = maxdist).

maxdist

A number, passed onto getLinkedMarkers() if linkedPairs is NULL.

markerData

A data frame with marker data, typically the output of markerSummary(pedigrees).

mapfun

Name of the map function to be used; either "Haldane" or "Kosambi" (default).

lumpSpecial

A logical, by default TRUE.

verbose

A logical, by default TRUE.

debug

A logical, by default FALSE.

Value

A data frame with detailed LR results.

Examples

linkedLR(paternity, KLINK::LINKAGEMAP)

# For testing
# .linkedLR(paternity, markerpair = c("SE33", "D6S474"), linkageMap = LINKAGEMAP)

Load .fam file

Description

Load .fam file

Usage

loadFamFile(path, fallbackModel = "equal", withParams = FALSE)

Arguments

path

The path to a .fam file.

fallbackModel

The name of a mutation model; passed on to pedFamilias::readFam().

withParams

A logical indicating if the Familias parameters should be included in the output. (See pedFamilias::readFam().)

Value

A list of two ped objects.

Examples

fam = system.file("extdata/halfsib-test.fam", package = "KLINK")
peds = loadFamFile(fam)
pedtools::plotPedList(peds)

Load genetic map

Description

Load genetic map

Usage

loadMap(path)

Arguments

path

Path to a map file, which should contain columns Marker, Chr, cM. (Slight variations are allowed.)

Value

A data frame.

Examples

tmp = tempfile(fileext = ".map")
map1 = as.data.frame(KLINK::LINKAGEMAP)
write.table(map1, tmp, sep = "\t", quote = FALSE, row.names = FALSE)

map2 = loadMap(tmp)
stopifnot(all.equal(map1, map2))

Generate table of marker data

Description

Generate table of marker data

Usage

markerSummary(pedigrees, replaceNames = FALSE)

Arguments

pedigrees

A list of 2 pedigrees.

replaceNames

A logical, indicating if IDs should be changed to Person1, Person2, ...

Value

A data frame.

Examples

markerSummary(paternity)

Parse XML file associated with .fam file

Description

Parse XML file associated with .fam file

Usage

parseXML(xml)

Arguments

xml

Path to a file with extension .xml.

Examples

# (No example included)

Dataset for a paternity case

Description

A list of two pedigrees forming the hypotheses in a paternity case: H1 (AF is the father of CH) and H2 (unrelated). AF and CH are genotyped with 11 markers, with allele frequencies from forrel::NorwegianFrequencies.

Usage

paternity

Format

A list of two pedigrees, named H1 and H2.

Examples

pedtools::plotPedList(paternity, marker = "SE33")
markerSummary(paternity)

forrel::kinshipLR(paternity)

Dataset for a full vs half sibship case

Description

A list of two pedigrees forming opposing hypotheses about two individuals NN1 and NN2: FS (full siblings) vs. HS (half siblings). Both individuals are genotyped with the 23 markers included in the Fusion 6C kit. Three pairs of markers are linked:

Usage

sibship

Format

A list of two ped objects, named FS and HS.

Details

  • TPOX and D2S441

  • D5S818 and CSF1PO

  • vWA and D12S391

Examples

library(pedtools)
plotPedList(sibship, hatched = typedMembers)
markerSummary(sibship)
linkedLR(sibship, KLINK::LINKAGEMAP)

Write data and results to Excel

Description

This function produces an Excel document containing the genotype data and various LR tables.

Usage

writeResult(
  resultTable,
  pedigrees,
  linkageMap,
  markerData,
  outfile,
  notes = NULL,
  famname = NULL,
  hideEmpty = FALSE,
  settings = NULL,
  XML = NULL
)

Arguments

resultTable

A data frame.

pedigrees

A list of two ped objects.

linkageMap

A data frame.

markerData

A data frame.

outfile

The output file name.

notes

A character vector.

famname

The name of the input .fam file.

hideEmpty

A logical, indicating if untyped markers should be dropped.

settings

A list of KLINK settings to be included in the output

XML

Optional data from .xml file.

Examples

# Built-in dataset `paternity`
peds = paternity
map = LINKAGEMAP
mdata = markerSummary(peds)

# Result table
LRtab = linkedLR(pedigrees = peds, linkageMap = map, markerData = mdata, verbose = FALSE)

# Write to excel
tmp = paste0(tempfile(), ".xlsx")
writeResult(LRtab,
            pedigrees = peds,
            linkageMap = map,
            markerData = mdata,
            outfile = tmp)

# openxlsx::openXL(tmp)