BGI-Qingdao / GEM3D_toolkit

A tool to use stereo-seq GEM and ssDNA to generate single-cell and 3D spatial resolved transtriptomics data
11 stars 1 forks source link

AttributeError: 'numpy.int64' object has no attribute '__dict__' #1

Closed pangxueyu233 closed 1 year ago

pangxueyu233 commented 1 year ago

Hi, I met a problem when I test the GEM_toolkit.py function with test data.

cd ./GEM3D_toolkit-main/

vim test_gem2bfm.json
[
    ["/mnt/data/user_data/xiangyu/programme/GEM3D_toolkit-main/example/slice_88.gem", 88]
]

python ../GEM_toolkit.py  gem2bfm  -c test_gem2bfm.json -o test_g

Then, I got error:

config file is test_gem2bfm.json
output prefix is test_g
binsize is 50
threads is 8
start loading slice(s)...
2022-12-27 15:01:45
handle slice(s)...
2022-12-27 15:01:45
build gene maps for slice 88 ...
2022-12-27 15:01:45
get bins of slice 88 ...
2022-12-27 15:01:45
get mtx of slice 88...
2022-12-27 15:01:45
#line in gem: 9999, slice 88
2022-12-27 15:01:45
hanle a gem : done slice <st3d.model.slice_dataframe.slice_meta_data object at 0x7fd6624b5df0>
2022-12-27 15:01:46
save slice 88 data ...
2022-12-27 15:01:46
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/usr/local/python3.8/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/usr/local/python3.8/lib/python3.8/multiprocessing/pool.py", line 48, in mapstar
    return list(map(*args))
  File "/mnt/data/user_data/xiangyu/programme/GEM3D_toolkit-main/st3d/control/gem2bfm.py", line 43, in gem2bfm_one_slice
    print_gem2bfm_slices_json(slices_info,prefix,slice_index)
  File "/mnt/data/user_data/xiangyu/programme/GEM3D_toolkit-main/st3d/control/save_miscdf.py", line 113, in print_gem2bfm_slices_json
    sourceFile.writelines(json.dumps(slices_info, sort_keys=False, indent=4, separators=(',', ':'),cls=General_Encoder))
  File "/usr/local/python3.8/lib/python3.8/json/__init__.py", line 234, in dumps
    return cls(
  File "/usr/local/python3.8/lib/python3.8/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/local/python3.8/lib/python3.8/json/encoder.py", line 439, in _iterencode
    yield from _iterencode(o, _current_indent_level)
  File "/usr/local/python3.8/lib/python3.8/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/local/python3.8/lib/python3.8/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/local/python3.8/lib/python3.8/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/mnt/data/user_data/xiangyu/programme/GEM3D_toolkit-main/st3d/control/save_miscdf.py", line 16, in default
    return o.__dict__
AttributeError: 'numpy.int64' object has no attribute '__dict__'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "../GEM_toolkit.py", line 90, in <module>
    gem2bfm_main(sys.argv[2:])
  File "/mnt/data/user_data/xiangyu/programme/GEM3D_toolkit-main/st3d/control/gem2bfm.py", line 114, in gem2bfm_main
    gem2bfm_slices_one_by_one(slice_data,prefix,binsize,threads)
  File "/mnt/data/user_data/xiangyu/programme/GEM3D_toolkit-main/st3d/control/gem2bfm.py", line 57, in gem2bfm_slices_one_by_one
    p.map(gem2bfm_one_slice, args)
  File "/usr/local/python3.8/lib/python3.8/multiprocessing/pool.py", line 364, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/usr/local/python3.8/lib/python3.8/multiprocessing/pool.py", line 768, in get
    raise self._value
AttributeError: 'numpy.int64' object has no attribute '__dict__'

I guess this error occurred because the inappropriate version of numpy and pandas were used. Can you show me what's the version of this dependency packages. My version of numpy and pandas are as following:

/usr/local/python3.8/bin/pip3.8 show numpy
Name: numpy
Version: 1.21.4
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email:
License: BSD
Location: /usr/local/python3.8/lib/python3.8/site-packages
Requires:
Required-by: anndata, arboreto, bokeh, contourpy, dask-image, datashader, datashape, gefpy, gtfparse, h5py, harmonypy, holoviews, hotspotsc, hvplot, imageio, KDEpy, loompy, matplotlib, numba, numcodecs, numexpr, numpy-groupies, opencv-python, pandas, patsy, PhenoGraph, PIMS, pyarrow, PyWavelets, scanpy, scikit-image, scikit-learn, scipy, seaborn, slideio, squidpy, statsmodels, tables, tifffile, umap-learn, xarray, zarr

/usr/local/python3.8/bin/pip3.8 show pandas
Name: pandas
Version: 1.3.4
Summary: Powerful data structures for data analysis, time series, and statistics
Home-page: https://pandas.pydata.org
Author: The Pandas Development Team
Author-email: pandas-dev@python.org
License: BSD-3-Clause
Location: /usr/local/python3.8/lib/python3.8/site-packages
Requires: numpy, python-dateutil, pytz
Required-by: anndata, arboreto, datashader, gefpy, gtfparse, harmonypy, holoviews, hotspotsc, hvplot, omnipath, scanpy, seaborn, spatialpandas, squidpy, statsmodels, xarray
cchd0001 commented 1 year ago

numpy 1.19.2 py38h54aff64_0 pandas 1.1.3 py38he6710b0_0

cchd0001 commented 1 year ago

微信?15153293402

pangxueyu233 commented 1 year ago

Thanks, I figured it out by using similar function implemented in stereopy-0.8.0.