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

AttributeError: ('PyRanges object has no attribute', 'Overlap') #267

Closed twoneu closed 11 months ago

twoneu commented 11 months ago

Describe the bug I am running the tutorial steps using the 10x PBMC dataset and have hit the error in the title at the run_pycistarget step.

To Reproduce

if not os.path.exists(os.path.join(work_dir, 'motifs')):
    os.makedirs(os.path.join(work_dir, 'motifs'))

from scenicplus.wrappers.run_pycistarget import run_pycistarget
run_pycistarget(
    region_sets = region_sets,
    species = 'homo_sapiens',
    save_path = os.path.join(work_dir, 'motifs'),
    ctx_db_path = rankings_db,
    dem_db_path = scores_db,
    path_to_motif_annotations = motif_annotation,
    run_without_promoters = True,
    n_cpu = 1,
    _temp_dir = os.path.join(tmp_dir, 'ray_spill'),
    annotation_version = 'v10nr_clust',
    )

Error output

2023-12-07 03:44:15,651 pycisTarget_wrapper INFO     pbmc_tutorial/motifs folder already exists.
2023-12-07 03:44:17,767 pycisTarget_wrapper INFO     Loading cisTarget database for topics_otsu
2023-12-07 03:44:17,768 cisTarget    INFO     Reading cisTarget database
2023-12-07 03:46:45,111 pycisTarget_wrapper INFO     Running cisTarget for topics_otsu
2023-12-07 03:46:45,113 cisTarget    INFO     Running cisTarget for Topic1 which has 9844 regions
2023-12-07 03:47:10,721 cisTarget    INFO     Annotating motifs for Topic1
2023-12-07 03:47:13,866 cisTarget    INFO     Getting cistromes for Topic1
2023-12-07 03:47:14,583 cisTarget    INFO     Running cisTarget for Topic2 which has 5011 regions
2023-12-07 03:47:32,625 cisTarget    INFO     Annotating motifs for Topic2
2023-12-07 03:47:35,044 cisTarget    INFO     Getting cistromes for Topic2
2023-12-07 03:47:35,636 cisTarget    INFO     Running cisTarget for Topic3 which has 4176 regions
2023-12-07 03:47:53,160 cisTarget    INFO     Annotating motifs for Topic3
2023-12-07 03:47:55,672 cisTarget    INFO     Getting cistromes for Topic3
2023-12-07 03:47:56,091 cisTarget    INFO     Running cisTarget for Topic4 which has 2904 regions
2023-12-07 03:48:14,624 cisTarget    INFO     Annotating motifs for Topic4
2023-12-07 03:48:17,198 cisTarget    INFO     Getting cistromes for Topic4
2023-12-07 03:48:17,871 cisTarget    INFO     Running cisTarget for Topic5 which has 3528 regions
2023-12-07 03:48:34,831 cisTarget    INFO     Annotating motifs for Topic5
2023-12-07 03:48:37,193 cisTarget    INFO     Getting cistromes for Topic5
2023-12-07 03:48:37,719 cisTarget    INFO     Running cisTarget for Topic6 which has 5832 regions
2023-12-07 03:48:56,224 cisTarget    INFO     Annotating motifs for Topic6
2023-12-07 03:48:58,738 cisTarget    INFO     Getting cistromes for Topic6
2023-12-07 03:48:59,348 cisTarget    INFO     Running cisTarget for Topic7 which has 5741 regions
2023-12-07 03:49:18,075 cisTarget    INFO     Annotating motifs for Topic7
2023-12-07 03:49:20,632 cisTarget    INFO     Getting cistromes for Topic7
2023-12-07 03:49:21,185 cisTarget    INFO     Running cisTarget for Topic8 which has 5883 regions
2023-12-07 03:49:40,334 cisTarget    INFO     Annotating motifs for Topic8
2023-12-07 03:49:42,989 cisTarget    INFO     Getting cistromes for Topic8
2023-12-07 03:49:43,678 cisTarget    INFO     Running cisTarget for Topic9 which has 7512 regions
2023-12-07 03:50:02,584 cisTarget    INFO     Annotating motifs for Topic9
2023-12-07 03:50:05,476 cisTarget    INFO     Getting cistromes for Topic9
2023-12-07 03:50:06,147 cisTarget    INFO     Running cisTarget for Topic10 which has 2144 regions
2023-12-07 03:50:24,346 cisTarget    INFO     Annotating motifs for Topic10
2023-12-07 03:50:26,983 cisTarget    INFO     Getting cistromes for Topic10
2023-12-07 03:50:27,661 cisTarget    INFO     Running cisTarget for Topic11 which has 3642 regions
2023-12-07 03:50:45,831 cisTarget    INFO     Annotating motifs for Topic11
2023-12-07 03:50:48,424 cisTarget    INFO     Getting cistromes for Topic11
2023-12-07 03:50:49,103 cisTarget    INFO     Running cisTarget for Topic12 which has 7061 regions
2023-12-07 03:51:09,450 cisTarget    INFO     Annotating motifs for Topic12
2023-12-07 03:51:13,543 cisTarget    INFO     Getting cistromes for Topic12
2023-12-07 03:51:14,391 cisTarget    INFO     Running cisTarget for Topic13 which has 6605 regions
2023-12-07 03:51:34,696 cisTarget    INFO     Annotating motifs for Topic13
2023-12-07 03:51:37,882 cisTarget    INFO     Getting cistromes for Topic13
2023-12-07 03:51:38,580 cisTarget    INFO     Running cisTarget for Topic14 which has 6266 regions
2023-12-07 03:51:59,067 cisTarget    INFO     Annotating motifs for Topic14
2023-12-07 03:52:02,202 cisTarget    INFO     Getting cistromes for Topic14
2023-12-07 03:52:03,032 cisTarget    INFO     Running cisTarget for Topic15 which has 5432 regions
2023-12-07 03:52:23,131 cisTarget    INFO     Annotating motifs for Topic15
2023-12-07 03:52:26,032 cisTarget    INFO     Getting cistromes for Topic15
2023-12-07 03:52:26,703 cisTarget    INFO     Running cisTarget for Topic16 which has 4799 regions
2023-12-07 03:52:44,761 cisTarget    INFO     Annotating motifs for Topic16
2023-12-07 03:52:47,471 cisTarget    INFO     Getting cistromes for Topic16
2023-12-07 03:52:48,153 cisTarget    INFO     Done!
2023-12-07 03:52:48,154 pycisTarget_wrapper INFO     pbmc_tutorial/motifs/CTX_topics_otsu_All folder already exists.
2023-12-07 03:52:48,377 pycisTarget_wrapper INFO     Running cisTarget without promoters for topics_otsu
2023-12-07 03:53:00,880 cisTarget    INFO     Running cisTarget for Topic1 which has 7943 regions
2023-12-07 03:53:21,170 cisTarget    INFO     Annotating motifs for Topic1
2023-12-07 03:53:24,327 cisTarget    INFO     Getting cistromes for Topic1
2023-12-07 03:53:24,940 cisTarget    INFO     Running cisTarget for Topic2 which has 3677 regions
2023-12-07 03:53:40,760 cisTarget    INFO     Annotating motifs for Topic2
2023-12-07 03:53:42,944 cisTarget    INFO     Getting cistromes for Topic2
2023-12-07 03:53:43,208 cisTarget    INFO     Running cisTarget for Topic3 which has 3204 regions
2023-12-07 03:54:01,157 cisTarget    INFO     Annotating motifs for Topic3
2023-12-07 03:54:03,715 cisTarget    INFO     Getting cistromes for Topic3
2023-12-07 03:54:04,206 cisTarget    INFO     Running cisTarget for Topic4 which has 905 regions
2023-12-07 03:54:21,098 cisTarget    INFO     Annotating motifs for Topic4
2023-12-07 03:54:23,239 cisTarget    INFO     Getting cistromes for Topic4
2023-12-07 03:54:23,781 cisTarget    INFO     Running cisTarget for Topic5 which has 2604 regions
2023-12-07 03:54:40,332 cisTarget    INFO     Annotating motifs for Topic5
2023-12-07 03:54:42,630 cisTarget    INFO     Getting cistromes for Topic5
2023-12-07 03:54:43,043 cisTarget    INFO     Running cisTarget for Topic6 which has 4331 regions
2023-12-07 03:55:00,219 cisTarget    INFO     Annotating motifs for Topic6
2023-12-07 03:55:02,536 cisTarget    INFO     Getting cistromes for Topic6
2023-12-07 03:55:02,983 cisTarget    INFO     Running cisTarget for Topic7 which has 4015 regions
2023-12-07 03:55:19,617 cisTarget    INFO     Annotating motifs for Topic7
2023-12-07 03:55:21,816 cisTarget    INFO     Getting cistromes for Topic7
2023-12-07 03:55:22,035 cisTarget    INFO     Running cisTarget for Topic8 which has 4571 regions
2023-12-07 03:55:40,428 cisTarget    INFO     Annotating motifs for Topic8
2023-12-07 03:55:42,980 cisTarget    INFO     Getting cistromes for Topic8
2023-12-07 03:55:43,411 cisTarget    INFO     Running cisTarget for Topic9 which has 5670 regions
2023-12-07 03:56:02,443 cisTarget    INFO     Annotating motifs for Topic9
2023-12-07 03:56:05,128 cisTarget    INFO     Getting cistromes for Topic9
2023-12-07 03:56:05,607 cisTarget    INFO     Running cisTarget for Topic10 which has 286 regions
2023-12-07 03:56:21,637 cisTarget    INFO     Annotating motifs for Topic10
2023-12-07 03:56:23,716 cisTarget    INFO     Getting cistromes for Topic10
2023-12-07 03:56:24,167 cisTarget    INFO     Running cisTarget for Topic11 which has 2537 regions
2023-12-07 03:56:41,991 cisTarget    INFO     Annotating motifs for Topic11
2023-12-07 03:56:44,472 cisTarget    INFO     Getting cistromes for Topic11
2023-12-07 03:56:44,943 cisTarget    INFO     Running cisTarget for Topic12 which has 682 regions
2023-12-07 03:57:01,354 cisTarget    INFO     Annotating motifs for Topic12
2023-12-07 03:57:03,534 cisTarget    INFO     Getting cistromes for Topic12
2023-12-07 03:57:04,074 cisTarget    INFO     Running cisTarget for Topic13 which has 5054 regions
2023-12-07 03:57:23,085 cisTarget    INFO     Annotating motifs for Topic13
2023-12-07 03:57:26,022 cisTarget    INFO     Getting cistromes for Topic13
2023-12-07 03:57:26,481 cisTarget    INFO     Running cisTarget for Topic14 which has 4597 regions
2023-12-07 03:57:45,510 cisTarget    INFO     Annotating motifs for Topic14
2023-12-07 03:57:48,327 cisTarget    INFO     Getting cistromes for Topic14
2023-12-07 03:57:48,794 cisTarget    INFO     Running cisTarget for Topic15 which has 4104 regions
2023-12-07 03:58:07,189 cisTarget    INFO     Annotating motifs for Topic15
2023-12-07 03:58:09,841 cisTarget    INFO     Getting cistromes for Topic15
2023-12-07 03:58:10,247 cisTarget    INFO     Running cisTarget for Topic16 which has 3111 regions
2023-12-07 03:58:28,106 cisTarget    INFO     Annotating motifs for Topic16
2023-12-07 03:58:30,661 cisTarget    INFO     Getting cistromes for Topic16
2023-12-07 03:58:31,251 cisTarget    INFO     Done!
2023-12-07 03:58:31,252 pycisTarget_wrapper INFO     pbmc_tutorial/motifs/CTX_topics_otsu_No_promoters folder already exists.
2023-12-07 03:58:31,463 pycisTarget_wrapper INFO     Running DEM for topics_otsu
2023-12-07 03:58:31,464 DEM          INFO     Reading DEM database
2023-12-07 04:00:48,031 DEM          INFO     Creating contrast groups
2023-12-07 04:01:09,304 DEM          INFO     Computing DEM for Topic1
2023-12-07 04:01:38,273 DEM          INFO     Computing DEM for Topic2
2023-12-07 04:01:48,320 DEM          INFO     Computing DEM for Topic3
2023-12-07 04:02:04,494 DEM          INFO     Computing DEM for Topic4
2023-12-07 04:02:22,400 DEM          INFO     Computing DEM for Topic5
2023-12-07 04:02:31,871 DEM          INFO     Computing DEM for Topic6
2023-12-07 04:02:43,023 DEM          INFO     Computing DEM for Topic7
2023-12-07 04:02:54,484 DEM          INFO     Computing DEM for Topic8
2023-12-07 04:03:06,033 DEM          INFO     Computing DEM for Topic9
2023-12-07 04:03:54,849 DEM          INFO     Computing DEM for Topic10
2023-12-07 04:04:25,581 DEM          INFO     Computing DEM for Topic11
2023-12-07 04:04:46,664 DEM          INFO     Computing DEM for Topic12
2023-12-07 04:06:35,469 DEM          INFO     Computing DEM for Topic13
2023-12-07 04:07:00,832 DEM          INFO     Computing DEM for Topic14
2023-12-07 04:07:25,969 DEM          INFO     Computing DEM for Topic15
2023-12-07 04:07:45,437 DEM          INFO     Computing DEM for Topic16
2023-12-07 04:07:58,723 DEM          INFO     Forming cistromes
2023-12-07 04:08:06,616 DEM          INFO     Done!
2023-12-07 04:08:06,617 pycisTarget_wrapper INFO     pbmc_tutorial/motifs/DEM_topics_otsu_All folder already exists.
2023-12-07 04:08:06,915 pycisTarget_wrapper INFO     Running DEM without promoters for topics_otsu
2023-12-07 04:08:20,119 DEM          INFO     Creating contrast groups
2023-12-07 04:08:23,519 DEM          INFO     Computing DEM for Topic1
2023-12-07 04:09:00,454 DEM          INFO     Computing DEM for Topic2
2023-12-07 04:09:08,976 DEM          INFO     Computing DEM for Topic3
2023-12-07 04:09:20,064 DEM          INFO     Computing DEM for Topic4
2023-12-07 04:09:36,398 DEM          INFO     Computing DEM for Topic5
2023-12-07 04:09:44,757 DEM          INFO     Computing DEM for Topic6
2023-12-07 04:09:53,745 DEM          INFO     Computing DEM for Topic7
2023-12-07 04:10:03,923 DEM          INFO     Computing DEM for Topic8
2023-12-07 04:10:15,658 DEM          INFO     Computing DEM for Topic9
2023-12-07 04:10:29,784 DEM          INFO     Computing DEM for Topic10
2023-12-07 04:10:40,765 DEM          INFO     Computing DEM for Topic11
2023-12-07 04:11:10,797 DEM          INFO     Computing DEM for Topic12
2023-12-07 04:11:27,917 DEM          INFO     Computing DEM for Topic13
2023-12-07 04:11:48,433 DEM          INFO     Computing DEM for Topic14
2023-12-07 04:12:01,511 DEM          INFO     Computing DEM for Topic15
2023-12-07 04:12:17,037 DEM          INFO     Computing DEM for Topic16
2023-12-07 04:12:39,944 DEM          INFO     Forming cistromes
2023-12-07 04:12:48,169 DEM          INFO     Done!
2023-12-07 04:12:48,170 pycisTarget_wrapper INFO     pbmc_tutorial/motifs/DEM_topics_otsu_No_promoters folder already exists.
2023-12-07 04:12:48,508 pycisTarget_wrapper INFO     Loading cisTarget database for topics_top_3
2023-12-07 04:12:48,509 cisTarget    INFO     Reading cisTarget database
2023-12-07 04:14:12,340 pycisTarget_wrapper INFO     Running cisTarget for topics_top_3
2023-12-07 04:14:12,342 cisTarget    INFO     Running cisTarget for Topic1 which has 3 regions
2023-12-07 04:14:26,882 cisTarget    INFO     Annotating motifs for Topic1
2023-12-07 04:14:28,887 cisTarget    INFO     Getting cistromes for Topic1
2023-12-07 04:14:29,289 cisTarget    INFO     Running cisTarget for Topic2 which has 5 regions
2023-12-07 04:14:43,862 cisTarget    INFO     Annotating motifs for Topic2
2023-12-07 04:14:45,895 cisTarget    INFO     Getting cistromes for Topic2
2023-12-07 04:14:46,318 cisTarget    INFO     Running cisTarget for Topic3 which has 4 regions
2023-12-07 04:15:03,419 cisTarget    INFO     Annotating motifs for Topic3
2023-12-07 04:15:05,454 cisTarget    INFO     Getting cistromes for Topic3
2023-12-07 04:15:05,983 cisTarget    INFO     Running cisTarget for Topic4 which has 5 regions
2023-12-07 04:15:23,241 cisTarget    INFO     Annotating motifs for Topic4
2023-12-07 04:15:25,284 cisTarget    INFO     Getting cistromes for Topic4
2023-12-07 04:15:25,910 cisTarget    INFO     Running cisTarget for Topic5 which has 4 regions
2023-12-07 04:15:44,368 cisTarget    INFO     Annotating motifs for Topic5
2023-12-07 04:15:46,418 cisTarget    INFO     Getting cistromes for Topic5
2023-12-07 04:15:47,095 cisTarget    INFO     Running cisTarget for Topic6 which has 5 regions
2023-12-07 04:16:05,191 cisTarget    INFO     Annotating motifs for Topic6
2023-12-07 04:16:07,245 cisTarget    INFO     Getting cistromes for Topic6
2023-12-07 04:16:07,890 cisTarget    INFO     Running cisTarget for Topic7 which has 6 regions
2023-12-07 04:16:26,729 cisTarget    INFO     Annotating motifs for Topic7
2023-12-07 04:16:28,803 cisTarget    INFO     Getting cistromes for Topic7
2023-12-07 04:16:29,560 cisTarget    INFO     Running cisTarget for Topic8 which has 3 regions
2023-12-07 04:16:46,451 cisTarget    INFO     Annotating motifs for Topic8
2023-12-07 04:16:48,494 cisTarget    INFO     Getting cistromes for Topic8
2023-12-07 04:16:49,046 cisTarget    INFO     Running cisTarget for Topic9 which has 3 regions
2023-12-07 04:17:06,568 cisTarget    INFO     Annotating motifs for Topic9
2023-12-07 04:17:08,630 cisTarget    INFO     Getting cistromes for Topic9
2023-12-07 04:17:09,212 cisTarget    INFO     Running cisTarget for Topic10 which has 4 regions
2023-12-07 04:17:27,268 cisTarget    INFO     Annotating motifs for Topic10
2023-12-07 04:17:29,330 cisTarget    INFO     Getting cistromes for Topic10
2023-12-07 04:17:29,845 cisTarget    INFO     Running cisTarget for Topic11 which has 3 regions
2023-12-07 04:17:45,852 cisTarget    INFO     Annotating motifs for Topic11
2023-12-07 04:17:47,904 cisTarget    INFO     Getting cistromes for Topic11
2023-12-07 04:17:48,304 cisTarget    INFO     Running cisTarget for Topic12 which has 4 regions
2023-12-07 04:18:06,290 cisTarget    INFO     Annotating motifs for Topic12
2023-12-07 04:18:08,358 cisTarget    INFO     Getting cistromes for Topic12
2023-12-07 04:18:09,003 cisTarget    INFO     Running cisTarget for Topic13 which has 3 regions
2023-12-07 04:18:24,230 cisTarget    INFO     Annotating motifs for Topic13
2023-12-07 04:18:26,270 cisTarget    INFO     Getting cistromes for Topic13
2023-12-07 04:18:26,499 cisTarget    INFO     Running cisTarget for Topic14 which has 3 regions
2023-12-07 04:18:43,308 cisTarget    INFO     Annotating motifs for Topic14
2023-12-07 04:18:45,376 cisTarget    INFO     Getting cistromes for Topic14
2023-12-07 04:18:45,819 cisTarget    INFO     Running cisTarget for Topic15 which has 3 regions
2023-12-07 04:19:00,797 cisTarget    INFO     Annotating motifs for Topic15
2023-12-07 04:19:02,838 cisTarget    INFO     Getting cistromes for Topic15
2023-12-07 04:19:03,105 cisTarget    INFO     Running cisTarget for Topic16 which has 5 regions
2023-12-07 04:19:21,756 cisTarget    INFO     Annotating motifs for Topic16
2023-12-07 04:19:23,817 cisTarget    INFO     Getting cistromes for Topic16
2023-12-07 04:19:24,583 cisTarget    INFO     Done!
2023-12-07 04:19:24,585 pycisTarget_wrapper INFO     pbmc_tutorial/motifs/CTX_topics_top_3_All folder already exists.
2023-12-07 04:19:24,852 pycisTarget_wrapper INFO     Running cisTarget without promoters for topics_top_3
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[12], line 5
      2     os.makedirs(os.path.join(work_dir, 'motifs'))
      4 from scenicplus.wrappers.run_pycistarget import run_pycistarget
