1
votes

I am running one simple python program with my files. This program works fine on one of my machines with the file, fileA.bed. But this program doesn't work in another machine with the same file. I installed same python version, 2.7.6, same required modules, scipy ('0.15.1'), numpy('1.8.2'), iced ('0.2.2-git') (same versions in both machines). The error message is something about ValueError: column index exceeds matrix dimensions (please see below). Could you please help, what could cause this problem?

python Dense.py -b fileA.bed 

Traceback (most recent call last):
  File "Dense.py", line 34, in <module>
    counts = io.load_counts(args.filename, lengths=lengths)
  File "$PATH/Python-2.7.6/venv_iced_2.2/lib/python2.7/site-packages/iced/io/_io_else.py", line 30, in load_counts
    counts = sparse.coo_matrix((X[:, 2], (X[:, 0], X[:, 1])), shape=shape)
  File "$PATH/Python-2.7.6/venv_iced_2.2/lib/python2.7/site-packages/scipy/sparse/coo.py", line 206, in __init__
    self._check()
  File "$PATH/Python-2.7.6/venv_iced_2.2/lib/python2.7/site-packages/scipy/sparse/coo.py", line 262, in _check
    raise ValueError('column index exceeds matrix dimensions')
ValueError: column index exceeds matrix dimensions
1

1 Answers

3
votes

I can reproduce this error by creating a sparse.coo_matrix with:

In [1075]: sparse.coo_matrix(([1,1,1],([0,1,1],[0,1,3])), shape=(2,3))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1075-40a6338a3244> in <module>()
----> 1 sparse.coo_matrix(([1,1,1],([0,1,1],[0,1,3])), shape=(2,3))

/usr/lib/python3/dist-packages/scipy/sparse/coo.py in __init__(self, arg1, shape, dtype, copy)
    180             self.data = self.data.astype(dtype)
    181 
--> 182         self._check()
    183 
    184     def getnnz(self, axis=None):

/usr/lib/python3/dist-packages/scipy/sparse/coo.py in _check(self)
    236                 raise ValueError('row index exceeds matrix dimensions')
    237             if self.col.max() >= self.shape[1]:
--> 238                 raise ValueError('column index exceeds matrix dimensions')
    239             if self.row.min() < 0:
    240                 raise ValueError('negative row index found')

ValueError: column index exceeds matrix dimensions

I'm telling it that the matrix should be 2x3, but one of the column values is 3, where as it should be in the [0,3) range (less than 3).

I know nothing about your iced package, or the data in the file that it apparently is trying to load. But hopefully this gives you an idea of where to search for the problem.