bioinfo-biols / SEVtras

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

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

Open fusca9 opened 2 weeks ago

fusca9 commented 2 weeks 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 2 weeks 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 2 weeks 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 2 weeks 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 2 weeks 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 2 weeks 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.

fusca9 commented 1 week ago

i'm sorry for the late answer. i had a problem with th server but now it works and i could achieve finishing the SEVtras.sEV_recognizer analysis. Thank you very much. i would ask only one last question. The input for SEVtras.ESAI_calculator consists of a cell matrix with cell type, but how can i create this matrix? what kind of data i need? sorry if i'm not very into english and thank you for the help!

RuiqiaoHe commented 1 week ago

SEVtras needs the cell matrix in h5ad format, this can be converted by scanpy with the following code: import scanpy as sc adata = = sc.read_10x_h5(path)#path means the directory of feature_bc_matrix adata.write_h5ad('./adata.h5ad') And the cell type information, this is conventional analysis in the single cell transcriptomics. You can refer to here for further insights.