Closed g1g122 closed 3 months ago
You need to either update cooler to the latest version, or downgrade it to v0.9.3
You need to either update cooler to the latest version, or downgrade it to v0.9.3
Thank you so much for your help! Following your suggestions, my issue has been resolved. I really appreciate your guidance and prompt response!!
Happy to help!
Description: I encountered an IndexError while running the TAD analysis script on chromosome regions chr1 and chr2. The error seems to occur during the insulation score calculation step in the cooltools package. Below are the details of the error and the relevant code snippets.
Error Traceback: INFO:root:fallback to serial implementation. INFO:root:Processing region chr1 INFO:root:Processing region chr2 Traceback (most recent call last): File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/pandas/core/indexing.py", line 1714, in _get_list_axis return self.obj._take_with_is_copy(key, axis=axis) File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/pandas/core/generic.py", line 4150, in _take_with_is_copy result = self.take(indices=indices, axis=axis) File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/pandas/core/generic.py", line 4130, in take new_data = self._mgr.take( File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/pandas/core/internals/managers.py", line 891, in take indexer = maybe_convert_indices(indexer, n, verify=verify) File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/pandas/core/indexers/utils.py", line 282, in maybe_convert_indices raise IndexError("indices are out-of-bounds") IndexError: indices are out-of-bounds
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/home/yhzheng/Projects/Omics/CodeTest/TEST_TAD_analysis/TAD_analysis.py", line 206, in
analyze_and_visualize(hg38_dir, hg38_output_dir, resolution, region, test)
File "/home/yhzheng/Projects/Omics/CodeTest/TEST_TAD_analysis/TAD_analysis.py", line 63, in analyze_and_visualize
insulation_table = insulation(clr, windows, verbose=True)
File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/cooltools/api/insulation.py", line 713, in insulation
ins_table = calculate_insulation_score(
File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/cooltools/lib/common.py", line 541, in wrapper
result = func(*args, **kwargs, map_functor=mymap)
File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/cooltools/api/insulation.py", line 275, in calculate_insulation_score
ins_table = pd.concat(ins_region_tables)
File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/pandas/core/reshape/concat.py", line 382, in concat
op = _Concatenator(
File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/pandas/core/reshape/concat.py", line 445, in init
objs, keys = self._clean_keys_and_objs(objs, keys)
File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/pandas/core/reshape/concat.py", line 504, in _clean_keys_and_objs
objs_list = list(objs)
File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/cooltools/api/insulation.py", line 331, in _get_region_insulation
ins_track, n_pixels, sum_balanced, sum_counts = insul_diamond(
File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/cooltools/api/insulation.py", line 111, in insul_diamond
diag_pixels = cooler.annotate(diag_pixels, bins[[clr_weight_name]])
File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/cooler/api.py", line 634, in annotate
ann1.iloc[bin1 - bmin]
File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/pandas/core/indexing.py", line 1191, in getitem
return self._getitem_axis(maybe_callable, axis=axis)
File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/pandas/core/indexing.py", line 1743, in _getitem_axis
return self._get_list_axis(key, axis=axis)
File "/home/yhzheng/Software/anaconda3/envs/omics/lib/python3.9/site-packages/pandas/core/indexing.py", line 1717, in _get_list_axis
raise IndexError("positional indexers are out-of-bounds") from err
IndexError: positional indexers are out-of-bounds
Relevant Code: clr = cooler.Cooler(f'{mcool_file}::resolutions/{resolution}') windows = [3resolution, 5resolution, 10resolution, 25resolution] insulation_table = insulation(clr, windows, verbose=True)
Environment: Python version: 3.9 cooltools version: 0.7.0
Any help or guidance on resolving this issue would be greatly appreciated. Thank you!