Reference

Structures

GenLib.IndividualType
struct Individual <: AbstractIndividual
    ID::Int
    father::Union{Nothing, Individual}
    mother::Union{Nothing, Individual}
    children::Vector{Individual}
    sex::Int
    rank::Int
end

The unit structure of a GenLib.Pedigree.

source
GenLib.PedigreeType
struct Pedigree{T}

A minimal structure wrapping an OrderedDict with individuals accessed by ID.

source
GenLib.GenMatrixType
struct GenMatrix
    individuals::Vector{Int}
    ancestors::Vector{Int}
    meioses::Matrix{Int}
end

A matrix that goes with individuals as rows and ancestors as columns.

source

Available data

GenLib.genea140Constant

Genealogical information for 140 individuals from the Quebec Reference Sample.

According to the R GENLIB documentation, genea140 corresponds to "a genealogical corpus made of 41523 individuals from the province of Quebec, Canada. A total of 140 individuals have been sampled in seven sub-populations, listed in pop140, and their genealogies were reconstructed as far back as possible using the BALSAC population register and the Early Quebec Population Register."

Loading the Dataset

import GenLib as gen
genea140 = gen.genea140
ped = gen.genealogy(genea140)
source
GenLib.geneaJiConstant

A highly inbred pedigree.

According to the R GENLIB documentation, geneaJi corresponds to "a modified version of a pedigree of two Jicaque Indians studied by Chapman & Jacquard (1971)."

Loading the Dataset

import GenLib as gen
geneaJi = gen.geneaJi
ped = gen.genealogy(geneaJi)
source
GenLib.pop140Constant

Population of origin of the 140 Quebec samples.

According to the R GENLIB documentation, pop140 corresponds to "140 individuals from the genealogical corpus from Quebec (…) sampled from 7 different populations from 5 regions: Quebec City, Montreal, Saguenay, North Shore, Gaspesia. In Gaspesia we find 3 different populations: French-Canadians, Acadians and Loyalists."

Loading the Dataset

import GenLib as gen
pop140 = gen.pop140
pop = gen.population(pop140)
source

Create a pedigree

GenLib.genealogyFunction
genealogy(dataframe::DataFrame; sort::Bool = true)

Return an ordered pedigree of individuals from a DataFrame.

Example

import GenLib as gen
using DataFrames
inds = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
fathers = [0, 0, 0, 1, 1, 0, 3, 3, 6, 6]
mothers = [0, 0, 0, 2, 2, 0, 4, 4, 5, 5]
sexes = [1, 2, 1, 2, 2, 1, 2, 1, 1, 2]
df = DataFrame([inds, fathers, mothers, sexes], [:ind, :father, :mother, :sex])
ped = gen.genealogy(df)
source
genealogy(filename::String)

Return an ordered pedigree of individuals from a CSV file.

Example

import GenLib as gen
genea140 = gen.genea140
ped = gen.genealogy(genea140)
source

Extract a pedigree

GenLib.branchingFunction
branching(pedigree::Pedigree; pro::Union{Vector{Int}, Nothing} = nothing,
ancestors::Union{Vector{Int}, Nothing} = nothing)

Return a pedigree that filters individuals who are in the paths between select probands and ancestors.

source

Output a pedigree

GenLib.genoutFunction
genout(pedigree::Pedigree, sorted::Bool = false)

Return a pedigree as a DataFrame.

If sorted is false (the default), then the individuals will appear in the same order as in the pedigree.

If sorted is true, then the individuals will appear in alphabetical ID order.

import GenLib as gen
geneaJi = gen.geneaJi
ped = gen.genealogy(geneaJi)
gen.genout(ped)
source

Identify individuals

GenLib.founderFunction
founder(pedigree::Pedigree)

Return a vector of founder IDs in alphabetical order.

Example

import GenLib as gen
genea140 = gen.genea140
ped = gen.genealogy(genea140)
founders = gen.founder(ped)
source
GenLib.proFunction
pro(pedigree::Pedigree)

Return a vector of proband IDs in alphabetical order.

Example

import GenLib as gen
genea140 = gen.genea140
ped = gen.genealogy(genea140)
probands = gen.pro(ped)
source
GenLib.sibshipFunction
sibship(pedigree::Pedigree, IDs::Vector{Int}; halfSibling = true)

Return the siblings of specified individuals.

If halfSibling is true, half-siblings will be included.

source
GenLib.childrenFunction
children(pedigree::Pedigree, ID::Int)

Return the children of an individual.

source
GenLib.findFoundersFunction
findFounders(pedigree::Pedigree, IDs::Vector{Int})

Return a vector of founders from whom the IDs descend.

