Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in permutation scheme with triploids #1

Closed
zkamvar opened this issue Apr 16, 2014 · 1 comment
Closed

Bug in permutation scheme with triploids #1

zkamvar opened this issue Apr 16, 2014 · 1 comment
Assignees

Comments

@zkamvar
Copy link
Member

zkamvar commented Apr 16, 2014

There is a bug in the default shuffling algorithm for shufflepop and ia that comes down to numerical precision. The general process is:

  1. Take the sum of the columns (alleles) at a locus and multiply them by the ploidy to get the counts of each allele.
  2. Create a vector of indices of alleles where each index is replicated the number of times that allele is represented.
  3. Use that to shuffle the locus.

The problem occurs when there are triploids and 1/3 by 3 doesn't always equal 1.

mat <- structure(c(0.333333333333333, 0.333333333333333, 0.333333333333333, 
0.333333333333333, 0, 0, 0.333333333333333, 0, 0.666666666666667, 
0.666666666666667, 0.333333333333333, 0.666666666666667), .Dim = c(4L, 
3L), .Dimnames = list(structure(c("1", "2", "3", "5"), .Names = c("1", 
"2", "3", "4")), c("D13.000", "D13.144", "D13.190")))

bucket <- colSums(mat) * 3
bucket
## D13.000 D13.144 D13.190
##       4       1       7

rep(1:length(bucket), bucket)
## [1]11112333333

print(bucket, dig = 20)
## D13.000 D13.144 D13.190
## 4.0000000000000000000 1.0000000000000000000 6.9999999999999991118

A control scheme to check for the correct number of alleles is needed.

@zkamvar zkamvar added the bug label Apr 16, 2014
@zkamvar zkamvar self-assigned this Apr 16, 2014
@zkamvar
Copy link
Member Author

zkamvar commented Apr 16, 2014

Fixed with 4978358

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant