pymnet icon indicating copy to clipboard operation
pymnet copied to clipboard

Error when creating a four-layer multilayer

Open Zhangmochen-zmc opened this issue 1 year ago • 2 comments

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 avatar Apr 20 '23 14:04 Zhangmochen-zmc

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.

Zhangmochen-zmc avatar Apr 23 '23 06:04 Zhangmochen-zmc

"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!

cloner174 avatar Apr 23 '24 19:04 cloner174

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

ercco avatar Jun 17 '24 09:06 ercco