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

Error with custom distance in aboot with PA data #210

Open
zkamvar opened this issue Dec 2, 2019 · 2 comments
Open

Error with custom distance in aboot with PA data #210

zkamvar opened this issue Dec 2, 2019 · 2 comments
Labels

Comments

@zkamvar
Copy link
Member

zkamvar commented Dec 2, 2019

library(poppr)
#> Loading required package: adegenet
#> Loading required package: ade4
#> Registered S3 method overwritten by 'spdep':
#>   method   from
#>   plot.mst ape
#> 
#>    /// adegenet 2.1.1 is loaded ////////////
#> 
#>    > overview: '?adegenet'
#>    > tutorials/doc/questions: 'adegenetWeb()' 
#>    > bug reports/feature requests: adegenetIssues()
#> Registered S3 method overwritten by 'pegas':
#>   method      from
#>   print.amova ade4
#> This is poppr version 2.8.3. To get started, type package?poppr
#> OMP parallel support: available
data(Aeut)
bindist <- function(x){ stopifnot(is.genind(x)); dist(tab(x), method = "binary") }
aboot(Aeut, dist = function(x) bootgen2genind(x) %>% bindist)
#> Error in .setupMethodsTables(fdef, initialize = TRUE): no slot of name "group" for this object of class "derivedDefaultMethod"

Created on 2019-12-02 by the reprex package (v0.3.0)

This originated from a discussion on the poppr forum.

@zkamvar
Copy link
Member Author

zkamvar commented Dec 2, 2019

Here's the traceback:

13: .setupMethodsTables(fdef, initialize = TRUE)
12: (function (fdef, env = environment(fdef), check = TRUE, inherited = FALSE) 
    {
        name <- if (inherited) 
            ".AllMTable"
        else ".MTable"
        if (check && !exists(name, envir = env, inherits = FALSE)) {
            .setupMethodsTables(fdef, initialize = TRUE)
            if (!exists(name, envir = env, inherits = FALSE)) 
                stop("invalid methods table request")
        }
        get(name, envir = env)
    })(new("derivedDefaultMethod", .Data = function (bg) 
    {
        standardGeneric("bootgen2genind")
    }, target = new("signature", .Data = "matrix", names = "bg", 
        package = "methods"), defined = new("signature", .Data = "ANY", 
        names = "bg", package = "methods"), generic = "bootgen2genind"))
11: bootgen2genind(x)
10: bootgen2genind(x)
9: eval(lhs, parent, parent)
8: eval(lhs, parent, parent)
7: bootgen2genind(x) %>% bindist at #1
6: (function (x) 
   bootgen2genind(x) %>% bindist)(x = c(1L, 1L, 1L, 1L, 1L, 1L, 
 
<SNIP>

5: do.call(DISTFUNK, distargs)
4: as.dist(D)
3: TREEFUNK(do.call(DISTFUNK, distargs))
2: treefunk(xboot)
1: aboot(Aeut[1:10, 1:10], dist = function(x) bootgen2genind(x) %>% 
       bindist)

@zkamvar
Copy link
Member Author

zkamvar commented Dec 5, 2019

Internally, aboot converts the PA genind object to a matrix, so we can create a bootgen2genind method for matrix, but it might just be better to recommend to people to extract the matrix itself before using bootgen2genind() on PA data.

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

No branches or pull requests

1 participant