magnusdv / pedtools

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

`randomPed()` error #42

Closed chrcarrizosa closed 1 year ago

chrcarrizosa commented 1 year ago

randomPed() plots a pedigree when it stops on error:

library(pedtools) # 2.1.1

randomPed(n = 5, maxGenerationGap = 0, seed = 1)
#> Error in sample.int(length(x), ...): invalid first argument

# # Other examples
# randomPed(n = 10, maxGenerationGap = 0, seed = 1)
# randomPed(n = 5, maxGenerationGap = 1, seed = 58)
# randomPed(n = 10, maxGenerationGap = 1, seed = 2)
# randomPed(n = 10, maxGenerationGap = 2, seed = 63)
# randomPed(n = 10, maxGenerationGap = 3, seed = 202)

Created on 2023-02-28 with reprex v2.0.2

magnusdv commented 1 year ago

Thanks, I think these errors are avoided in the latest development version.

The maxGenerationGap concept was more complex than I anticipated, resulting in a buggish implementation (as you have discovered). It has been replaced with the less restrictive maxDirectGap, which only disallows matings between individuals in direct (lineal) relationship.