daler / pybedtools

Python wrapper -- and more -- for BEDTools (bioinformatics tools for "genome arithmetic")
http://daler.github.io/pybedtools
Other
297 stars 103 forks source link

numpy.int64 has no attribute isdigit #362

Closed urrik98 closed 2 years ago

urrik98 commented 2 years ago

Trying make an annotation file and getting the error:

File “/home/qinma/software/ldsc/make_annot.py”, line 56, in make_annot_files(args, bed_for_annot) File “/home/qinma/software/ldsc/make_annot.py”, line 24, in make_annot_files bimbed = BedTool(iter_bim) File “/home/qinma/anaconda3/envs/ldsc3/lib/python3.7/site-packages/pybedtools/bedtool.py”, line 583, in init fn = BedTool(iter(fn)).saveas().fn File “/home/qinma/anaconda3/envs/ldsc3/lib/python3.7/site-packages/pybedtools/bedtool.py”, line 917, in decorated result = method(self, *args, **kwargs) File “/home/qinma/anaconda3/envs/ldsc3/lib/python3.7/site-packages/pybedtools/bedtool.py”, line 3346, in saveas out_compressed=compressed, File “/home/qinma/anaconda3/envs/ldsc3/lib/python3.7/site-packages/pybedtools/bedtool.py”, line 1416, in _collapse for i in iterable: File “pybedtools/cbedtools.pyx”, line 792, in pybedtools.cbedtools.IntervalIterator.next File “pybedtools/cbedtools.pyx”, line 656, in pybedtools.cbedtools.create_interval_from_list File “pybedtools/cbedtools.pyx”, line 578, in pybedtools.cbedtools.isdigit AttributeError: ‘numpy.int64’ object has no attribute ‘isdigit’

daler commented 2 years ago

Can you provide an example that reproduces this error? Without the make_annot.py code or knowing what's in iter_bim it is not possible to troubleshoot.

urrik98 commented 2 years ago

Thanks, I think I've found the problem lies elsewhere in our workflow.

wangqiaoxiu-array commented 1 year ago

hello! I am doing sc-linker STEP 2C: From bedgraph to annotation files, facing the same question, could you tell me how to solve the question, please?

EthanZhaoChem commented 1 year ago

Hello, I wrote the following lines to solve this problems. Feel free to use:

iter_bim = [['chr'+str(x1), x2, x2, 1] for (x1, x2) in np.array(df_bim[['CHR', 'BP']])]
element_strings = [' '.join(map(str, sublist)) for sublist in iter_bim]
iter_bim = '\n'.join(element_strings)
bimbed = BedTool(iter_bim, from_string=True)
annotbed = bimbed.intersect(bed_for_annot, wb=True)

You will be able to find these part in line 40 from the python script to annotate bed file: bedgraph_to_annot.py

It was assuming that BedTool function can read list of locations, but it can't now (maybe just the problem of package version).