----> 5 run_pycistarget(
      6     region_sets = region_sets,
      7     species = 'homo_sapiens',
      8     save_path = os.path.join(work_dir, 'motifs'),
      9     ctx_db_path = rankings_db,
     10     dem_db_path = scores_db,
     11     path_to_motif_annotations = motif_annotation,
     12     run_without_promoters = True,
     13     n_cpu = 1,
     14     _temp_dir = os.path.join(tmp_dir, 'ray_spill'),
     15     annotation_version = 'v10nr_clust',
     16     )

File ~/scenicplus/src/scenicplus/wrappers/run_pycistarget.py:224, in run_pycistarget(region_sets, species, save_path, custom_annot, save_partial, ctx_db_path, dem_db_path, run_without_promoters, biomart_host, promoter_space, ctx_auc_threshold, ctx_nes_threshold, ctx_rank_threshold, dem_log2fc_thr, dem_motif_hit_thr, dem_max_bg_regions, annotation, motif_similarity_fdr, path_to_motif_annotations, annotation_version, n_cpu, _temp_dir, exclude_motifs, exclude_collection, **kwargs)
    222 regions_np = {key: regions_overlaps[key][regions_overlaps[key].NumberOverlaps == 0][['Chromosome', 'Start', 'End']] for key in regions.keys()}
    223 db_regions = set(pd.concat([ctx_db.regions_to_db[x] for x in ctx_db.regions_to_db.keys()])['Query'])
