saezlab / decoupler-py

Python package to perform enrichment analysis from omics data.
https://decoupler-py.readthedocs.io/
GNU General Public License v3.0
157 stars 23 forks source link

shuffle_nets function produces networks with repeated edges #81

Closed IBMB-MFP closed 11 months ago

IBMB-MFP commented 12 months ago

Hi, using decoupler for python version 1.4.0 I have the problem with the newly added shuffle_net feature. My networks have a large number of targets and when I shuffle them and try to call decouple with the shuffled network, I get the errror:

ValueError: net contains repeated edges, please remove them.

I assume this is because many of the targets are repeated and the shuffling process doesn't ensure that the same target isn't assigned to the same source more than once.

PauBadiaM commented 12 months ago

Hi @IBMB-MFP,

Indeed this is expected since by random chance it can happen, just remove the duplicates afterwards like this:

rnet = dc.shuffle_net(net, target='target', weight='weight').drop_duplicates(['source', 'target'])

Hope this is helpful!