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

allow for binomial expansion estimations for polyploidy in Bruvo's distance #139

Closed
zkamvar opened this issue Apr 13, 2017 · 2 comments
Closed

Comments

@zkamvar
Copy link
Member

zkamvar commented Apr 13, 2017

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

@zkamvar
Copy link
Member Author

zkamvar commented Jun 22, 2017

Note that implementing the calculation may require a binary search tree.

@zkamvar
Copy link
Member Author

zkamvar commented Aug 13, 2017

I believe I have addressed this in zkamvar@486928a. 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.

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