Rosemeis / pcangsd

Framework for analyzing low depth NGS data in heterogeneous populations using PCA.
GNU General Public License v3.0
47 stars 11 forks source link

ValueError: ndarray is not C-contiguous #25

Closed debjyoti88 closed 4 years ago

debjyoti88 commented 4 years ago

Hi, I ran PCAngsd for 10 samples and it successfully produced a covariance matrix. However when I tried it for more than 10 samples, I got the error: ValueError: ndarray is not C-contiguous

Please see the terminal output below:


python pcangsd.py -beagle variants.beagle.gz -o test1 -threads 10
PCAngsd 0.981
Using 10 thread(s)

Parsing Beagle file
Read 31 samples and 5966 sites

Estimating population allele frequencies
EM (MAF) converged at iteration: 3

Number of sites after MAF filtering (0.05): 5966

Estimating covariance matrix
Using 2 principal components (MAP test)
Individual allele frequencies estimated (1)
Traceback (most recent call last):
  File "pcangsd.py", line 179, in <module>
    C, Pi, e = covariance.pcaEM(L, args.e, f, args.iter, args.tole, args.threads)
  File "covariance.py", line 92, in pcaEM
    diff = covariance_cy.rmse2d_eig(W, prevW)
  File "covariance_cy.pyx", line 138, in covariance_cy.rmse2d_eig
    cpdef rmse2d_eig(float[:,::1] A, float[:,::1] B):
  File "stringsource", line 658, in View.MemoryView.memoryview_cwrapper
  File "stringsource", line 349, in View.MemoryView.memoryview.__cinit__
ValueError: ndarray is not C-contiguous

Could you please help me troubleshoot this issue? Thank you.

Rosemeis commented 4 years ago

Hi,

Tried to reproduce the error but I can't seem to do it. It seems that the 'svds' function in your Scipy library returns a F-contiguous array. Could you try and update your Scipy library (maybe Numpy as well)?

If it still doesn't work, then a quick fix would be to remove the assumption of a C-contiguous array. You can do that by changing line 138 in 'covariance_cy.pyx' to following: cpdef rmse2d_eig(float[:,:] A, float[:,:] B):

After this you need to run 'python setup.py build_ext --inplace' again. :-)

Best, Jonas

debjyoti88 commented 4 years ago

Hi Jonas, Changing line 138 worked. Now the script works for all sample sizes. Thank you :) Best. Debjyoti