igrabski / sc-SHC

Significance analysis for clustering single-cell RNA-sequencing data
87 stars 10 forks source link

Error in eigs_real_sym; k must satisfy 0 < k < rnow(A) #2

Closed VitorAguiar closed 1 year ago

VitorAguiar commented 1 year ago

Hi, thanks for developing scSHC!

When running the following code:

clusters <- scSHC(SeuratObj@assays$RNA@data, batch = NULL, alpha = 0.05, num_features = 2000, num_PCs = 30, parallel = TRUE, cores = 4)

I get the error:

Error in eigs_real_sym(A, nrow(A), k, which, sigma, opts, mattype  = "sym_matrix", :
    'k' must satisfy 0 < k < nrow(A)
In addition: Warning message:
In eigs_real_sym(A, nrow(A), k, which, sigma, opts, mattype  = "sym_matrix", :
    all eigenvalues are requested, eigen() is used instead

Please, any ideas on how to deal with that?

Thank you!

igrabski commented 1 year ago

Hi Vitor, I haven't seen that error before but it seems like at some point, for some reason, num_PCs is larger than the dimension of the data. Could you please confirm/clarify: (1) is the input data raw counts and of the class matrix or Matrix, (2) what is the dimension of the input data, and (3) how long does the code run before the error appears? Thanks!

VitorAguiar commented 1 year ago

Hi Isabella,

I see now that I need to use raw counts. I was using Seurat's log normalized counts.

It works!

Thank you, Vitor

Pacomito commented 1 year ago

Hello, Than you for this tool, sorry to re-open this issue, the same error happened to me running on scRNA public dataset:

clusters <- scSHC(data, cores = 3) Erreur dans eigs_real_sym(A, nrow(A), k, which, sigma, opts, mattype = "sym_matrix", : 'k' must satisfy 0 < k < nrow(A)

1) Dimension dim(data) [1] ´ 13098 35312´

2) Class

class(data)
[1] "dgCMatrix"
attr(,"package")
[1] "Matrix"

3) Raw counts:

13098 x 35312 sparse Matrix of class "dgCMatrix"
  [[ suppressing 85 column names ‘01:02:16:08’, ‘01:02:21:09’, ‘01:02:25:03’ ... ]]
  [[ suppressing 85 column names ‘01:02:16:08’, ‘01:02:21:09’, ‘01:02:25:03’ ... ]]

Gnai3 1 . . . . . . . . 1 . 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......
Pbsn  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......
Scml2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......
Apoh  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . ......
Cav2  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......
Wnt9a 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 . . . . 1 . . . . 1 . . . . . . . 1 . . . . . . . . . . . . . . ......

 ..............................
 ........suppression de 35227 colonnes et 13087 lignes dans show() ; ajustez peut-être 'options(max.print= *, width = *)'
 ..............................
  [[ suppressing 85 column names ‘01:02:16:08’, ‘01:02:21:09’, ‘01:02:25:03’ ... ]]

Gm49248 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......
Gm48169 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......
Gm47603 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . 1 . . . . . . . ......
Gm47853 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......
Gm47451 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......

4) Time after error =~20-30 min

Thank you in advance, Pacôme

igrabski commented 1 year ago

Hi Pacôme, you mentioned the dataset is public -- would it be possible to share the data so I can take a look at this issue on my end? Thanks!

Pacomito commented 1 year ago

Of course, here is a link: https://we.tl/t-pn25XhCSE6, Thanks

Pacomito commented 1 year ago

Just to let you know, I tried removing empty cells / columns first, which might cause PCA to fail, but it produced the same error indicating it might not be that.

data = data[which(rowSums(data) > 0), ]
data = data[,which(colSums(data) > 0)]
clusters <- scSHC(as.matrix(data), parallel = TRUE, cores = 8)
Erreur dans eigs_real_sym(A, nrow(A), k, which, sigma, opts, mattype = "sym_matrix",  : 
  'k' must satisfy 0 < k < nrow(A)

Best, Pacôme

igrabski commented 1 year ago

Thanks! I think I figured out the issue -- at some point, the number of relevant genes considered in the comparison of two tiny clusters is smaller than the default number of PCs, which leads to an error in the eigendecomposition. I just pushed a simple fix and now your data runs without issues on my end. Please re-install the package and let me know if the issue persists!

Pacomito commented 1 year ago

Thank you, I ran it and it works now.