filipinascimento / bl-network-communities

App to obtain the community structure of networks by using the Louvain or Infomap methods. All the Louvain quality functions work for networks with negative weights.
MIT License
0 stars 0 forks source link

BaseException: Could not construct partition: Cannot accept negative weights. #1

Closed soichih closed 4 years ago

soichih commented 4 years ago

I just ran a test job for this App and it failed with the following error message.

+ chmod +x main.py
+ SINGULARITYENV_PYTHONNOUSERSITE=true
+ singularity exec -e docker://filsilva/cxnetwork:0.1.0 ./main.py config.json

  0%|          | 0/1 [00:00<?, ?it/s]
  0%|          | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/export/prod/5e7cb6993138f72c9f30cb46/5e7cb69a3138f734be30cb49/main.py", line 148, in <module>
    membership = louvain.find_partition(g,louvain.ModularityVertexPartition, weights=weightsProperty).membership
  File "/usr/local/lib/python3.7/site-packages/louvain/functions.py", line 76, in find_partition
    **kwargs)
  File "/usr/local/lib/python3.7/site-packages/louvain/VertexPartition.py", line 442, in __init__
    initial_membership, weights)
BaseException: Could not construct partition: Cannot accept negative weights.

Here is the test process

https://brainlife.io/project/5d64733db29ac960ca2e797f/process/5e7cb6993138f72c9f30cb46#5e7cb69a3138f734be30cb49

I am using a test output stored in the App Test project, and I do see some negative values.

image

It might be a problem with @faskowit 's app-fmri-2-mat App, or the fmriprep output.. I haven't investigated this yet.

faskowit commented 4 years ago

fyi, negative weights are indeed expected to show up a functional connectivity network. Since a func conn network is just a bunch of correlations between time series at each node, we expect that some time series are negatively correlated. Some practitioners choose to discard the negative weights by setting them to '0'. Doing such an operation (applying a threshold to the network) should be done for a specific purpose... since it's a decision that affects network topology.

On Thu, Mar 26, 2020 at 10:14 AM Soichi Hayashi notifications@github.com wrote:

I just ran a test job for this App and it failed with the following error message.

  • chmod +x main.py
  • SINGULARITYENV_PYTHONNOUSERSITE=true
  • singularity exec -e docker://filsilva/cxnetwork:0.1.0 ./main.py config.json

    0%| | 0/1 [00:00<?, ?it/s] 0%| | 0/1 [00:00<?, ?it/s] Traceback (most recent call last): File "/export/prod/5e7cb6993138f72c9f30cb46/5e7cb69a3138f734be30cb49/main.py", line 148, in membership = louvain.find_partition(g,louvain.ModularityVertexPartition, weights=weightsProperty).membership File "/usr/local/lib/python3.7/site-packages/louvain/functions.py", line 76, in find_partition **kwargs) File "/usr/local/lib/python3.7/site-packages/louvain/VertexPartition.py", line 442, in init initial_membership, weights) BaseException: Could not construct partition: Cannot accept negative weights.

Here is the test process

https://brainlife.io/project/5d64733db29ac960ca2e797f/process/5e7cb6993138f72c9f30cb46#5e7cb69a3138f734be30cb49

I am using a test output stored in the App Test project, and I do see some negative values.

[image: image] https://user-images.githubusercontent.com/923896/77656373-265b4480-6f4a-11ea-9971-7e5eea2f661c.png

It might be a problem with @faskowit https://github.com/faskowit 's app-fmri-2-mat App, or the fmriprep output.. I haven't investigated this yet.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/filipinascimento/bl-network-communities/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZHY5BMXOK3PCSQHB3VMHTRJNPJTANCNFSM4LUIMRWA .

filipinascimento commented 4 years ago

Only the Clique Percolation Method (CPM) method works for negative weights out of the box. On all other cases, the Network Preprocessor app is needed to takes care of negative weights. With this app you can separate the negative and positive relationships or use the abstract value to generate another preprocessed conmat file. I will add this to the App description.

faskowit commented 4 years ago

for running louvain, couldn't you use a modularity null model that incorporates negative weights? In the brain connectivity toolbox (matlab) we have this. This python port of BCT also has it: https://github.com/fiuneuro/brainconn/blob/master/brainconn/modularity/modularity.py#L69

it's just, thresholding the matrix at 0 is not really that great for brain networks... we try to avoid it when possible -- the reason is that negative weights could be meaningful for these correlation matrices.

faskowit commented 4 years ago

or here too: https://github.com/fiuneuro/brainconn/blob/master/brainconn/modularity/modularity.py#L1146

filipinascimento commented 4 years ago

Thanks for pointing this out. It makes sense then to add this implementation of signed modularity to the App. I'm not familiar with the normalization they use in BCT and implications of these changes to modularity, do you know the reference for this method? I know the method from Vincent (https://arxiv.org/abs/0811.2329 ), but not sure if this is used in neuroscience. Ok, found it. It is described in

Rubinov, M., & Sporns, O. (2011). Weight-conserving characterization of complex functional brain networks. NeuroImage, 56(4), 2068–2079. doi:10.1016/j.neuroimage.2011.03.069

faskowit commented 4 years ago

And here is an open pdf! http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.727.3049&rep=rep1&type=pdf