aertslab / scenicplus

SCENIC+ is a python package to build gene regulatory networks (GRNs) using combined or separate single-cell gene expression (scRNA-seq) and single-cell chromatin accessibility (scATAC-seq) data.
Other
186 stars 29 forks source link

pycisTopic.iterative_peak_calling: IndexError: list index out of range #388

Closed hshcao closed 6 months ago

hshcao commented 6 months ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce

from pycisTopic.iterative_peak_calling import get_consensus_peaks

Other param

peak_half_width=250 path_to_blacklist="pycisTopic/blacklist/hg38-blacklist.v2.bed"

Get consensus peaks

consensus_peaks = get_consensus_peaks( narrow_peaks_dict = narrow_peak_dict, peak_half_width = peak_half_width, chromsizes = chromsizes, path_to_blacklist = path_to_blacklist)

Error output

2024-05-06 23:30:20,024 cisTopic INFO Extending and merging peaks per class { "name": "IndexError", "message": "list index out of range", "stack": "--------------------------------------------------------------------------- IndexError Traceback (most recent call last) Cell In[29], line 6 4 path_to_blacklist='data/hg38-blacklist.v2.bed' 5 # Get consensus peaks ----> 6 consensus_peaks = get_consensus_peaks( 7 narrow_peaks_dict = narrow_peak_dict, 8 peak_half_width = peak_half_width, 9 chromsizes = chromsizes, 10 path_to_blacklist = path_to_blacklist)

File ~/anaconda3/envs/scenicplus/lib/python3.11/site-packages/pycisTopic/iterative_peak_calling.py:66, in get_consensus_peaks(narrow_peaks_dict, peak_half_width, chromsizes, path_to_blacklist) 63 chromsizes = pr.PyRanges(chromsizes) 65 log.info(\"Extending and merging peaks per class\") ---> 66 center_extended_peaks = [ 67 iterative_peak_filtering( 68 calculate_peaks_and_extend( 69 narrow_peaks_dict[x], peak_half_width, chromsizes, path_to_blacklist 70 ) 71 ).df 72 for x in list(narrow_peaks_dict.keys()) 73 ] 74 log.info(\"Normalizing peak scores\") 75 center_extended_peaks_norm = [cpm(x, \"Score\") for x in center_extended_peaks]

File ~/anaconda3/envs/scenicplus/lib/python3.11/site-packages/pycisTopic/iterative_peak_calling.py:68, in (.0) 63 chromsizes = pr.PyRanges(chromsizes) 65 log.info(\"Extending and merging peaks per class\") 66 center_extended_peaks = [ 67 iterative_peak_filtering( ---> 68 calculate_peaks_and_extend( 69 narrow_peaks_dict[x], peak_half_width, chromsizes, path_to_blacklist 70 ) 71 ).df 72 for x in list(narrow_peaks_dict.keys()) 73 ] 74 log.info(\"Normalizing peak scores\") 75 center_extended_peaks_norm = [cpm(x, \"Score\") for x in center_extended_peaks]

File ~/anaconda3/envs/scenicplus/lib/python3.11/site-packages/pycisTopic/iterative_peak_calling.py:144, in calculate_peaks_and_extend(narrow_peaks, peak_half_width, chromsizes, path_to_blacklist) 140 center_extended_peaks = center_extended_peaks.intersect( 141 chromsizes, how=\"containment\" 142 ) 143 if isinstance(path_to_blacklist, str): --> 144 blacklist = pr.read_bed(path_to_blacklist) 145 center_extended_peaks = center_extended_peaks.overlap(blacklist, invert=True) 146 return center_extended_peaks

File ~/anaconda3/envs/scenicplus/lib/python3.11/site-packages/pyranges/readers.py:79, in read_bed(f, as_df, nrows) 77 first_start = gzip.open(f).readline().split()[1] 78 else: ---> 79 first_start = open(f).readline().split()[1] 81 header = None 83 try:

IndexError: list index out of range" }

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem or show the format of the input data for the command/s.

Version (please complete the following information):

Additional context Add any other context about the problem here.

SeppeDeWinter commented 6 months ago

Hi @hshcao

Could it be that (one of) your peak files is empty? Please check the files listed in narrow_peak_dict.

Best,

Seppe

hshcao commented 6 months ago

@SeppeDeWinter I used the exact codes provided in this tutorial and did not make changes, unless some paths (but not file names). no empty files. https://pycistopic.readthedocs.io/en/latest/notebooks/human_cerebellum.html#Downloading-data

hshcao commented 6 months ago
Screenshot 2024-05-19 at 1 32 50 PM

here is screenshot of the narrow_peak_dict dictionary

hshcao commented 6 months ago

the problem solved by downloading a real bed file