--> 224 ctx_db.regions_to_db = {x: target_to_query(regions_np[x], list(db_regions), fraction_overlap = 0.4) for x in regions_np.keys()}
    225 menr['CTX_'+key+'_No_promoters'] = run_cistarget(ctx_db = ctx_db,
    226                    region_sets = regions_np,
    227                    specie = species,
   (...)
    236                    annotation_version = annotation_version,
    237                    **kwargs)
    238 out_folder = os.path.join(save_path,'CTX_'+key+'_No_promoters')

File ~/scenicplus/src/scenicplus/wrappers/run_pycistarget.py:224, in <dictcomp>(.0)
    222 regions_np = {key: regions_overlaps[key][regions_overlaps[key].NumberOverlaps == 0][['Chromosome', 'Start', 'End']] for key in regions.keys()}
    223 db_regions = set(pd.concat([ctx_db.regions_to_db[x] for x in ctx_db.regions_to_db.keys()])['Query'])
--> 224 ctx_db.regions_to_db = {x: target_to_query(regions_np[x], list(db_regions), fraction_overlap = 0.4) for x in regions_np.keys()}
    225 menr['CTX_'+key+'_No_promoters'] = run_cistarget(ctx_db = ctx_db,
    226                    region_sets = regions_np,
    227                    specie = species,
   (...)
    236                    annotation_version = annotation_version,
    237                    **kwargs)
    238 out_folder = os.path.join(save_path,'CTX_'+key+'_No_promoters')

