EcologicalNetwork
Exported
Q(A::Array{Float64, 2}, L::Array{Int64, 1}) ¶
Q -- a measure of modularity
This measures Barber's bipartite modularity based on a matrix and a list of module labels.
source: EcologicalNetwork/src/modularity.jl:29
Q(P::Partition) ¶
Q -- a measure of modularity
This measures Barber's bipartite modularity based on a Partition
object, and
update the object in the proccess.
source: EcologicalNetwork/src/modularity.jl:47
Qr(A::Array{Float64, 2}, L::Array{Int64, 1}) ¶
Qr -- a measure of realized modularity
Measures Poisot's realized modularity, based on a a matrix and a list of module labels. Realized modularity takes values in the [0;1] interval, and is the proportion of interactions established within modules.
Note that in some situations, Qr
can be lower than 0. This reflects a
partition in which more links are established between than within modules.
source: EcologicalNetwork/src/modularity.jl:65
Qr(P::Partition) ¶
Qr -- a measure of realized modularity
Measures Poisot's realized modularity, based on a Partition
object.
source: EcologicalNetwork/src/modularity.jl:80
a_var(p::Array{Float64, N}) ¶
Variance of a series of additive Bernoulli events
f(p): ∑(p(1-p))
source: EcologicalNetwork/src/proba_utils.jl:65
betadiversity(A::Array{Float64, 2}, B::Array{Float64, 2}) ¶
Measure the expected network similarity
Note that this is only meaningful to apply this function when the two matrices
have the same species at the same position! If this is note the case, a
BoundsError
will be thrown.
This function will return a BetaSet
, which is then used by the function to
actually measure the beta-diversity. This package uses the approach of Koleff et a. (2003).
References
- Koleff, P., Gaston, K. J. and Lennon, J. J. (2003), Measuring beta diversity for presence–absence data. Journal of Animal Ecology, 72: 367–382. doi: 10.1046/j.1365-2656.2003.00710.x
source: EcologicalNetwork/src/betadiversity.jl:41
centrality_katz(A::Array{Float64, 2}) ¶
Measures Katz's centrality for each node in a unipartite network.
Keyword arguments
a
(def. 0.1), the weight of each subsequent connectionk
(def. 5), the maximal path length considered
source: EcologicalNetwork/src/centrality.jl:11
connectance(A::Array{Float64, 2}) ¶
Expected connectance for a probabilistic matrix, measured as the number of expected links, divided by the size of the matrix.
source: EcologicalNetwork/src/connectance.jl:16
connectance_var(A::Array{Float64, 2}) ¶
Expected variance of the connectance for a probabilistic matrix, measured as the variance of the number of links divided by the squared size of the matrix.
source: EcologicalNetwork/src/connectance.jl:24
count_motifs(A::Array{Float64, 2}, m::Array{Float64, 2}) ¶
Motif counter
This function will go through all k-permutations of A
to measure the
probability of each induced subgraph being an instance of the motif given by
m
(the square adjacency matrix of the motif, with 0 and 1).
source: EcologicalNetwork/src/motifs.jl:38
degree(A::Array{Float64, 2}) ¶
Expected degree
source: EcologicalNetwork/src/degree.jl:15
degree_in(A::Array{Float64, 2}) ¶
Expected number of ingoing degrees
source: EcologicalNetwork/src/degree.jl:9
degree_out(A::Array{Float64, 2}) ¶
Expected number of outgoing degrees
source: EcologicalNetwork/src/degree.jl:3
free_species(A::Array{Float64, 2}) ¶
Expected number of species with no interactions
This function will be applied on the unipartite version of the network. Note
that the functions species_ |predecessors
will work on bipartite networks, but
the unipartite situation is more general.
source: EcologicalNetwork/src/free_species.jl:32
gaston(S::BetaSet) ¶
Gaston measure of beta-diversity
source: EcologicalNetwork/src/betadiversity.jl:72
harrison(S::BetaSet) ¶
Harrison measure of beta-diversity
source: EcologicalNetwork/src/betadiversity.jl:97
hartekinzig(S::BetaSet) ¶
Harte-Kinzig measure of beta-diversity
source: EcologicalNetwork/src/betadiversity.jl:92
i_esp(p::Float64) ¶
Expected value of a single Bernoulli event
Simply f(p): p
source: EcologicalNetwork/src/proba_utils.jl:39
i_var(p::Float64) ¶
Variance of a single Bernoulli event
f(p): p(1-p)
source: EcologicalNetwork/src/proba_utils.jl:52
jaccard(S::BetaSet) ¶
Jaccard measure of beta-diversity
source: EcologicalNetwork/src/betadiversity.jl:67
lande(S::BetaSet) ¶
Lande measure of beta-diversity
source: EcologicalNetwork/src/betadiversity.jl:82
links(A::Array{Float64, 2}) ¶
Expected number of links for a probabilistic matrix
source: EcologicalNetwork/src/connectance.jl:3
links_var(A::Array{Float64, 2}) ¶
Expected variance of the number of links for a probabilistic matrix
source: EcologicalNetwork/src/connectance.jl:9
m_var(p::Array{Float64, N}) ¶
Variance of a series of multiplicative Bernoulli events
source: EcologicalNetwork/src/proba_utils.jl:74
make_bernoulli(A::Array{Float64, 2}) ¶
Generate a random 0/1 matrix from probabilities
Returns a matrix B of the same size as A, in which each element B(i,j) is 1 with probability A(i,j).
source: EcologicalNetwork/src/matrix_utils.jl:20
make_binary(A::Array{Float64, 2}) ¶
Returns the adjacency/incidence matrix from a probability matrix
Returns a matrix B of the same size as A, in which each element B(i,j) is 1 if A(i,j) is greater than 0.
source: EcologicalNetwork/src/matrix_utils.jl:71
make_threshold(A::Array{Float64, 2}, k::Float64) ¶
Generate a random 0/1 matrix from probabilities
Returns a matrix B of the same size as A, in which each element B(i,j) is 1 if
A(i,j) is > k
. This is probably unwise to use this function since this
practice is of questionnable relevance, but it is included for the sake of
exhaustivity.
k
must be in [0;1[.
source: EcologicalNetwork/src/matrix_utils.jl:54
make_unipartite(A::Array{Float64, 2}) ¶
Transforms a bipartite network into a unipartite network
Note that this function returns an asymetric unipartite network.
source: EcologicalNetwork/src/matrix_utils.jl:5
modularity(A::Array{Float64, 2}) ¶
This function is a wrapper for the modularity code. The number of replicates is the number of times the modularity optimization should be run.
Non-keywords arguments:
A
, probability matrix
Keywords arguments:
replicates
, defaults to100
kmax
, defaults to twice the matrix size, number of propagations to dosmax
, maximum number of steps without an increase in modularity before LP stops
Keep in mind that this approach has not been thoroughly tested. The measure of modularity works, but the optimization routine is not guaranteed to give robust/correct results.
source: EcologicalNetwork/src/modularity.jl:155
motif(A::Array{Float64, 2}, m::Array{Float64, 2}) ¶
Expected number of a given motif
source: EcologicalNetwork/src/motifs.jl:60
motif_p(A::Array{Float64, 2}, m::Array{Float64, 2}) ¶
Probability that a group of species form a given motif
source: EcologicalNetwork/src/motifs.jl:22
motif_v(A::Array{Float64, 2}, m::Array{Float64, 2}) ¶
Variance that a group of species form a given motif
source: EcologicalNetwork/src/motifs.jl:27
motif_var(A::Array{Float64, 2}, m::Array{Float64, 2}) ¶
Expected variance of a given motif
source: EcologicalNetwork/src/motifs.jl:65
nestedness(A::Array{Float64, 2}) ¶
Nestedness of a matrix, using the Bastolla et al. (XXXX) measure
Returns three values:
- nestedness of the entire matrix
- nestedness of the columns
- nestedness of the rows
source: EcologicalNetwork/src/nestedness.jl:33
nestedness_axis(A::Array{Float64, 2}) ¶
Nestedness of a single axis (called internally by nestedness
)
source: EcologicalNetwork/src/nestedness.jl:4
nodiag(A::Array{Float64, 2}) ¶
Sets the diagonal to 0
Returns a copy of the matrix A, with the diagonal set to 0. Will fail if the matrix is not square.
source: EcologicalNetwork/src/matrix_utils.jl:36
null1(A::Array{Float64, 2}) ¶
Given a matrix A
, null1(A)
returns a matrix with the same dimensions, where
every interaction happens with a probability equal to the connectance of A
.
source: EcologicalNetwork/src/nullmodels.jl:8
null2(A::Array{Float64, 2}) ¶
Given a matrix A
, null2(A)
returns a matrix with the same dimensions, where
every interaction happens with a probability equal to the degree of each
species.
source: EcologicalNetwork/src/nullmodels.jl:47
null3in(A::Array{Float64, 2}) ¶
Given a matrix A
, null3in(A)
returns a matrix with the same dimensions,
where every interaction happens with a probability equal to the in-degree
(number of predecessors) of each species, divided by the total number of
possible predecessors.
source: EcologicalNetwork/src/nullmodels.jl:35
null3out(A::Array{Float64, 2}) ¶
Given a matrix A
, null3out(A)
returns a matrix with the same dimensions,
where every interaction happens with a probability equal to the out-degree
(number of successors) of each species, divided by the total number of possible
successors.
source: EcologicalNetwork/src/nullmodels.jl:21
nullmodel(A::Array{Float64, 2}) ¶
This function is a wrapper to generate replicated binary matrices from
a template probability matrix A
.
If you use julia on more than one CPU, i.e. if you started it with julia -p
k
where k
is more than 1, this function will distribute each trial to one
worker. Which means that it's fast.
Note that you will get a warning if there are less networks created than have been requested. Not also that this function generates networks, but do not check that their distribution is matching what you expect. Simulated annealing routines will be part of a later release.
Keyword arguments
n
(def. 1000), number of replicates to generatemax
(def. 10000), number of trials to make
source: EcologicalNetwork/src/nullmodels.jl:79
number_of_paths(A::Array{Float64, 2}) ¶
Measures the expected number of paths in a probabilistic network
Keyword arguments
n
(def. 2), the path length
source: EcologicalNetwork/src/paths.jl:7
propagate_labels(A::Array{Float64, 2}, kmax::Int64, smax::Int64) ¶
A very experimental label propagation method for probabilistic networks
This function is a take on the usual LP method for community detection. Instead of updating labels by taking the most frequent in the neighbors, this algorithm takes each interaction, and transfers the label across it with a probability equal to the probability of the interaction. It is therefore not generalizable for non-probabilistic networks.
The other pitfall is that there is a need to do a large number of iterations to get to a good partition. This method is also untested.
source: EcologicalNetwork/src/modularity.jl:96
ruggiero(S::BetaSet) ¶
Ruggiero measure of beta-diversity
source: EcologicalNetwork/src/betadiversity.jl:87
sorensen(S::BetaSet) ¶
Sorensen measure of beta-diversity
source: EcologicalNetwork/src/betadiversity.jl:62
species_has_no_predecessors(A::Array{Float64, 2}) ¶
Probability that a species has no predecessors
source: EcologicalNetwork/src/free_species.jl:2
species_has_no_successors(A::Array{Float64, 2}) ¶
Probability that a species has no successors
source: EcologicalNetwork/src/free_species.jl:8
species_is_free(A::Array{Float64, 2}) ¶
Probability that a species has no links
This will return a vector, where the ith element is the probability that species i has no interaction. Note that this is only meaningful for unipartite networks.
source: EcologicalNetwork/src/free_species.jl:20
whittaker(S::BetaSet) ¶
Whittaker measure of beta-diversity
source: EcologicalNetwork/src/betadiversity.jl:57
williams(S::BetaSet) ¶
Williams measure of beta-diversity
source: EcologicalNetwork/src/betadiversity.jl:77
Partition ¶
Type to store a community partition
This type has three elements:
A
, the probability matrixL
, the array of (integers) module labelsQ
, if needed, the modularity value
source: EcologicalNetwork/src/modularity.jl:14
Internal
motif_internal(A::Array{Float64, 2}, m::Array{Float64, 2}) ¶
Internal motif calculations
The two arguments are A
the adjacency matrix (probabilistic) and m
the motif
adjacency matrix (0.0 or 1.0 only). The two matrices must have the same size.
The function returns a vectorized probability of each interaction being in the
right state for the motif, i.e. P if m is 1, and 1 - P if m is 0.
source: EcologicalNetwork/src/motifs.jl:9
BetaSet ¶
Partition of network similarity
The sets are, respectively
a
, expected number of common interactionsb
, expected number of interactions unique to Bc
, expected number of interactions unique to A
Note that all values are Float64
, since when dealing with probabilistic
events, the expected cardinality of each set is not integers.
source: EcologicalNetwork/src/betadiversity.jl:13
@checkprob(p) ¶
Quite crude way of checking that a number is a probability
The two steps are
- The number should be of the
Float64
type -- if not, will yield aTypeError
- The number should belong to [0,1] -- if not, will throw a
DomainError