magnusdv / forrel

Forensic pedigree analysis and relatedness inference
GNU General Public License v2.0
10 stars 0 forks source link

markerSim #1

Closed thoree closed 6 years ago

thoree commented 6 years ago

In the markerSim example library(pedtools) partial = marker(x, 3, 1, alleles=1:3) Apparently the marker is created without genotype Should it be ?: partial = marker(x, "3"=1, alleles=1:3)

The below doesn't work unless mutmat is removed library(forrel) z = fullSibMating(2) l = leaves(z) z = addChildren(z, father = l[1], mother = l[2], sex = 2, nch=1) p = c(1,1,1)/3; lp = length(p); alleler = 1:lp R = 0.05 M = matrix(ncol= lp,nrow =lp, R/(lp-1), dimnames = list(alleler, alleler)) diag(M) = 1-R m = marker(z, alleles = alleler, afreq = p, mutmat = M) markerSim(z, N=1, partialmarker = m )

magnusdv commented 6 years ago

Thanks, fixed in 05ad808 and 7725f1e.

Note that the recent mutationMatrix() in pedtools (magnusdv/pedtools@c9111fc) facilitate construction of mutation matrices:

library(pedtools)
mutationMatrix(alleles = 1:3, model = "equal", rate = 0.05)
#>       1     2     3
#> 1 0.950 0.025 0.025
#> 2 0.025 0.950 0.025
#> 3 0.025 0.025 0.950
thoree commented 6 years ago

Thanks! I attach a suggestion for an extension of mutationMatrix() with proportional added based on formula in section 2.1.4 of Simonsson and Mostad (2016) mutationMatrix.txt Here's a check against Familias: afreq = 1:10 afreq = afreq/sum(afreq) alleler = 1:length(afreq) rate = 0.05 model = "proportional" M1 = mutationMatrix(alleler, model, rate, afreq)

library(Familias) locus1 <- FamiliasLocus(frequencies = afreq, name = "L1", allelenames = alleler, MutationRate = rate, MutationModel = model) M2 <- locus1$maleMutationMatrix all(M1 == M2)

magnusdv commented 6 years ago

Thanks. I opened a this as a separate issue in pedtools (since that's where mutationMatrix() lives).