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

Add Nei's DA distance (1983) #1

Open
pascalangst opened this issue Nov 9, 2021 · 3 comments
Open

Add Nei's DA distance (1983) #1

pascalangst opened this issue Nov 9, 2021 · 3 comments
Assignees

Comments

@pascalangst
Copy link

Hi @lpembleton

StAMPP is a cool package and I've used it a lot. Thanks!

Have you thought about adding more functions to the package? For example, since we can calculate Nei's D with StAMPP, I assume it would not be too difficult to implement Nei's DA distance. Having this measure would allow to build more reliable trees.

I was looking around in your code and found sections in the NeisD function that one could modify to get a new NeisDA function. However, I'm not 100 % sure what your variables code for. E.g.

StAMPP/R/stamppNeisD.R

Lines 263 to 277 in 346815e

p.dup <- (p[p.dup.ids[((pre.split*split.size)+1):(totalind*totalind)],]) #matrix of allele frequencies to calculate squared allele freq, jx & jy
m.dup <- (m[m.dup.ids[((pre.split*split.size)+1):(totalind*totalind)],]) #matrix of true false (1/0) missing genotype of each ind & loci to adjust p.dup matrix for missing alleles
m.dup2 <- (m[p.dup.ids[((pre.split*split.size)+1):(totalind*totalind)],])
jxjy <- c(jxjy, sum((p.dup*m.dup)^2)+sum(((1-p.dup)*m.dup*m.dup2)^2)) #sum of square allele freq
}
#########################
sq.jxjy <- sqrt(matrix(jxjy, nrow=totalind, ncol=totalind)) #square root of the sum of squared allele freq
i <- jxy/sq.jxjy
i <- i/t(sq.jxjy) #normalised identity averaged across loci
d <- -log(i) #Nei's genetic distance

Would you be willing to add this function or could you give me a hint how I could modify the existing code to do so?

Cheers
Pascal

@pascalangst pascalangst changed the title Add Nei's D<sub>A</sub> distance (1983) Add Nei's DA distance (1983) Nov 9, 2021
@lpembleton
Copy link
Owner

Thanks for the feature request @pascalangst
I have been working to incorporate this and will hopefully push to GitHub soon so you can test it.
Cheers,
Luke

@lpembleton lpembleton self-assigned this Nov 28, 2021
@lpembleton
Copy link
Owner

A alpha/beta release is now available with this requested feature (https://github.com/lpembleton/StAMPP/releases/tag/v1.6.3.9000).
@pascalangst do you have any example datasets with known results to test the implementation of this formula?

@pascalangst
Copy link
Author

Hi @lpembleton

Thanks for implementing. Unfortunately, I don't have datasets with known results. Therefore, I cannot do a proper test. However, I can check if it is running ok on my machine.

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

No branches or pull requests

2 participants