Deeptools ValueError: invalid literal for int() with base 10 error
1
0
Entering edit mode
3.7 years ago
das2000sidd ▴ 30

Hi

I am using deeptools for some heatmap plotting and I am running into an error that have never run into before while using deeptools.

The error says: if int(cols[1]) >= int(cols[2]): ValueError: invalid literal for int() with base 10: '3.2e+07'

As I understand, while checking if the third column is larger than the second one in the bed file, a string value was interpreted when an integer was expected. Note that my bed file is a tab delimited text file with no quotes.

Can someone suggest what might be causing the issue here?

Thank you and appreciate the help.

deeptools ChIP-Seq • 4.3k views
ADD COMMENT
1
Entering edit mode

Looking at the error you may have scientific notation for some of the values. How was the bed generated?

ADD REPLY
0
Entering edit mode

I first used biomart database to pull out the coordinates and then I saved the chromosome, start, stop, ensemble id and strand in a tab delimited file and used that file.

ADD REPLY
0
Entering edit mode

Before you save the file, disable scientific notation in R options(scipen=999). You likely have values written as literal scientific notation strings in some of the columns.

ADD REPLY
0
Entering edit mode

Can you post the command you used and the entire error message? Do you have a position in your BED file of literally 3.2e+07?

ADD REPLY
0
Entering edit mode

Thank you for your reply. Below is the message:

Traceback (most recent call last):
  File "/hpc/software/deeptools/3.1.1/bin/computeMatrix", line 14, in <module>
    main(args)
  File "/software/deeptools/3.1.1/lib/python3.6/site-packages/deeptools/computeMatrix.py", line 421, in main
    hm.computeMatrix(scores_file_list, args.regionsFileName, parameters, blackListFileName=args.blackListFileName, verbose=args.verbose, allArgs=args)
  File "/software/deeptools/3.1.1/lib/python3.6/site-packages/deeptools/heatmapper.py", line 264, in computeMatrix
    verbose=verbose)
  File "/software/deeptools/3.1.1/lib/python3.6/site-packages/deeptools/mapReduce.py", line 85, in mapReduce
    bed_interval_tree = GTF(bedFile, defaultGroup=defaultGroup, transcriptID=transcriptID, exonID=exonID, transcript_id_designator=transcript_id_designator, keepExons=keepExons)
  File "/software/deeptools/3.1.1/lib/python3.6/site-packages/deeptoolsintervals/parse.py", line 595, in __init__
    self.parseBED(fp, line, 3, labelColumn)
  File "/software/deeptools/3.1.1/lib/python3.6/site-packages/deeptoolsintervals/parse.py", line 362, in parseBED
    self.parseBEDcore(line, ncols)
  File "/software/deeptools/3.1.1/lib/python3.6/site-packages/deeptoolsintervals/parse.py", line 228, in parseBEDcore
    if int(cols[1]) >= int(cols[2]):
ValueError: invalid literal for int() with base 10: '3.2e+07'
/software/anaconda3.6/lib/python3.6/site-packages/plotly/tools.py:103: UserWarning:

I have the following lines in my bed with 32 in it.

chr5    31926812    32000000    ENSMUSG00000029136  -
chr5    32000057    32387335    ENSMUSG00000052139  +
ADD REPLY
0
Entering edit mode

Can you grep e on your BED file?

ADD REPLY
0
Entering edit mode

Okay thanks for this tip. Here is what I get:

chr5    31926812    3.2e+07 ENSMUSG00000029136  -
chr5    31926812    3.2e+07 ENSMUSG00000029136  -

So my guess is when I am exporting the file from R, then the problem is arising?

ADD REPLY
0
Entering edit mode

Yup, exactly

ADD REPLY
0
Entering edit mode
3.3 years ago
delonbest • 0

The error message invalid literal for int() with base 10 would seem to indicate that you are passing a string that's not an integer to the int() function . In other words it's either empty, or has a character in it other than a digit. You can solve this error by using Python isdigit() method to check whether the value is number or not. The returns True if all the characters are digits, otherwise False . The other way to overcome this issue is to wrap your code inside a Python try...except block to handle this error.

Sometimes the difference between Python2.x and Python3.x that leads to this ValueError: invalid literal for int() with base 10 . With Python2.x , int(str(3/2)) gives you "1". With Python3.x , the same gives you ("1.5"): ValueError: invalid literal for int() with base 10: "1.5".

ADD COMMENT

Login before adding your answer.

Traffic: 3205 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6