| Title: | Forensic Bayesian Networks |
|---|---|
| Description: | Open-source package for computing likelihood ratios in kinship testing and human identification cases (Chernomoretz et al. (2021) <doi:10.1016/j.fsir.2020.100132>). It has the core function of the software GENis, developed by Fundación Sadosky. It relies on a Bayesian Networks framework and is particularly well suited to efficiently perform large-size queries against databases of missing individuals (Darwiche (2009) <doi:10.1017/CBO9780511811357>). |
| Authors: | Franco Marsico [aut, cre], Ariel Chernomoretz [aut] |
| Maintainer: | Franco Marsico <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.0.3 |
| Built: | 2026-10-23 11:13:52 UTC |
| Source: | https://github.com/marsicofl/fbnet |
STRs allelic frequencies from Argentina.
Argentina_STRsArgentina_STRs
A data frame with allele frequencies
Initialized bayesian network.
bnetbnet
Initialized bayesian network, based on toyped.
buildBN: a function for building the bayesian network.
buildBN(pbn, QP)buildBN(pbn, QP)
pbn |
A bayesian network for pedigree object with information of the genotyped members. The ped object must be in Familias format. |
QP |
Query Persons Ids |
A bayesian network based on pedigree evidence and QP definition.
## Not run: # Modern entry point via pedtools (recommended): library(pedtools); library(forrel) ped <- linearPed(2) ped <- setMarkers(ped, locusAttributes = NorwegianFrequencies[1:2]) ped <- profileSim(ped, N = 1, ids = 2, seed = 1) pbn <- from_pedtools(ped, QP = "5") bnet <- buildBN(pbn, QP = "5") ## End(Not run)## Not run: # Modern entry point via pedtools (recommended): library(pedtools); library(forrel) ped <- linearPed(2) ped <- setMarkers(ped, locusAttributes = NorwegianFrequencies[1:2]) ped <- profileSim(ped, N = 1, ids = 2, seed = 1) pbn <- from_pedtools(ped, QP = "5") bnet <- buildBN(pbn, QP = "5") ## End(Not run)
buildCPTs: a function for building conditional probability tables based on pedigree bayesian network.
buildCPTs( bn, bNodePrunning = TRUE, bStateRemoval = TRUE, bStateRemoval2 = TRUE, lumpingParameter = NULL, renorm = "row-wise", verbose = FALSE )buildCPTs( bn, bNodePrunning = TRUE, bStateRemoval = TRUE, bStateRemoval2 = TRUE, lumpingParameter = NULL, renorm = "row-wise", verbose = FALSE )
bn |
A bayesian network for pedigree object with information of the genotyped members. The ped object must be in Familias format. |
bNodePrunning |
Standard pruning. |
bStateRemoval |
State based pruning. |
bStateRemoval2 |
State based pruning (model 2). |
lumpingParameter |
Used for stepwise mutational model. |
renorm |
If "row-wise" is selected, zero probability is assigned for transitions out of range. |
verbose |
Computations output. |
A bayesian network based on pedigree evidence and QP definition.
## Not run: library(pedtools); library(forrel) ped <- linearPed(2) ped <- setMarkers(ped, locusAttributes = NorwegianFrequencies[1:2]) ped <- profileSim(ped, N = 1, ids = 2, seed = 1) pbn <- from_pedtools(ped, QP = "5") bnet <- buildBN(pbn, QP = "5") bn1 <- buildCPTs(bnet) ## End(Not run)## Not run: library(pedtools); library(forrel) ped <- linearPed(2) ped <- setMarkers(ped, locusAttributes = NorwegianFrequencies[1:2]) ped <- profileSim(ped, N = 1, ids = 2, seed = 1) pbn <- from_pedtools(ped, QP = "5") bnet <- buildBN(pbn, QP = "5") bn1 <- buildCPTs(bnet) ## End(Not run)
convertPedformat: a function for converting a pedtools ped onject to a famlink ped object.
convertPedformat(x, verbose = FALSE)convertPedformat(x, verbose = FALSE)
x |
A pedtools ped object. |
verbose |
Function output. |
A dataframe with LRs.
evidencePrunning: a fuction for pruning instantiated variables.
evidencePrunning(bn)evidencePrunning(bn)
bn |
A bayesian network (output of buildBN function). |
A preprocessed bayesian network.
factorHeteroFounders: a function for multiplying probabilities in case of heterocigote founders.
factorHeteroFounders(rresQ, bn)factorHeteroFounders(rresQ, bn)
rresQ |
List of CPTs. |
bn |
A bayesian network for pedigree object with information of the genotyped members. The ped object must be in Familias format. |
A dataframe with genotype probabilities.
This function has been entirely copied from Familias R package, it has been removed from CRAN. All references and citations about this function should be done to Familias developers. More information could be obtained from: https://www.familias.name/index.html. In fbnet package, this function is only used for dealing with the pedigree object.
FamiliasLocus( frequencies, allelenames, name, MutationModel = "Stepwise", MutationRate = 0, MutationRange = 0.5, MutationRate2 = 0, MutationMatrix, Stabilization = "None", MaxStabilizedMutrate = 1, femaleMutationModel, femaleMutationRate, femaleMutationRange, femaleMutationRate2, femaleMutationMatrix, maleMutationModel, maleMutationRate, maleMutationRange, maleMutationRate2, maleMutationMatrix )FamiliasLocus( frequencies, allelenames, name, MutationModel = "Stepwise", MutationRate = 0, MutationRange = 0.5, MutationRate2 = 0, MutationMatrix, Stabilization = "None", MaxStabilizedMutrate = 1, femaleMutationModel, femaleMutationRate, femaleMutationRange, femaleMutationRate2, femaleMutationMatrix, maleMutationModel, maleMutationRate, maleMutationRange, maleMutationRate2, maleMutationMatrix )
frequencies |
allele frequencies |
allelenames |
names |
name |
system name |
MutationModel |
model |
MutationRate |
rates |
MutationRange |
range |
MutationRate2 |
rate two, applied for extended stepwise |
MutationMatrix |
matrix |
Stabilization |
stabilization factor |
MaxStabilizedMutrate |
mix factor |
femaleMutationModel |
for females |
femaleMutationRate |
rate |
femaleMutationRange |
range |
femaleMutationRate2 |
rate 2 |
femaleMutationMatrix |
females matrix |
maleMutationModel |
male matrix |
maleMutationRate |
male rate |
maleMutationRange |
male range |
maleMutationRate2 |
rate 2 |
maleMutationMatrix |
matrix |
Locus analysis.
frequencies <- c(0.1, 0.2, 0.3, 0.4) allelenames <- c("A", "B", "C", "D") marker <- FamiliasLocus(frequencies, allelenames)frequencies <- c(0.1, 0.2, 0.3, 0.4) allelenames <- c("A", "B", "C", "D") marker <- FamiliasLocus(frequencies, allelenames)
This function has been entirely copied from Familias R package, it has been removed from CRAN. All references and citations about this function should be done to Familias developers. More information could be obtained from: https://www.familias.name/index.html. In fbnet package, this function is only used for dealing with the pedigree object.
FamiliasPedigree(id, dadid, momid, sex)FamiliasPedigree(id, dadid, momid, sex)
id |
individual id |
dadid |
father id |
momid |
mother id |
sex |
biological sex |
A dataframe with probabilities.
persons <- c("mother", "child", "AF") sex <- c("female", "female", "male") ped1 <- FamiliasPedigree(id = persons, dadid = c(NA, "AF", NA),momid = c(NA, "mother", NA), sex=sex)persons <- c("mother", "child", "AF") sex <- c("female", "female", "male") ped1 <- FamiliasPedigree(id = persons, dadid = c(NA, "AF", NA),momid = c(NA, "mother", NA), sex=sex)
'fbnet' is an open source software package written in R statistical languaje. It relies on a Bayesian Networks framework doi:10.1017/CBO9780511811357. It is particularly well suited to efficiently perform large-size queries against databases of missing individuals. It could interact with the main functionallities of other packages for pedigree analysis. In particular, 'fbnet' imports the 'Familias' software doi:10.1016/S0379-0738(00)00147-X. In addition 'pedtools', a software for creating and manipulating pedigrees and markers, is supported. 'fbnet' allows computing LRs and obtaining genotype probability distributions for query individual, based on the pedigree data. 'fbnet' implements the complete GENis functionality, a recently published open-source multi-tier information system developed to run forensic DNA databases to perform kinship analysis based on DNA profiles doi:10.1016/j.fsir.2020.100132.
Maintainer: Franco Marsico [email protected]
Authors:
Ariel Chernomoretz [email protected]
Useful links:
Report bugs at https://github.com/MarsicoFL/fbnet/issues
Builds the list structure returned by initBN directly
from a pedtools::ped object, without routing through the
archived paramlink package. This is the recommended entry
point for modern workflows that construct pedigrees via
pedtools, forrel, or pedsuite helpers such as
linearPed, cousinPed, avuncularPed, or
nuclearPed.
from_pedtools(x, available = NULL, QP = NULL)from_pedtools(x, available = NULL, QP = NULL)
x |
A |
available |
Character or integer vector of IDs that are
genotyped (have non-missing evidence). If |
QP |
Character or integer vector of Query Person IDs (the
individuals whose genotype posterior we want to query). Used by
|
The paramlink package was archived from CRAN in 2022, and its
replacement pedtools uses a different in-memory representation.
The original initBN.fromPed function requires a
paramlink linkdat object, which makes it difficult to use
fbnet with modern pedigree workflows. from_pedtools constructs
the equivalent list structure by hand from a pedtools::ped
object, so that the rest of the fbnet pipeline (buildBN,
buildCPTs, imposeEvidence, etc.) can be
run on pedigrees built with modern tools such as forrel and
pedsuite.
A list with the same shape as the return value of
initBN, namely
pedAn auxiliary pedigree object with fields
pedigree, ped, orig.ids, markerdata,
available, and nMark, mimicking the subset of
the paramlink linkdat interface that downstream fbnet
functions consume.
markerEvidenceA character matrix with rows
indexed by typed individuals and columns <marker>_p /
<marker>_m giving the observed allele labels.
markerLinkageA data frame with columns
linkedTo and recomb; defaults to unlinked.
alelFreqA named list of allele frequency vectors, one per marker.
mmodelA nested list with the default no-mutation model for each sex.
This function handles the entry point. Some downstream fbnet
functions still use @import paramlink in their roxygen
declarations, so a fully paramlink-free fbnet pipeline may
still require additional refactoring. For basic use cases (single
marker, small pedigree), the return value of from_pedtools
can be passed directly to buildBN.
initBN, initBN.fromPed,
buildBN.
## Not run: library(pedtools) library(forrel) # Build a 2nd-degree grandparent-grandchild pedigree with one marker ped <- linearPed(2) m <- marker(ped, afreq = c(A = 0.3, B = 0.4, C = 0.3), name = "M1") ped <- setMarkers(ped, m) ped <- setGenotype(ped, id = "1", marker = 1, geno = "A/B") pbn <- from_pedtools(ped) str(pbn) ## End(Not run)## Not run: library(pedtools) library(forrel) # Build a 2nd-degree grandparent-grandchild pedigree with one marker ped <- linearPed(2) m <- marker(ped, afreq = c(A = 0.3, B = 0.4, C = 0.3), name = "M1") ped <- setMarkers(ped, m) ped <- setGenotype(ped, id = "1", marker = 1, geno = "A/B") pbn <- from_pedtools(ped) str(pbn) ## End(Not run)
getConditional: a function for obtaining the coditional probability tables based on a given evidence.
getConditional(lf)getConditional(lf)
lf |
A list of joint probabilities. |
A list of conditioned probabilities.
getGenotypeTables: a function for obtaining genotypetables after variable elimination and using available genetic evidence.
getGenotypeTables(bn, resQ, geno = NULL, lqp = NULL)getGenotypeTables(bn, resQ, geno = NULL, lqp = NULL)
bn |
A bayesian network for pedigree object with information of the genotyped members. The ped object must be in Familias format. |
resQ |
List of CPTs. |
geno |
data.frame with genotypes. |
lqp |
list of individuals genotypes. |
A dataframe with genotype probabilities.
getLocusCPT: a function for obtaining the coditional probability table from a specific locus.
getLocusCPT(bn, locus, lumpingParameter = NULL, renorm = "row-wise")getLocusCPT(bn, locus, lumpingParameter = NULL, renorm = "row-wise")
bn |
A bayesian network for pedigree object with information of the genotyped members. The ped object must be in Familias format. |
locus |
Specified locus. |
lumpingParameter |
Used for stepwise mutational model. |
renorm |
If "row-wise" is selected, zero probability is assigned for transitions out of range. |
A bayesian network based on pedigree evidence and QP definition.
## Not run: library(pedtools); library(forrel) ped <- linearPed(2) ped <- setMarkers(ped, locusAttributes = NorwegianFrequencies[1:2]) ped <- profileSim(ped, N = 1, ids = 2, seed = 1) pbn <- from_pedtools(ped, QP = "5") bnet <- buildBN(pbn, QP = "5") bn1 <- buildCPTs(bnet) locCPT <- getLocusCPT(bn1, "D3S1358") ## End(Not run)## Not run: library(pedtools); library(forrel) ped <- linearPed(2) ped <- setMarkers(ped, locusAttributes = NorwegianFrequencies[1:2]) ped <- profileSim(ped, N = 1, ids = 2, seed = 1) pbn <- from_pedtools(ped, QP = "5") bnet <- buildBN(pbn, QP = "5") bn1 <- buildCPTs(bnet) locCPT <- getLocusCPT(bn1, "D3S1358") ## End(Not run)
factorHeteroFounders: a function for multiplying probabilities in case of heterocigote founders.
getMAP(resQ, topn = 3)getMAP(resQ, topn = 3)
resQ |
List of CPTs. |
topn |
Format parameter. |
A MAP from the probability table.
getGenotypeTables: a function for obtaining genotypetables after variable elimination and using available genetic evidence.
getQSetRMP(bn, lqp)getQSetRMP(bn, lqp)
bn |
A bayesian network for pedigree object with information of the genotyped members. The ped object must be in Familias format. |
lqp |
list of individuals genotypes. |
A dataframe with genotype probabilities.
getValuesOut: a function for getting out variables with zero probability in the bayesian network
getValuesOut(cpt, condVar = c())getValuesOut(cpt, condVar = c())
cpt |
conditional probability table from the bayesian network |
condVar |
variables from the conditioning table |
A processed conditional probability table
imposeEvidence: a fuction for imposing evidence in the bayesian network.
imposeEvidence(bn)imposeEvidence(bn)
bn |
A bayesian network (output of buildBN function). |
A preprocessed bayesian network.
initBN: a function to initialize the bayesian network.
initBN(ped = NULL, bplotped = FALSE)initBN(ped = NULL, bplotped = FALSE)
ped |
A ped object with information of the genotyped members. The ped object must be in Familias format. |
bplotped |
An alternative ped object to be compared. |
A bayesian network.
## Not run: # Legacy paramlink-based entry point. Use from_pedtools() instead. pbn <- initBN(toyped) ## End(Not run)## Not run: # Legacy paramlink-based entry point. Use from_pedtools() instead. pbn <- initBN(toyped) ## End(Not run)
initBN.fromPed: a function to initialize the bayesian network.
initBN.fromPed(ped, bplotped)initBN.fromPed(ped, bplotped)
ped |
A ped object in Familias format. |
bplotped |
An alternative ped object to be compared. |
A bayesian network.
initBN.fromVars: a function to initialize the bayesian network.
initBN.fromVars(bplotped)initBN.fromVars(bplotped)
bplotped |
An alternative ped object to be compared. |
A bayesian network.
minOrdering: a function for getting an ordering of bayesian network variables not in Q using min fill criteria on interaction graphs.
minOrdering(bn, vars = NULL, method = c("min_degree", "min_fill")[1])minOrdering(bn, vars = NULL, method = c("min_degree", "min_fill")[1])
bn |
A bayesian network for pedigree object with information of the genotyped members. The ped object must be in Familias format. |
vars |
Subset of tables where the order is calculated |
method |
Elimination method, min_degree or min_fill |
A bayesian network after ordering process.
Prepared pedigree for bayesian network trimming.
pbnpbn
A data.matrix.
preparePed: a function for simulating genetic data from untyped individuals conditioned on known genotypes.
preparePed(ped, available, lLociFreq, rseed = NULL)preparePed(ped, available, lLociFreq, rseed = NULL)
ped |
A ped object with information of the genotyped members. The ped object must be in Familias format. |
available |
Genotyped individuals IDs. |
lLociFreq |
Allele frequencies. |
rseed |
Seed used for simulations. |
A ped object.
prodFactor: a function for performing product between probability tables.
prodFactor(laux)prodFactor(laux)
laux |
probability distribution aux |
A dataframe with probabilities.
pruneNodes: a fuction for clasical pruning in bayesian networks.
pruneNodes(bn)pruneNodes(bn)
bn |
A bayesian network (output of buildBN function). |
A preprocessed bayesian network.
removeEvidenceFromPed: a function for removing evidence from specific individuals in a ped object.
removeEvidenceFromPed(pped, idNotEv)removeEvidenceFromPed(pped, idNotEv)
pped |
A ped object with information of the genotyped members. The ped object must be in Familias format. |
idNotEv |
A set of individuals whom evidence should be removed. |
A ped object.
reportLR: a function for calculating the LRs of specified genotypes in a pedigree.
reportLR(bn, resQ, geno = NULL)reportLR(bn, resQ, geno = NULL)
bn |
A bayesian network for pedigree object with information of the genotyped members. The ped object must be in Familias format. |
resQ |
List of CPTs. |
geno |
data.frame with genotypes. |
A dataframe with LRs.
reportPQ: a function for calculating the probability of specified genotypes in a pedigree.
reportPQ(bn, resQ, geno = NULL)reportPQ(bn, resQ, geno = NULL)
bn |
A bayesian network for pedigree object with information of the genotyped members. The ped object must be in Familias format. |
resQ |
List of CPTs. |
geno |
data.frame with genotypes. |
A dataframe with genotype probabilities.
reverseSpit: a function for formatting.
reverseSplit(inList)reverseSplit(inList)
inList |
input for formatting. |
A bayesian network.
setOrdering: a function for selecting the ordering method in the elimination process.
setOrdering(bn, ordMethod, vars = NULL, orderElim = NULL)setOrdering(bn, ordMethod, vars = NULL, orderElim = NULL)
bn |
A bayesian network for pedigree object with information of the genotyped members. The ped object must be in Familias format. |
ordMethod |
Ordering method. |
vars |
Vars |
orderElim |
Order elimination criteria. |
A bayesian network after ordering process.
stateRemoval: a function for processing the bayesian network.
stateRemoval(bn)stateRemoval(bn)
bn |
A bayesian network (output of buildBN function). |
A preprocessed bayesian network.
stateRemoval2: a function for processing the bayesian network. It implements another approach from the described in stateRemoval function.
stateRemoval2(bn, verbose = FALSE)stateRemoval2(bn, verbose = FALSE)
bn |
A bayesian network (output of buildBN function). |
verbose |
Computation output. |
A preprocessed bayesian network.
stateRemovalSubnucs: a fuctiong for variable state pruning.
stateRemovalSubnucs(bn, verbose = FALSE)stateRemovalSubnucs(bn, verbose = FALSE)
bn |
A bayesian network (output of buildBN function). |
verbose |
Computation output. |
A preprocessed bayesian network.
prodFactor: a function for performing sum between probability tables.
sumFactor(cpt, Z)sumFactor(cpt, Z)
cpt |
Conditional probability table |
Z |
factor |
A dataframe with probabilities.
Toy allele frequency database.
toybasetoybase
A data frame two markers allele frequencies
STRs allelic frequencies from specified country.
toypedtoyped
A toy pedigree. Nuclear family.
velim.bn: a function for variable elimination in a bayesian network.
velim.bn( bn, ordMethod = c("id", "min_degree", "min_fill", "fixed")[2], orderElim = NULL, verbose = FALSE )velim.bn( bn, ordMethod = c("id", "min_degree", "min_fill", "fixed")[2], orderElim = NULL, verbose = FALSE )
bn |
A bayesian network for pedigree object with information of the genotyped members. The ped object must be in Familias format. |
ordMethod |
Selected ordering method between id, min_degree, min_fill and fixed. |
orderElim |
Elimination order. |
verbose |
Computation output. |
Variable elimination result.
## Not run: library(pedtools); library(forrel) ped <- linearPed(2) ped <- setMarkers(ped, locusAttributes = NorwegianFrequencies[1:2]) ped <- profileSim(ped, N = 1, ids = 2, seed = 1) pbn <- from_pedtools(ped, QP = "5") bnet <- buildBN(pbn, QP = "5") bn1 <- buildCPTs(bnet) resQ <- velim.bn(bn1, ordMethod = "min_fill", verbose = FALSE) ## End(Not run)## Not run: library(pedtools); library(forrel) ped <- linearPed(2) ped <- setMarkers(ped, locusAttributes = NorwegianFrequencies[1:2]) ped <- profileSim(ped, N = 1, ids = 2, seed = 1) pbn <- from_pedtools(ped, QP = "5") bnet <- buildBN(pbn, QP = "5") bn1 <- buildCPTs(bnet) resQ <- velim.bn(bn1, ordMethod = "min_fill", verbose = FALSE) ## End(Not run)