gregorgorjanc / AlphaSimR

R package for breeding program simulations
Other
0 stars 2 forks source link

sortPed() with not recoded pedigree #6

Open AudreyAAMartin opened 7 months ago

AudreyAAMartin commented 7 months ago

sortPed() cannot take pedigree with not recoded ID. For example, pedigree with ID 1:10 will work fine but the same structure with ID 2:11 will not.

Error can be produced by

id = 2:11
mother = c(0,0,0,0,2,2,3,8,0,8)
father = c(0,0,0,0,4,4,5,6,7,7)
ped = sortPed(id=id, mother=mother, father=father, maxCycle=100)

Columns mother and father should match mother_id and father_id within ped file created.

The issue seems to come from the way of creating 'output', function 'match' seems incorrect for this use.

gregorgorjanc commented 7 months ago

@AudreyAAMartin what error do you get? Paste in here please

AudreyAAMartin commented 7 months ago

This is what we're getting out of sortPed() with the example above. The columns mother and father are correct (=as imputed) whereas the motherID and fatherID created by the function gave ID as 1:10. sortPed sort of recoded the mother and father part of the pedigree which should not be done.

gen id mother father motherID fatherID
1  2     NA     NA        0        0
1  3     NA     NA        0        0
1  4     NA     NA        0        0
1  5     NA     NA        0        0
2  6      1      3        2        4
2  7      1      3        2        4
2  8      2      4        3        5
3  9      7      5        8        6
3 10     NA      6        0        7
3 11      7      6        8        7