scHiCExplorer icon indicating copy to clipboard operation
scHiCExplorer copied to clipboard

Error when running `scHicCorrectMatrices`

Open GMFranceschini opened this issue 1 year ago • 1 comments

I encounter the following error when running the correct matrices command.

scHicCorrectMatrices -m ./tmp/merge/ramani_normalized.scool -o ./tmp/merge/ramani_corrected.scool --threads 20
...
DOne i: 6
DOne i: 7
DOne i: 8
DOne i: 9
Traceback (most recent call last):
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/bin/scHicCorrectMatrices", line 7, in <module>
    main()
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/schicexplorer/scHicCorrectMatrices.py", line 169, in main
    matrixFileHandler.save(args.outFileName, pSymmetric=True, pApplyCorrection=False)
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/hicmatrix/lib/matrixFileHandler.py", line 57, in save
    self.matrixFile.save(pName, pSymmetric, pApplyCorrection)
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/hicmatrix/lib/scool.py", line 46, in save
    bins_dict[coolObject.matrixFile.matrixFileName] = bins_data_frame
TypeError: unhashable type: 'csr_matrix'

So far, the previous commands in the tutorial have run to completion with no apparent errors.

Other downstream tasks applied to the normalized matrix (skipping this step) also fail. I don't know if this is due to the missing correction or if those are separate errors. For example:

hicPlotMatrix -m ./tmp/merge/ramani_normalized.scool     --log1p -o ./tmp/merge/ramani_bulk.png --dpi 300     --fontsize 5 --rotationX 45

INFO:hicexplorer.hicPlotMatrix:Cooler or no cooler: False
Traceback (most recent call last):
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/bin/hicPlotMatrix", line 7, in <module>
    main()
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/hicexplorer/hicPlotMatrix.py", line 700, in main
    ma = HiCMatrix.hiCMatrix(args.matrix)
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/hicmatrix/HiCMatrix.py", line 56, in __init__
    matrixFileHandler_load = self.matrixFileHandler.load()
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/hicmatrix/lib/matrixFileHandler.py", line 51, in load
    return self.matrixFile.load()
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/hicmatrix/lib/cool.py", line 72, in load
    count_dtype = matrixDataFrame[0]['count'].dtype
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/cooler/core/_selectors.py", line 145, in __getitem__
    return self._slice(self.field, i0, i1, j0, j1)
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/cooler/api.py", line 384, in _slice
    self._is_symm_upper,
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/cooler/api.py", line 713, in matrix
    reader = CSRReader(h5['pixels'], h5['indexes/bin1_offset'][:])
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/h5py/_hl/group.py", line 288, in __getitem__
    oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5o.pyx", line 190, in h5py.h5o.open
KeyError: "Unable to open object (object 'pixels' doesn't exist)"

And

 scHicCluster -m ./tmp/merge/ramani_normalized.scool     --numberOfClusters 7 --clusterMethod kmeans -o ./tmp/merge/clusters_raw_kmeans.txt --threads 20
 
Traceback (most recent call last):
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/bin/scHicCluster", line 7, in <module>
    main()
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/schicexplorer/scHicCluster.py", line 200, in main
    labels_clustering = kmeans_object.fit_predict(neighborhood_matrix)
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/sklearn/cluster/_kmeans.py", line 1077, in fit_predict
    return self.fit(X, sample_weight=sample_weight).labels_
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/sklearn/cluster/_kmeans.py", line 982, in fit
    accept_large_sparse=False)
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/sklearn/base.py", line 421, in _validate_data
    X = check_array(X, **check_params)
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/sklearn/utils/validation.py", line 63, in inner_f
    return f(*args, **kwargs)
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/sklearn/utils/validation.py", line 653, in check_array
    accept_large_sparse=accept_large_sparse)
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/sklearn/utils/validation.py", line 414, in _ensure_sparse_format
    _check_large_sparse(spmatrix, accept_large_sparse)
  File "/mnt/data3/gianmarco/condaforge/envs/explorer/lib/python3.6/site-packages/sklearn/utils/validation.py", line 761, in _check_large_sparse
    % indices_datatype)
ValueError: Only sparse matrices with 32-bit integer indices are accepted. Got int64 indices.

Could you please advise? I can provide the scool file or any additional information.

GMFranceschini avatar Jan 25 '24 14:01 GMFranceschini

I get the same error when use schicexplorer v7, finally fixed scHicCorrectMatrices error by change to v5.

orangeSi avatar Jun 01 '24 16:06 orangeSi