dwinter / mmod

Differentiation statistics in R
Other
11 stars 5 forks source link

Utilize [pop = ] accessor instead of repool for pairwise functions #3

Closed zkamvar closed 9 years ago

zkamvar commented 9 years ago

In all of mmod's pairwise functions, you first split populations and then repool them for each calculation. Using the new [pop = ] accessor would be advantageous as it would prevent unnecessary repooling of the data.

Example:

pair <- function(index.a, index.b){
    a <- pops[[index.a]]
    b <- pops[[index.b]]
    temp <- repool(a,b)
    # do something with temp
}

could be turned into:

pair <- function(two.pops = c(index.a, index.b), pops){
    temp <- pops[pop = two.pops]
    # do something with temp
}

This way, you could pass the table of combinations to apply:

apply(allP, 2, pair, pops)
dwinter commented 9 years ago

Hi @zkamvar -- thanks very much for spotting this. I think there is much that could be improved in mmod, both with adegenet2.0 functions and with a (I hope...) better programmer than I was when I first wrote it!

I will write up and test this, but want to create you as a contributor to the package in the DESCRIPTION. Is the email address in your github profile the best one to include?

zkamvar commented 9 years ago

:+1: Yes, that email is the best one.