# NOT RUN {
data(Ped_HSg5, LH_HSg5, package="sequoia")
## Example A: parentage assignment only
conf.A <- EstConf(Pedigree = Ped_HSg5, LifeHistData = LH_HSg5,
args.sim = list(nSnp = 100, SnpError = 5e-3, ParMis=c(0.2, 0.5)),
args.seq = list(Module="par", Err=1e-3, Tassign=0.5), nSim = 3)
# parent-pair confidence, per category:
conf.A$ConfProb
# calculate (correct) assignment rates (ignores co-parent)
1 - apply(conf.A$PedErrors, c(1,3), sum, na.rm=TRUE)
## Example B: with sibship clustering, based on sequoia inferred pedigree
RealGenotypes <- SimGeno(Ped = Ped_HSg5, nSnp = 100,
ParMis=c(0.19,0.53), SnpError = 6e-3)
SeqOUT <- sequoia(GenoM = RealGenotypes,
LifeHistData = LH_HSg5,
Err=5e-3, Module="ped",
quiet=TRUE, Plot=FALSE)
conf.B <- EstConf(Pedigree = SeqOUT$Pedigree,
LifeHistData = LH_HSg5,
args.sim = list(nSnp = 100, SnpError = 5e-3,
ParMis=c(0.2, 0.5)),
args.seq = list(Err=5e-3, Module="ped"),
nSim = 2, nCores=2)
conf.B$ConfProb
Ped.withConf <- getAssignCat(Pedigree = SeqOUT$Pedigree,
SNPd = rownames(RealGenotypes))
Ped.withConf <- merge(Ped.withConf, conf.B$ConfProb, all.x=TRUE, sort=FALSE)
Ped.withConf <- Ped.withConf[, c("id","dam","sire", "dam.conf", "sire.conf",
"id.cat", "dam.cat", "sire.cat")]
head(Ped.withConf[Ped.withConf$dam.cat=="G", ])
head(Ped.withConf[Ped.withConf$dam.cat=="D", ])
## P(actual FS | inferred as FS) etc.
PairL <- list()
for (i in 1:length(conf.A$Pedigree.inferred)) { # nSim
cat(i, "\t")
PairL[[i]] <- ComparePairs(conf.A$Pedigree.reference,
conf.A$Pedigree.inferred[[i]],
GenBack=1, patmat=TRUE, ExcludeDummies = TRUE,
Return="Counts")
}
# P(actual relationship (Ped1) | inferred relationship (Ped2))
PairA <- plyr::laply(PairL, function(M) sweep(M, 2, colSums(M), "/"))
PairRel.prop <- apply(PairA, 2:3, mean, na.rm=TRUE) # mean across simulations
round(PairRel.prop, 2)
#' # or: P(inferred relationship | actual relationship)
PairA2 <- plyr::laply(PairL, function(M) sweep(M, 1, rowSums(M), "/"))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab