magnusdv / pedtools

Tools for working with pedigrees in R
GNU General Public License v3.0
23 stars 3 forks source link

Duplicated individuals #2

Closed thoree closed 6 years ago

thoree commented 6 years ago

Apparenty nuclearPed and likelihood(https://github.com/magnusdv/pedprobr) tolerate some duplication, not plot :

library(pedtools)
library(pedprobr)
x = nuclearPed(children = c("sib1", "sib1"))
m = marker(x, sib1 = 1:2, sib1 = 1, alleles = 1:2)
likelihood(x,m)
#> [1] 0.25
plot(x,m)
#> Error in kinship2::pedigree(id = ped$id, dadid = ped$fid, momid = ped$mid, : Duplicate subject id: sib1

Created on 2018-08-13 by the reprex package (v0.2.0).

magnusdv commented 6 years ago

Good catch, duplicated id's should definitely raise an error during pedigree construction.

Plot labels can be duplicated, of course, when they are given explicitly in the plot() call using the id.labels argument. (For instance, it is often useful to use empty labels for many pedigree members.)

magnusdv commented 6 years ago

On a side note, this reminds me of something I've swept under the rug so far: The class of pedigrees allowed in pedtools is larger than for the kinship2 package (which does the plotting). Hence certain pedigrees (e.g. pedigrees involving selfing) cannot be plotted as of yet.

magnusdv commented 6 years ago

With 44598d5 duplicated IDs are caught in relabel(), resolving the original error here.