File ~/.local/lib/python3.10/site-packages/pycistarget/utils.py:283, in target_to_query(target, query, fraction_overlap)
    280     query_pr=query
    282 join_pr = target_pr.join(query_pr, report_overlap = True)
--> 283 join_pr.Overlap_query =  join_pr.Overlap/(join_pr.End_b - join_pr.Start_b)
    284 join_pr.Overlap_target =  join_pr.Overlap/(join_pr.End - join_pr.Start)
    285 join_pr = join_pr[(join_pr.Overlap_query > fraction_overlap) | (join_pr.Overlap_target > fraction_overlap)]

File ~/.local/lib/python3.10/site-packages/pyranges/pyranges_main.py:265, in PyRanges.__getattr__(self, name)
    240 """Return column.
    241 
    242 Parameters
   (...)
    260 Name: Start, dtype: int64
    261 """
    263 from pyranges.methods.attr import _getattr
--> 265 return _getattr(self, name)

File ~/.local/lib/python3.10/site-packages/pyranges/methods/attr.py:65, in _getattr(self, name)
     63     return pd.concat([df[name] for df in self.values()])
     64 else:
---> 65     raise AttributeError("PyRanges object has no attribute", name)

AttributeError: ('PyRanges object has no attribute', 'Overlap')

Expected behavior I also ran the following code upstream of run_pycistarget to ensure there were no empty dictionary entries:

