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: Mat::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD #55

Open
GregorDall opened this issue Oct 31, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@GregorDall
Copy link

GregorDall commented Oct 31, 2023

Dear Eduardo,

We are trying to use A.mat with 75000k lines and 10k markers, getting the following error:
Error: Mat::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD
Still seems to work with 50k lines, but 75k doesn't work any more. Must be related to the number of individuals, because I can replicate it with only 5 markers too. rrBLUP::A.mat does not seem to have this problem, but I thought sommer::A.mat might be more efficient?

I am not sure if that is something related to sommer or Rcpp...

Best Gregor

@yunmika
Copy link

yunmika commented Nov 30, 2023

Dear Eduardo,

We are trying to use A.mat with 75000k lines and 10k markers, getting the following error: Error: Mat::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD Still seems to work with 50k lines, but 75k doesn't work any more. Must be related to the number of individuals, because I can replicate it with only 5 markers too. rrBLUP::A.mat does not seem to have this problem, but I thought sommer::A.mat might be more efficient?

I am not sure if that is something related to sommer or Rcpp...

Best Gregor

Hello, I also encountered the same problem as you. Is there any solution?

@GregorDall
Copy link
Author

Dear Eduardo,
We are trying to use A.mat with 75000k lines and 10k markers, getting the following error: Error: Mat::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD Still seems to work with 50k lines, but 75k doesn't work any more. Must be related to the number of individuals, because I can replicate it with only 5 markers too. rrBLUP::A.mat does not seem to have this problem, but I thought sommer::A.mat might be more efficient?
I am not sure if that is something related to sommer or Rcpp...
Best Gregor

Hello, I also encountered the same problem as you. Is there any solution?

Hi, my solution was to use A.mat from the rrBLUP package.

Best Gregor

@yunmika
Copy link

yunmika commented Dec 2, 2023

Dear Eduardo,
We are trying to use A.mat with 75000k lines and 10k markers, getting the following error: Error: Mat::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD Still seems to work with 50k lines, but 75k doesn't work any more. Must be related to the number of individuals, because I can replicate it with only 5 markers too. rrBLUP::A.mat does not seem to have this problem, but I thought sommer::A.mat might be more efficient?
I am not sure if that is something related to sommer or Rcpp...
Best Gregor

Hello, I also encountered the same problem as you. Is there any solution?

Hi, my solution was to use A.mat from the rrBLUP package.

Best Gregor

Okay thanks for your reply.

@covaruber
Copy link
Owner

Sorry that I never followed up with this issue. I tried some solutions but I haven't succeeded. I am not sure why this happens. It seems to be more related to RcppArmadillo than sommer itself but I will keep trying things and see if I can make it work.

Cheers,

@covaruber covaruber added the enhancement New feature or request label Mar 24, 2024
@yunmika
Copy link

yunmika commented Mar 24, 2024

Sorry that I never followed up with this issue. I tried some solutions but I haven't succeeded. I am not sure why this happens. It seems to be more related to RcppArmadillo than sommer itself but I will keep trying things and see if I can make it work.

Cheers,

Hi, the problem seems to be in MNR.cpp, I tried the following changes to avoid such error messages.

// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-

// we only include RcppArmadillo.h which pulls Rcpp.h in for us
#define ARMA_64BIT_WORD
#define ARMA_DONT_PRINT_ERRORS
#include "RcppArmadillo.h"
#include "stdlib.h"
#include <progress.hpp>
// [[Rcpp::export]]
arma::mat amat(const arma::mat & Xo, const bool & vanraden, double minMAF) {
  // remove min.MAF
  arma::rowvec pfreq = mean(Xo+1,0)/2; // frequency of p
  arma::mat pqfreq = arma::join_cols(pfreq,1-pfreq); // frequencies of p and q
  arma::rowvec MAF = min(pqfreq,0); // minor allele freqs
  arma::uvec indexMAF = find(MAF > minMAF); // index for good markers > minMAF
  arma::mat Xo2 = Xo.cols(indexMAF); // new X only with polymorphic markers
  // remove monomorphic markers
  arma::rowvec xVar = var(Xo2,0); // column variance
  arma::uvec index = find(xVar > 0); // index for good markers
  arma::mat X = Xo2.cols(index); // new X only with polymorphic markers
  // initialize A
  int p = X.n_cols;// number of markers
  int n = X.n_rows;
  arma::mat A(n,n);
  if(vanraden == true){ //  regular vanRaden 
    arma::rowvec ms012 = mean( X+1, 0 ); // means of columns
    arma::rowvec freq = ms012/2;
    double v = 2 * mean(freq % (1 - freq));
    arma::mat one(n, 1, arma::fill::ones);
    arma::mat freqmat = one * freq;
    arma::mat W = (X + 1) - (2 * freqmat);
    //
    arma::mat K = W * W.t();
    A = K/v/p;
  }else{ // Endelman (currently we have a bug here)
    // IN R: M <- scale(X, center = TRUE, scale = FALSE)
    arma::rowvec ms = mean( X, 0 ); // means of columns
    arma::mat M = X.each_row() - ms;
    // IN R: tcrossprod(M)
    arma::mat K = M * M.t();
    // IN R: K/mean(diag(K))   mean(K.diag())
    double v = mean(diagvec(K));
    A = K/v;
  }
  return A;
}

@covaruber
Copy link
Owner

covaruber commented Mar 24, 2024

I already tried that and it solves it for isolated functions but it does not work for compiling the entire package. But thanks for trying on your side. This issue seems to arise from functions that use the sparse matrix functions from the Armadillo library. I will keep trying other things.

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

No branches or pull requests

3 participants