TypeError: 'numpy.float64' object cannot be interpreted as an integer

144 views
Skip to first unread message

David Castillo Rodríguez

unread,
Mar 27, 2021, 3:53:12 PM3/27/21
to DANPOS
Hello everyone,
I'm running DANPOS3. I actually created a Docker container to run this program using the following commands:

FROM python:latest
WORKDIR /batchx
RUN apt-get update && apt install -y r-base && apt -y autoremove
RUN cd DANPOS3 && pip install -r requirements.txt
RUN pip install scipy

I ran dpos with a single BAM file sample and everything went well. But every time I run dpos with more than one sample I get the same error:

fine-tuning positions for tmp_A_972-t0-20U-n3_S17_L003.mini_A1.sorted by comparing to the reference map...
Traceback (most recent call last):
  File "/batchx/DANPOS3/danpos.py", line 1365, in <module>
    if sys.argv[1]=='dpos':runDANPOS(command='dpos')
  File "/batchx/DANPOS3/danpos.py", line 396, in runDANPOS
    danpos(\
  File "/batchx/DANPOS3/functions.py", line 454, in danpos
 pooledgroups[groupname].fillPositions(dic=tdic,file=os.path.join(opath,'pooled',groupname+addname+"positions.ref_adjust.xls"),width=width,distance=distance,edge=edge,pcut=pheight,height=height,calculate_P_value=1,mode='w',title_line=1,poscal=1,rd=rd)
  File "/batchx/DANPOS3/wig.py", line 492, in fillPositions
    smts.fetchValueFromWig(twig)
  File "/batchx/DANPOS3/summits.py", line 43, in fetchValueFromWig
    if tp>wig.data[cr].size:wig.data[cr].resize(tp+1,refcheck=0)
TypeError: 'numpy.float64' object cannot be interpreted as an integer

In this last attempt, this is the command I was using:
python3 /batchx/DANPOS3/danpos.py dpos /tmp/A/972-t0-20U-n3_S17_L003.mini_A1.sorted.bam,/tmp/A/972-t0-20U-n3_S17_L003.mini_A2.sorted.bam:/tmp/condition-b/972-t0-20U-n3_S17_L003.mini_B1.sorted.bam,/tmp/condition-b/972-t0-20U-n3_S17_L003.mini_B2.sorted.bam --paired 1 --height 5 --out /batchx/output/dpos/

I was trying to compare two conditions, with two replicates each. 
All BAM files were created using bowtie2. All BAM files have paired reads and were sorted and indexed, before running dpos. Hope somebody knows what raises this error. The most I'm able to infer is that a float is being used where an int was expected.
If more info is required, let me know!
Cheers!
David

David Castillo Rodríguez

unread,
Mar 28, 2021, 5:57:23 AM3/28/21
to DANPOS
Adding the output from running the print_versions.py script:

# python3 /batchx/DANPOS3/print_versions.py

Python version
3.9.0 (default, Oct 13 2020, 20:14:06) 
[GCC 8.3.0]
-------------------------------------------------

R version 3.5.2 (2018-12-20) -- "Eggshell Igloo"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see

0
-------------------------------------------------

samtools 1.9
Using htslib 1.9
Copyright (C) 2018 Genome Research Ltd.
0
-------------------------------------------------

AVAILABLE python packages:
numpy: 1.18.5
rpy2: 3.3.3
pysam: 0.16.0.1
argparse: 1.1

Great job! No missing python packages!

David Castillo Rodríguez

unread,
Mar 28, 2021, 6:16:46 AM3/28/21
to DANPOS
I managed to avoid the summits.py script from crashing by modifying line 43.
from this:
if tp>wig.data[cr].size:wig.data[cr].resize(tp+1,refcheck=0)
to this:
if tp>wig.data[cr].size:wig.data[cr].resize(int(tp)+1,refcheck=0)
I just coerced tp to an integer. This avoids the script from crashing but not sure if this is a valid solution.
Please let me know if this solution is appropriate.
Best wishes,
David

sjk...@gmail.com

unread,
Mar 29, 2021, 10:45:23 AM3/29/21
to DANPOS
Thank you so much for your feedback. When I converted the scripts from python2 to python3 this bug was most likely born. The two types treat numerical objects differently. This is the solution. Thanks for your help!
Sincerely,
Sammy

David Castillo Rodríguez

unread,
Mar 29, 2021, 11:13:03 AM3/29/21
to DANPOS
Hello Sammy,
happy to help. Unfortunately, soon after, I stumbled into a new problem: https://groups.google.com/g/danpos/c/J4T_va8XrE4
I decided to take a step back and use version 2.2.2. So far it has been working flawlessly : )
Cheers!
David
Reply all
Reply to author
Forward
0 new messages