#get rid of empty regions in dictionary
for DAR in markers_dict.keys():
    if markers_dict[DAR].empty:
        continue
    regions = markers_dict[DAR].index[markers_dict[DAR].index.str.startswith('chr')] #only keep regions on known chromosomes
    region_sets['DARs'][DAR] = pr.PyRanges(region_names_to_coordinates(regions))

No topics were printed out using the following test code:

from ctxcore.rnkdb import FeatherRankingDatabase
from pycistarget.utils import target_to_query

db = FeatherRankingDatabase(rankings_db, name ='test')
db_regions = db.genes

for topic in region_sets['topics_otsu'].keys():
    try:
      overlapping_regions =  target_to_query(
          region_sets['topics_otsu'][topic], 
          list(db_regions), 
          fraction_overlap = 0.4)
    except:
      print(topic)

Version (please complete the following information):

Additional context N/A

SeppeDeWinter commented 11 months ago

Hi @twoneu

The reason for this is that all the regions in that topic overlap with promoters, resulting in an empty pyranges object. Your topic for topics_top_3only have a very limited amount of regions (3-8), this is really too low to perform motif enirchment analysis and probably also the reason why you are ending up with empty pyranges objects.

Try increasing the number of regions for this set of topics (maybe you meant to take top 3000 and accidentally specified top 3 regions?).

I hope this helps to resolve the issue.

All the best and good luck with the analysis,

Seppe

twoneu commented 11 months ago

I did accidentally write 3 instead of 3000. Thank you so much!