div.ProseMirror

Mangal.jl - Introduction

import Pkg
Pkg.activate(".")
1.0s
Pkg.add("Mangal")
Pkg.add("EcologicalNetworks")
58.5s
import Mangal
using EcologicalNetworks
50.8s

Compter le nombre de réseaux qui sont disponibles

count(Mangal.MangalNetwork)
8.1s
1386
count(Mangal.MangalDataset)
0.4s
173
count(Mangal.MangalReferenceTaxon)
0.3s
6985

On va chercher un dataset qui contient un terme spécifique

havens_dataset = Mangal.datasets("q" => "havens")[1]
1.2s
MangalDataset(15, true, "havens_1992", 2019-02-23T01:47:06, 2019-02-23T01:47:06, MangalReference(15, 1992, "10.1126/science.257.5073.1107", missing, missing, "@article{Havens_1992, doi = {10.1126/science.257.5073.1107}, url = {https://doi.org/10.1126%2Fscience.257.5073.1107}, year = 1992, month = {aug}, publisher = {American Association for the Advancement of Science ({AAAS})}, volume = {257}, number = {5073}, pages = {1107--1109}, author = {K. Havens}, title = {Scale and Structure in Natural Food Webs}, journal = {Science}}", "https://doi.org/10.1126%2Fscience.257.5073.1107", "URL of the attached data"), 3, "Pelagic communities of small lakes and ponds of the Adirondack")

Combien de réseaux dans ce jeu de données ?

count(Mangal.MangalNetwork, havens_dataset)
0.6s
50

On veut récupérer ces réseaux

havens_networks = Mangal.networks(havens_dataset)
12.4s

On veut les interactions entre les différentes espèces

count(Mangal.MangalInteraction, havens_networks[50])
0.9s
571

Convertir un MangalNetwork en EcologicalNetworks

N1 = convert(UnipartiteNetwork, havens_networks[1])
4.6s
26×26 unipartite ecological network (Bool, Mangal.MangalNode) (L: 60)

Chaque noeud contient des metadata

species(N1)
0.2s
species(N1)[1].taxon.gbif
0.2s
2234958

On peut maintenant compter les motifs

?find_motif
0.5s
find_motif(N::T1, m::T2) where {T1<:AbstractEcologicalNetwork, T2<:BinaryNetwork}

Returns an array of tuples, in which each tuple contains the species that are part of the motif. The length of the array gives the number of times the motif was found. For probabilistic networks, the tuple also contains the probability of observing the species in the correct conformation for the motif, as well as the variance.

References

Milo, R., Shen-Orr, S., Itzkovitz, S., Kashtan, N., Chklovskii, D., Alon, U.,

  1. Network motifs: simple building blocks of complex networks. Science 298,

824–7. https://doi.org/10.1126/science.298.5594.824

Poisot, T., Cirtwill, A.R., Cazelles, K., Gravel, D., Fortin, M.-J., Stouffer, D.B., 2016. The structure of probabilistic networks. Methods in Ecology and Evolution 7, 303–312. https://doi.org/10.1111/2041-210X.12468

On peut créer notre propre motif

linear_food_chain = UnipartiteNetwork([false true false; false false true; false false false])
0.6s
3×3 unipartite ecological network (Bool, String) (L: 2)

On peut maintenant chercher notre motif dans le réseau N1

list_sp = find_motif(N1, linear_food_chain)
2.4s
list_sp[1]
0.5s
(Mangal.MangalNode[MangalNode(18544, "Chydorus sphaericus", 2019-02-27T02:30:20, 2019-02-27T02:30:20, MangalReferenceTaxon(4080, "Chydorus sphaericus", 78201, 83993, 77745, 46498226, 2234958, 2019-02-22T22:39:56, 2019-06-14T15:25:30)), MangalNode(18561, "benthic detritus", 2019-02-27T02:30:21, 2019-02-27T02:30:21, missing), MangalNode(18537, "Polyphemus pediculus", 2019-02-27T02:30:20, 2019-02-27T02:30:20, MangalReferenceTaxon(4232, "Polyphemus pediculus", 8938, 83969, 77662, 46498346, 2234572, 2019-02-22T22:40:10, 2019-06-14T15:25:39))],)

On peut extraire le sous-graph formé par ces trois espèces.

N1[list_sp[1]...]
0.2s
3×3 unipartite ecological network (Bool, Mangal.MangalNode) (L: 3)
using LinearAlgebra
N1[list_sp[1]...].A |> diag
0.9s
3-element Array{Bool,1}: 0 0 1
nodiagonal(N1[list_sp[1]...]).A
0.2s
3×3 Array{Bool,2}: 0 1 0 0 0 0 1 0 0

Combien de chaînes trophiques linéaires

@time length(find_motif(N1, linear_food_chain))
0.7s
11
Runtimes (1)