bioinfo-biols / SEVtras

sEV-containing droplet identification in scRNA-seq data (SEVtras)
GNU Affero General Public License v3.0
20 stars 5 forks source link

AttributeError: 'csc_matrix' object has no attribute 'A' #32

Open fusca9 opened 1 day ago

fusca9 commented 1 day ago

Dear Author, i'm using this script for analysis: import SEVtras SEVtras.sEV_recognizer( input_path='/mnt/data1/foschi',
sample_file='/mnt/data1/foschi/sample_file.txt',
out_path='/mnt/data1/foschi/outputs_SEVtras', species='Homo' ) the output directories of cellranger are in: /mnt/data1/foschi and the file .txt is in this path: '/mnt/data1/foschi/sample_file.txt. However, i encountered this error: The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/mnt/data1/foschi/script_SEVtras.py", line 4, in SEVtras.sEV_recognizer( File "/home/foschi/.local/lib/python3.10/site-packages/SEVtras/main.py", line 121, in sEV_recognizer inter_adata, iteration_list = iteration(inter_adata, iteration_list, thershold, max_M, threads=threads, number_g = 30, alpha = alpha) File "/home/foschi/.local/lib/python3.10/site-packages/SEVtras/utils.py", line 204, in iteration result_tmp = multi_cor(inter_adata, threads) File "/home/foschi/.local/lib/python3.10/site-packages/SEVtras/utils.py", line 173, in multi_cor result_tmp = pool.map(corr_genes, item_list) File "/usr/lib/python3.10/multiprocessing/pool.py", line 367, in map return self._map_async(func, iterable, mapstar, chunksize).get() File "/usr/lib/python3.10/multiprocessing/pool.py", line 774, in get raise self._value AttributeError: 'csc_matrix' object has no attribute 'A'. i don't know why this error occurs, i followed all the instructions on the website. Do you know what is going wrong? Can ypu please give me some advice? Thank you very much for your work!

RuiqiaoHe commented 1 day ago

The error may be due to mismatched format in the input data files (different from 10X CellRanger standard output). It is OK to format each dataset in the sample_file.txt with the following code: import anndata as ad from scipy.sparse import csr_matrix adata = ad.read_h5ad('./adata.h5ad') adata.X = csr_matrix(adata.X) adata.write_h5ad('./adata_s.h5ad') The generated adata_s.h5ad would be used as the input files.

fusca9 commented 1 day ago

Thank you for the quick answer! however i used 10XCellRanger standard outputs(raw_feature_bc_matrix) as inputs for SEVtras. Anyway i'll try your suggestion!

RuiqiaoHe commented 21 hours ago

If you used the input data from CellRanger outputs, could you please check the version of scipy in your environment? An earlier version of scipy than 1.14.0 should work:

Several previously deprecated methods for sparse arrays were removed: asfptype, getrow, getcol, get_shape, getmaxprint, set_shape, getnnz, and getformat. Additionally, the .A and .H attributes were removed.

From https://docs.scipy.org/doc/scipy/release/1.14.0-notes.html

fusca9 commented 10 hours ago

Thank you very much for the informations. I tried with an earlier version of scipy and it goes, although it takes 2 hours to analyze 3/16 samples and it's using all the threads available on the server where i work. is it normal?

RuiqiaoHe commented 8 hours ago

This is not normal. Could you please first try to run the test data located at https://github.com/bioinfo-biols/SEVtras/tree/main/tests? It would only take a few minutes.