zhengxwen / SNPRelate

R package: parallel computing toolset for relatedness and principal component analysis of SNP data (Development version only)
http://www.bioconductor.org/packages/SNPRelate
98 stars 25 forks source link

snpgdsIBDSelection fails for large matrices #57

Closed smgogarten closed 5 years ago

smgogarten commented 5 years ago

Prior to commit 442cf0b, snpgdsIBDSelection worked for very large matrices (at least up to 65k samples). Now I get the following error on an object with 55k samples:

Error in which(xx, TRUE) :
  long vectors not supported yet
zhengxwen commented 5 years ago

fix it in SNPRelate_1.18.1 by adding the following:

    # get indexes
    if (length(xx) > 2147483647)
    {
        # work around long vector
        v <- apply(xx, 2L, function(x) which(x))
        n <- lengths(v)
        i <- which(n > 0L)
        ii <- data.frame(i1=unlist(v[i]), i2=rep(i, times=n[i]))
    } else {
        ii <- which(xx, TRUE)
    }