source
GenLib.findMRCAFunction
findMRCA(pedigree::Pedigree, IDs::Vector{Int})

Return a GenLib.GenMatrix of meioses between individuals and their most recent common ancestors (MRCAs).

Example

import GenLib as gen
genea140 = gen.genea140
ped = gen.genealogy(genea140)
pro = gen.pro(ped)
pro1 = pro[1]
pro2 = pro[2]
genMatrix = gen.findMRCA(ped, [pro1, pro2])
source
GenLib.ancestorFunction
ancestor(pedigree::Pedigree, ID::Int)

Return a vector of an individual's ancestors.

source
ancestor(pedigree::Pedigree, IDs::Vector{Int})

Return a vector of several individual's ancestors.

source

Describe

GenLib.nomenFunction
nomen(pedigree::Pedigree)

Return the number of men in the pedigree.

source
GenLib.nowomenFunction
nowomen(pedigree::Pedigree)

Return the number of women in the pedigree.

source
GenLib.noindFunction
noind(pedigree::Pedigree)

Return the number of individuals in the pedigree.

source
GenLib.depthFunction
depth(pedigree::Pedigree)

Return the maximum depth of a pedigree.

source
GenLib.completenessFunction
completeness(pedigree::Pedigree; pro::Vector{Int} = pro(pedigree),
genNo::Vector{Int} = Int[], type::String = "MEAN")

Return a dataframe with the completeness at each generation (one row per generation).

genNo: A vector of the generations to output. The probands are at generation 0.

type: If "MEAN", the mean completeness for each generation. If "IND", the completeness for each generation for each proband.

source
GenLib.recFunction
rec(pedigree::Pedigree, probandIDs::Vector{Int} = pro(genealogy),
ancestorIDs::Vector{Int} = founder(genealogy))

Return the number of descendants of each ancestor.

source
GenLib.occFunction
occ(pedigree::Pedigree; pro::Vector{Int} = pro(genealogy),
ancestors::Vector{Int} = founder(genealogy), typeOcc::String = "IND")

Return a matrix of ancestors' occurrences.

If typeOcc is "IND" (default), then the matrix corresponds to the occurrence per individual. If typeOcc is "TOTAL", then the matrix corresponds to the total occurrence.

Example

import GenLib as gen
geneaJi = gen.geneaJi
ped = gen.genealogy(geneaJi)
occ = gen.occ(ped, typeOcc = "TOTAL")
source
GenLib.findDistanceFunction
findDistance(pedigree::Pedigree, IDs::Vector{Int}, ancestorID::Int)

Return the distance between two individuals and their ancestor.

source

Compute

GenLib.gcFunction
gc(pedigree::Pedigree; pro::Vector{Int} = pro(pedigree),
    ancestors::Vector{Int} = founder(pedigree))

Return a matrix of the genetic contribution of each ancestor (columns) to each proband (rows).

Example

import GenLib as gen
genea140 = gen.genea140
ped = gen.genealogy(genea140)
contributions = gen.gc(ped)
source
GenLib.phiFunction
phi(individualᵢ::Individual, individualⱼ::Individual)

Return the kinship coefficient between two individuals.

Adapted from Karigl, 1981.

Example

import GenLib as gen
genea140 = gen.genea140
ped = gen.genealogy(genea140)
pro1 = ped[10033]
pro2 = ped[113470]
gen.phi(pro1, pro2)
source
phi(individualᵢ::IndexedIndividual, individualⱼ::IndexedIndividual, Ψ::Matrix{Float32})

Return the kinship coefficient between two individuals given a matrix of the founders' kinships.

Adapted from Karigl, 1981, and Kirkpatrick et al., 2019.

source
phi(pedigree::Pedigree, probandIDs::Vector{Int} = pro(pedigree);
    verbose::Bool = false)

Return a square matrix of pairwise kinship coefficients between probands.

If no probands are given, return the square matrix for all probands in the pedigree.

The algorithm computes pairwise kinships in parallel, a hybrid between the algorithms of Karigl, 1981, and Kirkpatrick et al., 2019.

If verbose is true, print the information about the cut vertices. If compute is true (the default), compute the kinship matrix. If it is false, only print the information about the cut vertices.

Example

import GenLib as gen
geneaJi = gen.geneaJi
ped = gen.genealogy(geneaJi)
gen.phi(ped)
source
GenLib.phiMeanFunction
function phiMean(ϕ::Matrix{Float32})

Return the mean kinship from a given kinship matrix.

source
function phiMean(ϕ::KinshipMatrix)

Return the mean kinship from a given sparse kinship matrix.

source
GenLib.fFunction
f(pedigree::Pedigree, IDs::Vector{Int})

Return the coefficients of inbreeding of a vector of individuals.

source