bowang-lab / scGPT

https://scgpt.readthedocs.io/en/latest/
MIT License
1.05k stars 207 forks source link

`layer_data.A` in `preprocess.y` #254

Closed sklarz-bgu closed 3 weeks ago

sklarz-bgu commented 2 months ago

Hi. When running preprocess.py, I get the following error:

AttributeError: 'csr_matrix' object has no attribute 'A'

I'm running preprocess() as part of the tutorial described here

offending lines: 181-182.

layer_data = _get_obs_rep(adata, layer=key_to_process)
layer_data = layer_data.A if issparse(layer_data) else layer_data

type(layer_data) is scipy.sparse._csr.csr_matrix, issparse(layer_data) is True.

Could this be an issue of versions? I think I installed everything correctly.

Thanks Menachem

8gabri8 commented 2 months ago

Same problem.

sklarz-bgu commented 2 months ago

You can do the following modification and it seems to work fine:

layer_data = layer_data.toarray() if issparse(layer_data) else layer_data

Hope it does what it's supposed to do...

subercui commented 3 weeks ago

Thank you @sklarz-bgu for providing the solution. I think that's some api mismatch bettween dependency versions. That solution does what it intended to do.