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.
1 answer
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".
Log in to answer this question.
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?
Thank you for your reply. Below is the message:
I have the following lines in my bed with 32 in it.
Can you
grep eon your BED file?Okay thanks for this tip. Here is what I get:
So my guess is when I am exporting the file from R, then the problem is arising?
Yup, exactly
Looking at the error you may have scientific notation for some of the values. How was the bed generated?
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.
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.