scenicplus icon indicating copy to clipboard operation
scenicplus copied to clipboard

Passing a set as an indexer is not supported. Use a list instead.

Open Meiyuhaha opened this issue 9 months ago • 4 comments

Hi Seppe,

I have an issue with this step:

consensus_peaks.to_bed(
    path = os.path.join(work_dir, 'scATAC/consensus_peak_calling/consensus_regions.bed'),
    keep=True,
    compression='infer',
    chain=False)

TypeError                                 Traceback (most recent call last)
Cell In[26], line 1
----> 1 consensus_peaks.to_bed(
      2     path = os.path.join(work_dir, 'scATAC/consensus_peak_calling/consensus_regions.bed'),
      3     keep=True,
      4     compression='infer',
      5     chain=False)

File /media/data1/zli/miniconda/envs/scenicplus/lib/python3.11/site-packages/pyranges/pyranges.py:4894, in PyRanges.to_bed(self, path, keep, compression, chain)
   4831 r"""Write to bed.
   4832 
   4833 Parameters
   (...)
   4890 ['chr1\t1\t5\t[.\t.\t](http://rna.ucsf.edu:8787/s/d6f2021f2ed724dc36a2a/lab/tree/scRNA/t./t)+\t1\n', 'chr1\t6\t8\t[.\t.\t-\t2\n](http://rna.ucsf.edu:8787/s/d6f2021f2ed724dc36a2a/lab/tree/scRNA/t./t-/t2/n)']
   4891 """
   4892 from pyranges.out import _to_bed
-> 4894 result = _to_bed(self, path, keep=keep, compression=compression)
   4896 if path and chain:
   4897     return self

File /media/data1/zli/miniconda/envs/scenicplus/lib/python3.11/site-packages/pyranges/out.py:129, in _to_bed(self, path, sep, keep, compression)
    126 gr = self
    128 outdfs = natsorted(gr.dfs.items())
--> 129 outdfs = [_bed(df, keep) for _, df in outdfs]
    131 if path:
    132     mode = "w+"

File /media/data1/zli/miniconda/envs/scenicplus/lib/python3.11/site-packages/pyranges/out.py:129, in <listcomp>(.0)
    126 gr = self
    128 outdfs = natsorted(gr.dfs.items())
--> 129 outdfs = [_bed(df, keep) for _, df in outdfs]
    131 if path:
    132     mode = "w+"

File /media/data1/zli/miniconda/envs/scenicplus/lib/python3.11/site-packages/pyranges/out.py:37, in _bed(df, keep)
     34 noncanonical = set(df.columns) - set(all_columns)
     36 if keep:
---> 37     return pd.concat([outdf, df.get(noncanonical)], axis=1)
     38 else:
     39     return outdf

File ~/.local/lib/python3.11/site-packages/pandas/core/generic.py:4581, in NDFrame.get(self, key, default)
   4528 """
   4529 Get item from object for given key (ex: DataFrame column).
   4530 
   (...)
   4578 '[unknown]'
   4579 """
   4580 try:
-> 4581     return self[key]
   4582 except (KeyError, ValueError, IndexError):
   4583     return default

File ~/.local/lib/python3.11/site-packages/pandas/core/frame.py:4063, in DataFrame.__getitem__(self, key)
   4062 def __getitem__(self, key):
-> 4063     check_dict_or_set_indexers(key)
   4064     key = lib.item_from_zerodim(key)
   4065     key = com.apply_if_callable(key, self)

File ~/.local/lib/python3.11/site-packages/pandas/core/indexing.py:2774, in check_dict_or_set_indexers(key)
   2766 """
   2767 Check if the indexer is or contains a dict or set, which is no longer allowed.
   2768 """
   2769 if (
   2770     isinstance(key, set)
   2771     or isinstance(key, tuple)
   2772     and any(isinstance(x, set) for x in key)
   2773 ):
-> 2774     raise TypeError(
   2775         "Passing a set as an indexer is not supported. Use a list instead."
   2776     )
   2778 if (
   2779     isinstance(key, dict)
   2780     or isinstance(key, tuple)
   2781     and any(isinstance(x, dict) for x in key)
   2782 ):
   2783     raise TypeError(
   2784         "Passing a dict as an indexer is not supported. Use a list instead."
   2785     )

TypeError: Passing a set as an indexer is not supported. Use a list instead.

Much appreciated!

Meiyuhaha avatar May 11 '24 07:05 Meiyuhaha

Hi @Meiyuhaha

This seems to be an incompatibility between pandas and pyranges.

What versions do you have for both packages?

Best,

Seppe

SeppeDeWinter avatar May 15 '24 07:05 SeppeDeWinter

Hi @SeppeDeWinter ,

Thank you for your reply.

The versions of the packages are:

pandas 1.5.0 pyranges 0.0.111

Now I also have another trouble when I run the scenicplus pipline:

TypeError: descriptor 'call' for 'type' objects doesn't apply to a 'property' object [Fri May 17 23:59:25 2024] Error in rule region_to_gene: jobid: 10 input: /home/zli/outputs/ACC_GEX.h5mu, /home/zli/outputs/search_space.tsv output: /home/zli/outputs/region_to_gene_adj.tsv shell:

    scenicplus grn_inference region_to_gene             --multiome_mudata_fname /home/zli/outputs/ACC_GEX.h5mu             --search_space_fname /home/zli/outputs/search_space.tsv             --temp_dir /home/zli/outputs/tmp             --out_region_to_gene_adjacencies /home/zli/outputs/region_to_gene_adj.tsv             --importance_scoring_method GBM             --correlation_scoring_method SR             --n_cpu 40
    
    (one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)

Shutting down, this might take some time. Exiting because a job execution failed. Look above for error message Complete log: .snakemake/log/2024-05-17T235847.987448.snakemake.log WorkflowError: At least one job did not complete successfully.

Looking forward to your reply. Thank you!

Meiyuhaha avatar May 18 '24 07:05 Meiyuhaha

Hi @Meiyuhaha

Is this the full error log? Could you please post the full log, I'm not able to see where things go wrong here.

Best,

Seppe

SeppeDeWinter avatar May 21 '24 10:05 SeppeDeWinter

Hi, I have the same issue. this is the command: consensus_peaks.to_bed( path = os.path.join(out_dir, "consensus_peak_calling/consensus_regions.bed"), keep =True, compression = 'infer', chain = False)

this the error:

TypeError: Passing a set as an indexer is not supported. Use a list instead.

pandas 1.5.0 pyranges 0.0.111

and I think the problem is what you said, there is an incompatibility between pandas and pyranges. other packages also the same problem, like https://github.com/pm4py/pm4py-core/issues/486 any chance the support team could help with this problem

thanks

Best Helene

HeleneZhao avatar Aug 16 '24 20:08 HeleneZhao