Reference
Structures
GenLib.Individual
— Typestruct 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
.
GenLib.Pedigree
— Typestruct Pedigree{T}
A minimal structure wrapping an OrderedDict
with individuals accessed by ID.
GenLib.GenMatrix
— Typestruct GenMatrix
individuals::Vector{Int}
ancestors::Vector{Int}
meioses::Matrix{Int}
end
A matrix that goes with individuals as rows and ancestors as columns.
Available data
GenLib.genea140
— ConstantGenealogical 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)
GenLib.geneaJi
— ConstantA 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)
GenLib.pop140
— ConstantPopulation 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)
Create a pedigree
GenLib.genealogy
— Functiongenealogy(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)
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)
Extract a pedigree
GenLib.branching
— Functionbranching(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.
Output a pedigree
GenLib.genout
— Functiongenout(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)
Identify individuals
GenLib.founder
— Functionfounder(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)
GenLib.pro
— Functionpro(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)
GenLib.sibship
— Functionsibship(pedigree::Pedigree, IDs::Vector{Int}; halfSibling = true)
Return the siblings of specified individuals.
If halfSibling
is true
, half-siblings will be included.
GenLib.children
— Functionchildren(pedigree::Pedigree, ID::Int)
Return the children of an individual.
GenLib.findFounders
— FunctionfindFounders(pedigree::Pedigree, IDs::Vector{Int})
Return a vector of founders from whom the IDs
descend.
GenLib.findMRCA
— FunctionfindMRCA(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])
GenLib.ancestor
— Functionancestor(pedigree::Pedigree, ID::Int)
Return a vector of an individual's ancestors.
ancestor(pedigree::Pedigree, IDs::Vector{Int})
Return a vector of several individual's ancestors.
Describe
GenLib.nomen
— Functionnomen(pedigree::Pedigree)
Return the number of men in the pedigree.
GenLib.nowomen
— Functionnowomen(pedigree::Pedigree)
Return the number of women in the pedigree.
GenLib.noind
— Functionnoind(pedigree::Pedigree)
Return the number of individuals in the pedigree.
GenLib.depth
— Functiondepth(pedigree::Pedigree)
Return the maximum depth of a pedigree.
GenLib.completeness
— Functioncompleteness(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.
GenLib.rec
— Functionrec(pedigree::Pedigree, probandIDs::Vector{Int} = pro(genealogy),
ancestorIDs::Vector{Int} = founder(genealogy))
Return the number of descendants of each ancestor.
GenLib.occ
— Functionocc(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")
GenLib.findDistance
— FunctionfindDistance(pedigree::Pedigree, IDs::Vector{Int}, ancestorID::Int)
Return the distance between two individuals and their ancestor.
Compute
GenLib.gc
— Functiongc(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)
GenLib.phi
— Functionphi(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)
phi(individualᵢ::IndexedIndividual, individualⱼ::IndexedIndividual, Ψ::Matrix{Float64})
Return the kinship coefficient between two individuals given a matrix of the founders' kinships.
Adapted from Karigl, 1981, and Kirkpatrick et al., 2019.
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)
GenLib.phiMean
— Functionfunction phiMean(ϕ::Matrix{Float64})
Return the mean kinship from a given kinship matrix.
GenLib.f
— Functionf(pedigree::Pedigree, IDs::Vector{Int})
Return the coefficients of inbreeding of a vector of individuals.