mnets / pymnet

The original library for analyzing multilayer networks.
https://mnets.github.io/pymnet/
GNU General Public License v3.0
118 stars 24 forks source link

Error when creating a four-layer multilayer #12

Closed Zhangmochen-zmc closed 1 month ago

Zhangmochen-zmc commented 1 year ago

When I add edges of a single layer using the code like mnet = MultilayerNetwork(aspects = 3) and mnet[1,2,'gene','gene'] = 1, it reports the error like "KeyError: 'Invalid number of indices.'". But when I change the aspects of the multilayer network to 2 mnet = MultilayerNetwork(aspects = 2) and run the same code to add edges, the program runs correctly. So what is the cause of this error?

Zhangmochen-zmc commented 1 year ago

Combined with the issue raised in issue5 (https://github.com/bolozna/Multilayer-networks-library/issues/5), I guess the developers set the maximum number of layers to 3 in order to fix the visualization bug.

cloner174 commented 3 months ago

"Aspect Concept" is not directly related with number of layers. You can set the aspect to 1 and come up with 50 layers, you know!

ercco commented 1 month ago

As @cloner174 mentioned, aspects and layers are different things. Number of aspects is the dimensionality of the layers. If you have genes as layers, then the network has one aspect. For example:

>>> M = pymnet.MultilayerNetwork(aspects=1)
>>> M[1,2,'gene1','gene2'] = 1
>>> M[2,3,'gene1','gene3'] = 1
>>> M[1,2,'gene4','gene3'] = 1
>>> list(M.iter_layers())
['gene1', 'gene2', 'gene4', 'gene3']
>>> list(M.edges)
[(1, 2, 'gene1', 'gene2', 1), (1, 2, 'gene4', 'gene3', 1), (2, 3, 'gene1', 'gene3', 1)]

See: https://mnets.github.io/pymnet/tutorial/networktypes.html#multilayer-networks