Closed zkamvar closed 7 years ago
Note that implementing the calculation may require a binary search tree.
I believe I have addressed this in https://github.com/zkamvar/poppr/commit/486928a12cb83de90ef779800ca8c62ecbef5535. I did not need to implement a binary search tree to calculate the multinomial coefficient.
The implementation is as described above with the exception of the option. Instead of giving the user options throughout the Bruvo functions, I have set a global option that changes the behavior of the internal function.
Currently, the number of permutations for calculating Bruvo's distance from genome addition and genome loss models counts each unique, unordered combination of alleles, which is derived from the multiset coefficient. This reduces the number of computations (e. g. trying to fill 3 alleles of a tetraploid in the genome addition model takes 20 steps as opposed to 64).
Since the other method available in R computes this using binomial expansion, it might be beneficial to give the users the option to do this as well with an argument:
method = c("multiset", "binomial")
.The way to implement this would not be to increase the number of steps to n^k, but rather to simply just use the permutation of multisets to calculate a number to be multiplied to the value since the order of alleles does not matter when calculating the distance:
For example, when trying to fill 3 missing alleles with 4 alleles, the genotype 123 would have:
3!/1!1!1! = 6 arrangements
the genotype 112 would have
3!/1!2! = 3 arrangements
and the genotype 111 would have
3!/3! = 1 arrangements