# Brim

## Exported

#### Q(M::Modular) ¶

Measures Q

*source:*
Brim/src/Q.jl:4

#### Qr(M::Modular) ¶

Measures Qr'

Qr' is the proportion of arvs established between nodes belonging to the same
modules. Values of Qr' below 0 indicate that there are *more* arcs between than
within modules.

Poisot T. An a posteriori measure of network modularity. *F1000Research* 2013,
2:130, `10.12688/f1000research.2-130.v3`

.

*source:*
Brim/src/Q.jl:29

#### draw_matrix(M::Modular) ¶

Takes a `Modular`

object, and plot it using the *Cairo* driver.

**Keyword arguments:**

`reorder::Function`

, a function to change the order of species (by default,`reorder_by_module!`

)`file`

: the name of the file to draw in (has to end in`.png`

)

Note that the modules are identified by color, using the
`distinguishable_colors`

function from the `Colors`

package.

*source:*
Brim/src/draw_matrix.jl:44

#### network_roles(M::Modular) ¶

Measure the roles of the species in a network (given as a `Modular`

object),
according to two parameters. *z* is the z-score of the degree within a modules
(which species connect *within* their modules). *c* is the degree across
networks (which species connect different networks).

The result is given as a `data.frame`

object.

*source:*
Brim/src/network_roles.jl:9

#### no_empty_modules!(M::Modular) ¶

Given a `Modular`

object, returns the same object with no empty modules (this
essentially reduces the size of `M.S`

if needed).

*source:*
Brim/src/common.jl:5

#### null_preserve_columns_marginals(A::Array{Int64, 2}) ¶

Calls `null_preserve_rows_marginals`

on `A'`

.

*source:*
Brim/src/permutations.jl:119

#### null_preserve_fill(A::Array{Int64, 2}) ¶

Performs 30000 2x2 swaps of a matrix by preserving the fill only.

*source:*
Brim/src/permutations.jl:127

#### null_preserve_marginals(A::Array{Int64, 2}) ¶

Performs 30000 2x2 swaps of a matrix by preserving the marginal totals (degree of the network).

*source:*
Brim/src/permutations.jl:58

#### null_preserve_rows_marginals(A::Array{Int64, 2}) ¶

Performs 30000 2x2 swaps of a matrix by preserving the marginal totals of ROWS only.

*source:*
Brim/src/permutations.jl:86

#### partition_lp(A::Array{Int64, 2}) ¶

Propagate labels to reach the starting partition. Takes an adjacency matrix
as input and returns a `Modular`

object as output.

This approach works better for large graphs (it tends to underperform both the "random" and "single" approaches for small graphs).

The optimization stops when any label propagation fails to increase the
modularity, measured with `Q`

.

*source:*
Brim/src/partition_lp.jl:11

#### partition_random(A::Array{Int64, 2}) ¶

Create a random partition for a matrix `A`

. Each node is assigned to a module at
random. If the smallest dimension of the matrix is *m*, there will be between 1
and *m* modules.

This method tends to work well for small to medium networks (and is faster than
`partition_lp`

).

*source:*
Brim/src/partition_random.jl:9

#### partition_single(A::Array{Int64, 2}) ¶

Every node is in its own module.

*source:*
Brim/src/partition_single.jl:4

#### recursive_brim!(M::Modular) ¶

Recursive Brim

*source:*
Brim/src/recursive_brim.jl:4

#### reorder_by_module!(M::Modular) ¶

Takes a `Modular`

object, and reorder it by module. The row / columns of `A`

and
`S`

are modified.

*source:*
Brim/src/draw_matrix.jl:5

## Internal

#### bestPart!(Target::Array{Int64, 2}, Scores::Array{Float64, 2}) ¶

Returns the best partition (used within recursive_brim)

*source:*
Brim/src/recursive_brim.jl:32

#### constrained_swap(A::Array{Int64, 2}) ¶

Performs a constrained swap: the marginals are conserved.

*source:*
Brim/src/permutations.jl:35

#### constrained_swapable(A::Array{Int64, 2}) ¶

Checks that the matrix is swapable under constrained permutations, i.e. one of the two conformations called c1 and c2.

*source:*
Brim/src/permutations.jl:5

#### free_swap(A::Array{Int64, 2}) ¶

Perfoms a free swap: the matrix cells are shuffled. The marginals are not (necessarily) conserved.

*source:*
Brim/src/permutations.jl:50

#### free_swapable(A::Array{Int64, 2}) ¶

Checks that the matrix is swapable under free permutations, i.e. it has at least one non-zero element, and at least one zero element.

This check is necessary because if not, the free swaps will collect all ones in a few rows / columns, which results in very blocky (and therefore biased) matrices. As a consequence, all sub-matrices that are "constrained swapable" are "free swapable" too, but the reciprocal is not true.

Because more sub-matrices are free swapable, and because there are higher order constraints on the acceptable swapped matrices.

Also, this is a serious lot of documentation in a function that is not exported.

*source:*
Brim/src/permutations.jl:26

#### no_empty_columns(A::Array{Int64, 2}) ¶

Check that there are no empty columns in a matrix.

*source:*
Brim/src/common.jl:22

#### no_empty_rows(A::Array{Int64, 2}) ¶

Check that there are no empty rows in a matrix.

*source:*
Brim/src/common.jl:15

#### same_row_marginals(A::Array{Int64, 2}, B::Array{Int64, 2}) ¶

Check that two matrices have the same degree distributions.

*source:*
Brim/src/common.jl:29