26
BiMat : Start Guide Cesar O. Flores, Timoth´ ee Poisot, Sergi Valverde, and Joshua S. Weitz http://ecotheory.biology.gatech.edu April 15, 2015 1 Description This document contains the start guide for the BiMat library. An extended documentation of this library can be located on: http://bimat.github.io/ 1.1 Main Goal The main goal of BiMat is to facilitate the analysis of nestedness and modularity of bipartite ecological networks. 1.2 System Requirements MATLAB 2011 or superior. BiMat may work in previous versions, but BiMat was not tested on them. The user is expected to have basic MATLAB knowledge. 1.3 Functionality BiMat is a MATLAB library whose main function is the analysis of modularity and nestedness in bipartite ecological networks. Its main features are: Modularity and nestedness analysis. Diversity analysis using Shannon and/or Simpson’s indexes. Different null models for the creation of random bipartite networks. Statistics values for helping the user to make inference about the structure of their networks (i.e. percentile,z -score). Internal statistics of the modules (multi-scale analysis). Meta-Statistics analysis (useful when the user need to compare and analyze many bipartite networks). Drawing of bipartite networks in both matrix and graph layout. 1.4 Workflow The workflow of the BiMat package can be visualized in Figure 1. 1

BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

BiMat : Start Guide

Cesar O. Flores, Timothee Poisot, Sergi Valverde, and Joshua S. Weitzhttp://ecotheory.biology.gatech.edu

April 15, 2015

1 Description

This document contains the start guide for the BiMat library. An extended documentation of this librarycan be located on: http://bimat.github.io/

1.1 Main Goal

The main goal of BiMat is to facilitate the analysis of nestedness and modularity of bipartite ecologicalnetworks.

1.2 System Requirements

� MATLAB® 2011 or superior. BiMat may work in previous versions, but BiMat was not tested on them.

� The user is expected to have basic MATLAB® knowledge.

1.3 Functionality

BiMat is a MATLAB® library whose main function is the analysis of modularity and nestedness in bipartiteecological networks. Its main features are:

� Modularity and nestedness analysis.

� Diversity analysis using Shannon and/or Simpson’s indexes.

� Different null models for the creation of random bipartite networks.

� Statistics values for helping the user to make inference about the structure of their networks (i.e.percentile,z -score).

� Internal statistics of the modules (multi-scale analysis).

� Meta-Statistics analysis (useful when the user need to compare and analyze many bipartite networks).

� Drawing of bipartite networks in both matrix and graph layout.

1.4 Workflow

The workflow of the BiMat package can be visualized in Figure 1.

1

Page 2: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

1 0 1 0

2 0 0 1

1 0 0 0

0 3 1 2

0 0 0 1

1 0 1 02 0 0 11 0 0 00 3 1 20 0 0 1

1 0 1 02 0 0 11 0 0 00 3 1 20 0 0 1

aa 1 bb

bb 3 cc

cc 1 aa

cc 2 bb

aa 1 ff

aa 1 bbbb 3 cccc 1 aacc 2 bbaa 1 ff

aa 1 bbdd 3 ccaa 1 ccff 2 bbff 1 gg

{}

1 0 0 1 1

text files

{}

ab

mat files

{}{}{} abababab

BiMat input

1 0 1 0

2 0 0 1

1 0 0 0

0 3 1 2

0 0 0 1

1 0 1 02 0 0 11 0 0 00 3 1 20 0 0 1

Mult.scanalys.Stat.tests.

aa 1 bb

bb 3 cc

cc 1 aa

cc 2 bb

aa 1 ff

aa 1 bbbb 3 cccc 1 aacc 2 bbaa 1 ff

Generalprop.Struct.prop.

{}

1 0 0 1 1

text files

{}

ab

mat files {}{}B

BiMat output

Bipartite objectsMatlab objects

row002

row010

row012

row013

row014

row015

row017

row004

row007

row009

row005

row001

row008

row006

row003

row011

row016

row018

col0

07

col0

06

col0

02

col0

05

col0

04

col0

03

col0

08

col0

01

row001

row008

row009

row004

row005

row006

row007

row003

row011

row002

row010

row012

row013

row014

row015

row017

row016

row018

col0

01

col0

03

col0

05

col0

07

col0

04

col0

06

col0

08

col0

02

row001

row002

row003

row004

row005

row006

row007

row008

row009

row010

row011

row012

row013

row014

row015

row016

row017

row018

col0

01

col0

02

col0

03

col0

04

col0

05

col0

06

col0

07

col0

08

row001

row008

row009

row004

row005

row006

row007

row003

row011

row002

row010

row012

row013

row014

row015

row017

row016

row018

col001

col003

col005

col007

col004

col006

col008

col002

row002

row010

row012

row013

row014

row015

row017

row004

row007

row009

row005

row001

row008

row006

row003

row011

row016

row018

col001

col008

col003

col004

col005

col002

col006

col007

AlgorithmsModularity:

BiMat Package

Null Models: EquiprobableDegree AverageRow AverageColumn Average

Meta-analysisMulti-scale analysis

Adaptive BrimLP&BrimLeading Eigenvalue

NODFNTC

Nestendess:

Statistics

Extended Statistics:

Figure 1: BiMat Workflow. The figure shows the main scheme of the BiMat package. BiMat can take matlabobjects or text files as main input. The input is analyzed mainly around modularity and nestedness usinga variety of null models. The user may also perform an additional multi-scale analysis on the data, or if hehave more than one matrix to perform a meta-analysis in the entire data. Finally, the user can observe theresults via matlab objects, text files, and plots.

2

Page 3: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

2 Installation

2.1 Downloading BiMat

BiMat can be downloaded from the main developer website: http://bimat.github.io/.

2.2 Installing BiMat and adding it to the MATLAB® path

To install BiMat , copy the downloaded zip file to a directory of interest and unzip it. Next, you will needto add BiMat to the MATLAB® path either temporally or permanently:

� Temporal path: Add the BiMat directory (and sub-directories) to the MATLAB® path. You can dothat by typing in the MATLAB® command line:

>>g=genpath(’bimat_directory_location’);

>>addpath(g);

You should replace bimat_directory_location with the full path to the directory in which youinstalled BiMat .

� Permanent path: Alternatively, the user can update permanently (also temporally) by accessing theMATLAB® path configuration. The path configuration can be accesed via menu File –>Set Path.

2.3 BiMat configuration: Options.m file

Most of the BiMat functions can work without the need of parameters by the user. However, if the user doesnot specify the required arguments, BiMat will assume that default values will be used. These default valuesare specified on the file main/Options.m that the user can modified according to his needs. A descriptionof each parameter with its default value is indicated below:

� Statistical Significance: A two-tail test is the default way of testing for significance in BiMat . Noticethat the user can perform a one-tail test by just duplicating the values below:

– P_VALUE = 0.05: The p-value for testing statistical significance using a percentile test approach.Anything above the percentile 100∗(1−p/2) will be significant, while anything below the percentile100 ∗ (p/2) will be anti-significant.

– Z_SCORE = 1.96: The z-score for testing statistical significance using a z-test approach. Any-thing above |z| will be considered significant, while anything below −|z| will be considered anti-significant. z = 1.96 has been chosen in order to correspond to p = 0.05.

� Null Models:

– DEFAULT_NULL_MODEL = @NullModels.EQUIPROBABLE: The default function for creating randomnetworks.

– ALLOW_ISOLATED_NODES = true: When the network is sparse, a random network may be createdwith nodes with no links at all (matrix with empty rows or columns). BiMat by default allowthis kind of random networks for performing the statistical test. However, the user may wantto change this value to false and like this avoid the creation of this kind of random networks.However, the user must be aware that the time required for creating a random network withoutempty nodes will growth with the sparsity of the matrix.

– TRIALS_FOR_NON_EMPTY_NODES = 1000: This value is only used when the user changes the valueof the previous parameter to false. In some extreme cases (a very sparse network), BiMat willnot be able to find a random network without empty nodes. Hence, in order to avoid infinite

3

Page 4: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

loops, BiMat will stop looking for them after the number of trials specified in this parameter. IfBiMat can not create a random network without empty nodes before this number of trials, BiMatwill just create a random network without this constraint and will print the next message in theMATLAB® command line:

Warning: Not possible to create a matrix with non isolated nodes.

The random matrix was created without this constraint instead.

Consider to modify Options.ALLOW_ISOLATED_NODES and/or Options.INCLUDE_EMPTY_NODES

– INCLUDE_EMPTY_NODES = true: Sometimes the user may have data with empty nodes (a matrixwith empty rows and/or columns). Depending on the value of this parameter BiMat will chosebetween keeping these nodes (true) or deleting them from the adjacency matrix (false). Further,the user must be aware that including or not empty nodes will have an effect during the statisticaltests of his data.

– SWAP_FIXED_FACTOR = 100: This swap factor Sf is used for creating random networks using theFIXED null model. The amount of performed random swaps in the matrix is SfE, were E is thenumber of edges.

– REPLICATES = 100: The amount of replicates that BiMat performs in order to test for statisticalsignificance. The value of 100 was chosen with the idea of getting quick results. However, theuser must be aware that this value is no appropriate for accurate testing. The right value willdepend on the kind of network (or networks) that the user is analyzing. It will depend mostlyin two quantities: the fill and the size of the adjacency matrix. Experience from the developersindicate that if matrices are small ∼ 10 × 10 the appropiate number is ∼ 10, 000, while for bigmatrices ∼ 200 × 200, the appropriate number is ∼ 1, 000. However, the right way for testingthe appropiate value is by looking and how the variance decrease as the number of replicatesincrease. The variance stops decreasing considerably with the number of replicates, increasingthis last number does not have any effect on the statistical results.

� Algorithms: All the next parameters refer to algorithms behavior. The user can change the valueshere, or he can change the parameters dynamically by modifying the corresponding properties in theBipartiteModularity instance or Nestedness.

– OPTIMIZE_COMPONENTS = false: Modularity is a function that depends in the global informationof the network. However, sometimes, the user may have a network which is not connected (it hasisolated components). By using the default value false, BiMat will optimize the modularity valueat the entire adjacency matrix, while by using the value true, BiMat will optimize the modularityat the component level. Optimizing at the component level may decrease the global modularityvalue, thought the number of communities may increase and be more finner.

– MODULARITY_ALGORITHM = @AdaptiveBrim: BiMat has three algorithms for optimizing the mod-ularity equation and hence find the module configuration of the network.

– NESTEDNESS_ALGORITHM = @NestednessNODF: BiMat has two metrics for evaluating nestedness.

– TRIALS_MODULARITY = 20: The results of the modularity algorithms depends strongly in someinitial random assignment of the communities. Therefore, BiMat restart the algorithm using thisamount of times.

2.4 Getting help

At any moment you can access help from the command line using any of the next commands:

� help class_name: For a summary of the class file (i.e. help StatisticalTest). This will summarizeall public and static methods and properties of the class. If you want to see private and/or protectedmethods you can use the doc instead of the help command.

4

Page 5: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

� help class_name.method_name: For a summary of what the methods does and what kind of argu-ments it gets (i.e. help StatisticalTest.DoNulls).

� help class_name.property_name: For a summary of the property (i.e.help StatisticalTest.replicates).

You can always replace help by the doc command.

5

Page 6: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

3 Examples

This section include three different examples to introduce the user to the main features of BiMat . All thecode and data file can be found on the examples directory. For another the description of other examplesincluded in the same directory, please visit http://bimat.github.io/

� creating_networks.m. It shows and explains the required input for BiMat .

� moebus_study.m. An analysis of the Moebus phage-bacteria bipartite network. It shows how to usethe most important functions that are available to analyze a single matrix. This analysis include howto calculate most of the results published on [3].

� phage_bacteria_meta_analysis.m. An analysis of a group of matrices that shows how to perform ameta-statistics analysis. This example reproduce some of the results published on [2]. However, usingthis template all the results can be reproduced with a little extra effort.

3.1 BiMat - Creating networks

This example will introduce the user to the input of BiMat . It explains what input is required andhow it is used by BiMat . This example is located on examples/creating_networks.m and make useof examples/data/input_adja.txt and examples/data/input_matrix.txt files.

3.1.1 Contents

� Add the source to the MATLAB® path� Bipartite class and main input� Optional input� Creating input for Bipartite class� Creating a Bipartite object from MATLAB® data� Creating a Bipartite object from text files

3.1.2 Add the source to the MATLAB® path

5 %% Add the source to the matlab path6 %Assuming that you run this script from examples directory7 g = genpath('../'); addpath(g);8 close all;

3.1.3 Bipartite class (main class)

The Bipartite is the fundamental class of the BiMat software. This class works as a communication bridgebetween all the available classes. Therefore, in order to work with BiMat we will always need to instantiateat least an object of this class.

3.1.4 Required input

The required input of the Bipartite class is a MATLAB® matrix, where the rows will represent the node setR and the columns the node set C, such that if the element matrix(i,j)>0 a link between node ri and cjexist. This matrix input can contain only non-negative integers {0, 1, 2, 3...}. However, at present, valuesgreater than 1 are only used for plotting purposes (e.g. color interactions according to weight) andnot in the existing algorithms (which only work using the boolean version of the matrix).

6

Page 7: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

3.1.5 Optional input

BiMat has two different types of optional input. The first type is for node labeling and the main use of itwill be for labeling row and column nodes during plotting. The input must be encoded in a cell of stringsfor each set R and C nodes, such that each string in a cell corresponds to the label of a node. The size ofsuch cells must corresponds to the number of nodes.

The second type of input consist of the type of node for either row and column nodes. For an exampleof type of nodes consider a bipartite network where R and C represent pollinators and plants respectivally.In turn pollinators can be classified in birds and insects, which will be the classification for set R. Theinformation of this classification is useful to explain modularity in terms of node classification. You canconsult the Moebus study example for additional details. The classification input must be vectors of thesame size than the number of nodes in rows and columns. The values must be positive integers {1, 2, 3, ...}that represents the classification class of each node.

3.1.6 Creating input for Bipartite class

Here will show an example of the simplest way of creating a Bipartite object. We will create a bipartitenetworks using a MATLAB® matrix as input of the Bipartite object. This synthetic data matrix representsthe interactions between a set of pollinators (rows) and a set of plants (columns). matrix(i,j)>0 meansthat pollinator i pollinates plant j with strength matrix(i,j).

46 %Creating the data47 matrix = [2 0 2 2;...48 1 2 2 1;...49 2 0 0 2;...50 0 1 2 2;...51 0 0 1 0];52 % For the next variables observe that the size of matrix 5x4 correlates with53 % them54 row labels = {'insect 1', 'insect 2', 'insect 3', 'bird 1', 'bird 2'};55 col labels = {'flower 1', 'flower 2', 'grass 1', 'gras 2'};56 %Notice that as long as each kind is represented by a diferented positive57 %integer you will be fine.58 row ids = [1 1 1 3 3];59 %Notice that 1 in col ids not necessearly corresponds to 1's in row ids.60 col ids = [1 1 5 5];

3.1.7 Creating a Bipartite object from MATLAB® data

Using the data we just created we can now create our Bipartite object:

64 bp = Bipartite(matrix);65 bp.row labels = row labels;66 bp.col labels = col labels;67 bp.row class = row ids;68 bp.col class = col ids;

3.1.8 Creating a Bipartite object from text files

An additional way of creating data is by using the static functions from the Reading.m class. Currently twodifferent formats are available. The first input format will contain only the information of the adjacencymatrix (you will need to add row/column labels and classification id’s if you need). A file example forcreating the last data is on examples/data/input_matrix.txt, which contains:

7

Page 8: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

2 0 2 2

1 2 2 1

2 0 0 2

0 1 2 2

0 0 1 0

The last format input can be called using:

84 bp = Reader.READ BIPARTITE MATRIX('input matrix.txt');85 % We need to add labels and classification ids by ourselves86 bp.row labels = row labels;87 bp.col labels = col labels;88 bp.row class = row ids;89 bp.col class = col ids;

The second input format consist on writing the adjacency list. This input format will read also the rowand column node labels. However if you need ids for the classification you will need to add by yourself. Anexample for the last data format is located on examples/data/input_adja.txt and is shown below:

insect_1 2 flower_1

insect_1 2 grass_1

insect_1 2 grass_2

insect_2 1 flower_1

insect_2 2 flower_2

insect_2 2 grass_1

insect_2 1 grass_2

insect_3 2 flower_1

insect_3 2 grass_2

bird_1 1 flower_2

bird_1 2 grass_1

bird_1 2 grass_2

bird_2 1 grass_1

The middle column is optional. If it is not used, the reading function will assume that is composed ofones only. We can now just call:

112 bp = Reader.READ ADJACENCY LIST('input adja.txt.');113 % Wee need to add classification ids by ourselves114 bp.row class = row ids;115 bp.col class = col ids;

Now that you know how to create a network object, you can proceed to the next example that showshow to perform a complete analysis in a bipartite network.

3.2 BiMat Use case using Moebus cross-infection matrix data

This example will introduce the user to the most basic features of the BiMat Software. In order to dothat we will calculate some of the results presented on the Flores et al 2012 paper (Multi-scale structureand geographic drivers of cross-infection within marine bacteria and phages) [3]. We will show how toplot, evaluate modularity and nestedness, and perform some statistics at the global and internal modularstructure.

This example is located on examples/moebus_study.m and makes use ofexamples/data/moebus_data.mat data file.

8

Page 9: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

3.2.1 Contents

� Add the source to the MATLAB® path� Creating the Bipartite network object� Calculating Modularity� Calculating Nestedness� Plotting in Matrix Layout� Statistical analysis in the entire network� Statistical analysis of the internal modules

3.2.2 Add the source to the MATLAB® path

10 %Assuming that you run this script from examples directory11 g = genpath('../'); addpath(g);12 close all; %Close any open figure

We need also to load the data from which we will be working on:

15 load moebus data.mat;

The loaded data contains the bipartite adjacency matrix of the Moebus and Nattkemper study [4],where 1’s and 2’s in the matrix represent either clear or turbid lysis spots. It also contains the labels forboth bacteria and phages and their geographical location from which they were isolated across the AtlanticOcean.

3.2.3 Creating the Bipartite network object

23 bp = Bipartite(moebus.weight matrix); % Create the main object24 bp.row labels = moebus.bacteria labels; % Updating node labels25 bp.col labels = moebus.phage labels;26 bp.row class = moebus.bacteria stations; % Updating node ids27 bp.col class = moebus.phage stations;

We can print the general properties of the network with:

30 bp.printer.PrintGeneralProperties();

General Properties

Number of species: 501

Number of row species: 286

Number of column species: 215

Number of Interactions: 1332

Size: 61490

Connectance or fill: 0.022

3.2.4 Calculating Modularity

The modularity algorithm is encoded in the property community of the Bipartite object (bp.community).Tree algorithms are available:

9

Page 10: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

1. Adaptive BRIM (AdaptiveBrim.m)2. LP&BRIM (LPBrim.m)3. Leading Eigenvector (NewmanAlgorithm.m)

Each algorithm optimizes the same modularity equation [1] for bipartite networks using different ap-proaches. Only the Newman algorithm return the same result. The other two perform at some pointrandom module pre-assigments, and by consequence they may not return the same result in each call. Thedefault algorithm is specified on Options.MODULARITY_ALGORITHM. However, we can assign another algo-rithm dynamically. Here, for example, we will use the Newman’s algorithm (Leading eigenvector):

47 bp.community = LeadingEigenvector(bp.matrix);48 % The next flag is exclusive of Newman Algorithm and what it does is to49 % performn a final tuning after each sub−division (see Newman 2006).50 bp.community.DoKernighanLinTunning = true; % Default value

We need to calculate the modularity explicitly by calling:

53 bp.community.Detect();

If Options.PRINT_RESULTS is true, the last call will print the next lines:

Modularity:

Used algorithm: LeadingEigenvector

N (Number of modules): 48

Qb (Standard metric): 0.7956

Qr (Ratio of int/ext inter): 0.8348

If we are interested in node module indexes too, we can use bp.community.row modules andbp.community.col modules. We can also access directly the modularity values by calling bp.community.Qb

or bp.community.Qr as the next example:

60 fprintf('The modularity value Qb is %f\n', bp.community.Qb);61 fprintf('The fraction inside modules Qr is %f\n',bp.community.Qr);

The modularity value Qb is 0.795611

The fraction inside modules Qr is 0.834835

The value 0 ≤ Qb ≤ 1 is calculated using the standard bipartite modularity function (introduced byBarber) [1] while the value Qr is an a posteriori represents the fraction of interactions that fall insidemodules [5].

3.2.5 Calculating Nestedness

The nestedness algorithm is encoded in the property nestedness of the Bipartite object (bp.nestedness).Currently, two algorithms (metrics) are available:

1. Nestedness Temperatur Calculator NTC (NestednessNTC.m)2. NODF (NestednessNODF.m)

Contrary to modularity (where each algorithm optimizes the same metric), these algorithms use differentmetrics to calculate nestedness. Therefore, the statistical significance of a network will depend not onlyin which null model but also in which metric (algorithm) is used. As the modularity case, the default

10

Page 11: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

nestedness algorithm that BiMat uses is specified in Options.NESTEDNESS_ALGORITHM. The user can alsoswitch the algorithm dinamically as we show for modularity. However, here we will just use the defaultalgorithm by calling:

86 bp.nestedness.Detect();

As the modularity case, BiMat will return the next output if Options.PRINT_RESULTS is true:

Nestedness NODF:

NODF (Nestedness value): 0.0341

NODF (Rows value): 0.0368

NODF (Columns value): 0.0293

Finally the user can access directly the value of nestedness as in the following line:

93 fprintf('The Nestedness value is %f\n', bp.nestedness.N);

The Nestedness value is 0.034053

To finish this section, we can summarize both modularity and nestedness results by calling:

96 bp.printer.PrintStructureValues();

Modularity:

Used algorithm: LeadingEigenvector

N (Number of modules): 48

Qb (Standard metric): 0.7956

Qr (Ratio of int/ext inter): 0.8348

Nestedness NODF:

NODF (Nestedness value): 0.0341

NODF (Rows value): 0.0368

NODF (Columns value): 0.0293

3.2.6 Plotting in Matrix Layout

You can print the layout of the original, nestedness, and modular sorting. If you matrix is weighted in acategorical way using integers (0,1,2...) you can visualize a different color for each interaction, where 0 isno interaction. For using this functionality you need to assign a color for each interaction and specificallyindicate that you want a color for each interaction before calling the plot function (otherwise default colorswill be used):

105 figure(1);106 % Matlab command to change the figure window;107 set(gcf,'Position',[0 72 1751 922]);108 bp.plotter.font size = 2.0; %Change the font size of the rows and labels109 % Use different color for each kind of interaction110 bp.plotter.use type interaction = true; %111 bp.plotter.color interactions(1,:) = [1 0 0]; %Red color for clear lysis112 bp.plotter.color interactions(2,:) = [0 0 1]; %Blue color for turbid spots113 bp.plotter.back color = 'white';114 % After changing all the format we finally can call the plotting function.115 bp.plotter.PlotMatrix();

11

Page 12: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

605|1520(+1)603|1504603|1502603|1501603|1499603|1494603|1493603|1486

603|1484(+1)603|1483

603|1482(+1)603|1481602|1476

602|1471(+3)602|1468

602|1464(+1)602|1461(+2)602|1460(+1)602|1459(+1)

602|1456602|1454601|1447601|1446601|1444601|1442601|1441601|1440601|1439601|1434

601|1431(+1)601|1427(+1)

601|1424601|1423601|1421600|1409600|1391598|1388598|1382598|1373596|1365596|1356596|1354596|1351596|1350596|1349596|1348596|1344593|1332593|1326593|1325593|1322593|1320593|1319593|1318593|1314593|1313593|1312590|1304590|1303590|1300590|1297590|1295590|1294590|1293590|1292590|1288590|1285590|1284590|1282590|1281588|1278588|1276588|1268588|1266588|1265588|1259588|1254581|1242581|1241581|1233581|1228576|1212572|1183572|1177572|1172572|1169572|1162572|1161572|1156572|1154572|1152570|1136570|1133570|1132570|1128568|1117568|1112568|1108568|1103568|1102568|1095568|1094565|1081564|1056564|1048564|1046564|1041564|1036559|1018559|1009559|1008559|1006554|988

554|979(+1)554|977554|973547|952547|949547|943541|929541|923541|920541|911541|905541|903536|897536|882536|872531|857

531|852(+1)531|847531|836531|834531|831526|823526|822526|812

526|808(+1)526|805522|791

522|769(+2)522|762518|755518|749518|748518|744518|734518|732518|731513|722513|720513|704513|701513|699513|694513|693508|667508|661508|660504|627504|661501|616497|589497|576497|573492|549492|542492|526492|523492|522489|507484|458484|444480|434480|432

480|421(+2)480|418480|417478|406478|404

478|398(+1)478|382478|377478|376478|373

478|372(+1)478|371(+1)

476|354476|344(+1)

474|335474|321474|305

474|304(+2)472|292472|289472|288472|284472|277472|276472|275

472|271(+1)471|268471|264471|263471|262471|256471|254471|252471|251469|241469|239469|234

469|231(+1)469|230469|229469|225465|216465|214465|205465|202465|200465|188465|185465|183464|173464|165464|162464|159464|153462|144462|141462|139462|136462|133462|131462|126

462|124(+1)462|122462|121460|119460|116460|114460|113460|111460|106460|105460|101

460|97460|93460|92460|91458|87458|86458|82

458|81(+1)458|75

458|74(+1)458|73(+1)

458|72458|71458|68

458|67(+1)458|65

458|64(+1)458|63458|62456|57456|56456|54456|53456|50

456|49(+1)456|47456|46456|45456|44456|43456|41456|39456|38456|37456|36456|34456|33456|32456|31

456|

31/1

456|

31/2

456|

33/1

456|

33/2

456|

33/2

−1

456|

36/1

456|

36/2

456|

45/1

456|

45/2

456|

45/3

456|

46/1

456|

50/1

456|

54/1

456|

56/1

456|

56/1

−1

458|

62/1

458|

62/2

458|

63/1

458|

63/2

458|

65/1

458|

68/1

458|

72/1

458|

82/1

458|

83/1

458|

87/1

458|

88/1

460|

93/1

460|

97/1

460|

101/

146

0|10

6/1

460|

111/

146

0|11

6/1

460|

119/

146

2|12

6/2

462|

126/

2−1

462|

131/

146

2|13

6/2

462|

139/

146

2|13

9/2

462|

139/

346

2|14

1/1

462|

141/

246

2|14

4/1

464|

153/

146

4|15

9/1

464|

162/

146

4|17

3/1

465|

185/

146

5|21

4/2

465|

216/

146

5|21

6/2

469|

230/

146

9|23

0/2

469|

231/

147

1|25

2/1

471|

256/

147

1|26

3/1

471|

263/

247

1|26

4/1

472|

275/

147

2|27

5/2

472|

277/

147

2|28

8/1

472|

289/

147

4|30

4/1

474|

305/

147

4|30

5/2

474|

321/

147

4|32

1/2

476|

344/

147

8|37

3/1

478|

382/

147

8|39

8/1

478|

398/

1−1

478|

400/

147

8|40

0/1−

147

8|40

0/2

480|

418/

148

0|43

2/1

484|

458/

148

9|50

7/1

492|

526/

149

2|54

9/1

497|

573/

149

7|57

3/2

497|

576/

149

7|58

9/2

508|

660/

150

8|66

0/3

508|

660/

450

8|66

1/1

508|

661/

1−1

508|

661/

251

3|70

1/1

513|

720/

151

3|72

2/1

518|

734/

151

8|73

4/2

518|

744/

151

8|74

9/1

518|

755/

152

2|76

2/1

522|

762/

352

2|79

1/1

522|

791/

252

6|80

5/1

526|

808/

152

6|81

2/1

531|

831/

153

1|83

4/1

531|

834/

253

1|83

6/1

531|

847/

153

1|84

7/2

531|

852/

153

1|85

7/1

536|

872/

153

6|88

2/1

541|

903/

154

1|90

3/2

541|

905/

154

1|90

5/2

541|

923/

155

4|97

3/1

554|

973/

255

9|10

06/1

559|

1008

/155

9|10

08/2

564|

1036

/156

4|10

41/1

564|

1041

/256

4|10

46/1

564|

1048

/156

4|10

56/2

564|

1056

/356

5|10

81/1

568|

1112

/156

8|11

17/1

570|

1128

/157

0|11

32/1

570|

1132

/257

2|11

52/1

572|

1156

/157

2|11

69/1

572|

1169

/257

2|11

83/1

581|

1228

/158

1|12

42/1

588|

1265

/158

8|12

66/1

590|

1284

/159

0|12

88/1

590|

1292

/159

0|12

92/2

590|

1293

/159

0|12

94/1

590|

1295

/159

0|12

97/1

590|

1303

/159

0|13

04/1

593|

1312

/159

3|13

13/1

593|

1314

/159

3|13

18/1

593|

1318

/1−

159

3|13

19/1

593|

1320

/159

3|13

20/2

593|

1320

/359

3|13

22/1

593|

1325

/159

3|13

25/2

593|

1326

/159

3|13

26/2

593|

1332

/159

6|13

44/1

596|

1349

/159

6|13

50/1

596|

1354

/159

6|13

65/1

598|

1373

/159

8|13

82/1

598|

1388

/160

1|14

21/1

601|

1423

/160

1|14

24/1

601|

1427

/160

1|14

33/1

601|

1434

/160

1|14

39/1

601|

1440

/160

1|14

41/1

601|

1441

/260

1|14

44/1

601|

1446

/160

2|14

54/1

602|

1456

/160

2|14

59/1

602|

1460

/160

2|14

61/1

602|

1464

/160

2|14

64/2

602|

1464

/360

2|14

71/1

602|

1474

/160

2|14

76/1

603|

1481

/160

3|14

82/1

603|

1484

/160

3|14

86/1

603|

1493

/160

3|14

94/1

603|

1501

/160

3|15

04/1

605|

1520

/1

Figure 2: Original sorted matrix. Blue and red cells represent different strengths of infection between virusand bacteria. Rows and columns represent bacteria and phages, respectively.

For plotting the nestedness matrix you may decide to use or not an isocline. The nestedness pattern isjust the matrix sorted in decreasing degree for row and column nodes.

120 figure(2);121 % Matlab command to change the figure window;122 set(gcf,'Position',[0+50 72 932 922]);123 bp.plotter.use isocline = true; %The NTC isocline will be plotted.124 bp.plotter.isocline color = 'red'; %Decide the color of the isocline.125 bp.plotter.PlotNestedMatrix();

For plotting the modularity sort, lets use the example to introduce the user to an interesting modularityproperty which is optimize_by_component. This property forces the modularity algorithms to optimizemodularity in each component:

12

Page 13: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

456|56472|288508|660

564|1041541|905

526|808(+1)518|748518|734474|321

456|31547|949541|903531|857464|173464|159462|141462|131

456|36603|1482(+1)602|1464(+1)

572|1169570|1132564|1056547|943531|834531|831

458|81(+1)581|1233559|1006536|872518|749508|661471|268471|262469|230

458|74(+1)458|64(+1)

458|63456|53456|45456|44456|41456|33

568|1094554|973474|305472|276472|275460|106

456|43456|34

564|1036559|1008531|836526|805501|616471|263464|162464|153

456|37536|882531|847497|573492|523465|183462|126

460|91458|75

602|1471(+3)601|1442601|1441593|1325593|1318588|1268588|1265588|1259572|1152559|1018526|822

522|769(+2)513|704513|694480|432

480|421(+2)480|418478|404

478|398(+1)478|377

478|372(+1)469|241465|185

456|54456|46456|32

601|1444601|1439601|1434

601|1431(+1)590|1285581|1241576|1212541|923536|897526|812522|762513|699497|576474|335471|252

460|97460|92

603|1494602|1468

602|1460(+1)602|1454601|1447601|1446601|1440

601|1427(+1)600|1409593|1313593|1312590|1304590|1293570|1136568|1095484|458478|406478|376471|254465|214465|188462|144462|139460|119

458|86458|82456|39

603|1499603|1486603|1481

602|1461(+2)601|1423598|1373593|1332593|1326593|1322593|1320593|1314590|1294590|1292590|1281572|1172572|1161572|1154570|1133570|1128568|1108568|1102554|977526|823513|720508|667484|444480|417

478|371(+1)476|344(+1)474|304(+2)

472|289472|284472|277

472|271(+1)471|251469|234465|202464|165462|136462|133462|121460|114460|111

460|93458|73(+1)

458|65456|38

603|1504603|1493600|1391596|1350596|1348590|1303590|1297590|1284590|1282588|1276572|1177572|1162568|1117568|1103547|952541|929541|920

531|852(+1)522|791518|744518|732518|731513|693504|627492|526492|522476|354472|292471|264469|239

469|231(+1)469|229469|225465|216465|205465|200460|116460|113

458|87458|72458|68

458|67(+1)458|62

456|49(+1)456|47

605|1520(+1)603|1502603|1501

603|1484(+1)603|1483602|1476

602|1459(+1)602|1456601|1424601|1421598|1388598|1382596|1365596|1356596|1354596|1351596|1349596|1344593|1319590|1300590|1295590|1288588|1278588|1266588|1254581|1242581|1228572|1183572|1156568|1112565|1081564|1048564|1046559|1009554|988

554|979(+1)541|911518|755513|722513|701504|661497|589492|549492|542489|507480|434478|382478|373471|256

462|124(+1)462|122460|105460|101

458|71456|57456|50

474|

304/

147

6|34

4/1

484|

458/

147

4|30

5/1

518|

744/

147

1|25

2/1

472|

277/

154

1|92

3/1

497|

573/

153

1|83

6/1

559|

1008

/253

6|87

2/1

508|

661/

150

8|66

1/1−

152

2|76

2/3

472|

275/

153

6|88

2/1

472|

275/

259

0|13

03/1

474|

321/

157

0|11

28/1

508|

660/

459

0|12

97/1

462|

141/

251

8|74

9/1

456|

31/2

513|

701/

153

1|83

4/1

464|

159/

146

4|16

2/1

480|

418/

151

8|73

4/2

526|

812/

153

1|83

4/2

598|

1388

/145

6|45

/346

0|10

6/1

464|

153/

147

4|32

1/2

522|

762/

155

9|10

08/1

456|

36/2

462|

126/

2−1

464|

173/

157

0|11

32/2

572|

1152

/157

2|11

69/2

456|

33/2

456|

33/2

−1

460|

97/1

469|

230/

147

2|28

8/1

478|

400/

1−1

526|

805/

154

1|90

5/2

588|

1265

/159

3|13

32/1

602|

1464

/145

6|56

/145

8|63

/246

2|13

1/1

471|

263/

147

2|28

9/1

478|

398/

1−1

478|

400/

250

8|66

1/2

541|

905/

155

9|10

06/1

593|

1318

/1−

160

2|14

64/3

603|

1482

/160

3|14

93/1

456|

33/1

456|

50/1

456|

56/1

−1

458|

88/1

462|

141/

146

2|14

4/1

474|

305/

247

8|39

8/1

480|

432/

149

2|52

6/1

508|

660/

356

4|10

56/2

593|

1326

/260

1|14

46/1

603|

1486

/145

8|83

/147

8|40

0/1

564|

1056

/357

0|11

32/1

590|

1288

/160

1|14

44/1

602|

1471

/160

2|14

76/1

456|

31/1

456|

36/1

456|

45/1

456|

54/1

458|

63/1

458|

82/1

460|

119/

146

2|12

6/2

465|

214/

259

3|13

12/1

593|

1325

/160

1|14

24/1

601|

1434

/160

1|14

40/1

601|

1441

/160

3|14

94/1

458|

65/1

458|

68/1

462|

139/

147

1|26

4/1

478|

382/

154

1|90

3/2

568|

1117

/158

8|12

66/1

590|

1292

/159

0|12

93/1

593|

1313

/159

3|13

20/2

593|

1322

/159

6|13

65/1

598|

1373

/160

1|14

27/1

601|

1433

/160

1|14

39/1

601|

1441

/260

2|14

54/1

602|

1459

/160

3|15

04/1

456|

45/2

458|

87/1

460|

93/1

460|

111/

146

0|11

6/1

462|

136/

246

2|13

9/2

462|

139/

346

5|18

5/1

465|

216/

146

5|21

6/2

469|

230/

246

9|23

1/1

497|

573/

251

8|73

4/1

522|

791/

253

1|83

1/1

531|

847/

253

1|85

2/1

531|

857/

154

1|90

3/1

564|

1036

/156

4|10

41/2

564|

1046

/157

2|11

69/1

590|

1292

/259

0|12

94/1

590|

1295

/159

0|13

04/1

593|

1320

/359

3|13

25/2

593|

1326

/159

8|13

82/1

601|

1423

/160

2|14

61/1

602|

1474

/160

3|14

81/1

603|

1484

/160

5|15

20/1

456|

46/1

458|

62/1

458|

62/2

458|

72/1

460|

101/

147

1|25

6/1

471|

263/

247

8|37

3/1

489|

507/

149

2|54

9/1

497|

576/

149

7|58

9/2

508|

660/

151

3|72

0/1

513|

722/

151

8|75

5/1

522|

791/

152

6|80

8/1

531|

847/

155

4|97

3/1

554|

973/

256

4|10

41/1

564|

1048

/156

5|10

81/1

568|

1112

/157

2|11

56/1

572|

1183

/158

1|12

28/1

581|

1242

/159

0|12

84/1

593|

1314

/159

3|13

18/1

593|

1319

/159

3|13

20/1

596|

1344

/159

6|13

49/1

596|

1350

/159

6|13

54/1

601|

1421

/160

2|14

56/1

602|

1460

/160

2|14

64/2

603|

1501

/1

Figure 3: Nested sorted matrix. Blue and red cells represent different strengths of infection between virusand bacteria. In a perfectly nested pattern of the same fill than the current matrix, all the interaction cellswill lay above the isocline (red line).

132 % independently of each other:133 figure(3);134 % Matlab command to change the figure window;135 set(gcf,'Position',[0+100 72 1754 922]);136 % First, lets optimize at the total matrix (default behavior)137 subplot(1,2,1);138 bp.community = LPBrim(bp.matrix); %Uses LPBrim algorithm139 bp.plotter.use isocline = true; %Although true is the default value140 bp.plotter.PlotModularMatrix();141 title(['$Q = $',num2str(bp.community.Qb),' $c = $', num2str(bp.community.N)],...142 'interpreter','latex','fontsize',23);143 %144 %Now, we will optimize at the graph component level.

13

Page 14: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

145 subplot(1,2,2);146 bp.community = LPBrim(bp.matrix);147 bp.community.optimize by component = true; % optimize by components148 bp.plotter.PlotModularMatrix();149 title(['$Q = $',num2str(bp.community.Qb),' $c = $', num2str(bp.community.N)],...150 'interpreter','latex','fontsize',23);151 % Move right panel to the left152 set(gca,'position',get(gca,'position')−[0.07 0 0 0]);

472|288526|808(+1)

474|321518|748547|949541|903531|857547|943536|872518|749541|905

568|1094554|973472|276

559|1008531|836501|616471|262497|573465|183526|822478|377469|241492|523541|923526|812484|458478|376

572|1154554|977513|720508|667472|284

572|1177572|1162568|1103518|744504|627469|225

603|1484(+1)554|988541|911

559|1018522|769(+2)

513|704513|694

480|421(+2)480|418478|404

478|372(+1)522|762513|699

570|1136568|1095478|406471|254

572|1161570|1133570|1128568|1108568|1102480|417

478|371(+1)476|344(+1)474|304(+2)472|271(+1)

471|251465|202464|165472|277469|239

598|1388508|660

564|1041518|734531|834531|831462|141

456|53456|41456|56456|31

508|661472|275462|131

564|1036581|1233

456|44456|33456|43

536|882531|847526|805464|153

456|46458|75

497|576588|1268

602|1460(+1)460|92

564|1046590|1304465|188

593|1314462|121

460|93598|1373600|1391590|1303590|1297590|1282588|1276472|292465|200

458|72460|105

593|1322526|823484|444472|289541|920

531|852(+1)518|732513|693492|526492|522476|354

554|979(+1)513|701504|661492|542462|126

460|91593|1318588|1265572|1152581|1241

460|97462|144

572|1172547|952462|122464|173464|159

456|36458|63456|45456|34456|37

460|106464|162

456|32603|1486462|133460|114

603|1493460|113

456|49(+1)603|1483

456|57456|50

480|432478|398(+1)

465|185576|1212536|897474|335

600|1409541|929

572|1169570|1132564|1056469|230471|268474|305471|263471|252

458|82460|111

603|1504596|1348

458|68602|1459(+1)

458|71602|1464(+1)603|1482(+1)

458|81(+1)458|74(+1)458|64(+1)

559|1006518|731

602|1471(+3)601|1441601|1444590|1285601|1446590|1288

601|1431(+1)601|1434601|1440593|1312593|1320601|1424588|1259602|1468603|1499

456|38456|39

590|1300465|214469|234

593|1332568|1117471|264

603|1502601|1442601|1439601|1447596|1350602|1476460|119

458|86593|1325

458|73(+1)458|67(+1)

456|54462|139

456|47590|1293462|136

458|65602|1454

601|1427(+1)593|1313601|1423590|1294596|1365596|1356596|1351588|1266559|1009480|434478|382

605|1520(+1)462|124(+1)

603|1494590|1292593|1326590|1281

469|231(+1)469|229

603|1481602|1461(+2)

598|1382588|1278590|1295588|1254465|216465|205460|116

458|87590|1284603|1501522|791

602|1456601|1421596|1354596|1349596|1344593|1319581|1242581|1228572|1183572|1156568|1112565|1081564|1048518|755513|722497|589492|549489|507478|373471|256460|101

458|62

458|

62/2

458|

62/1

460|

101/

147

1|25

6/1

478|

373/

148

9|50

7/1

492|

549/

149

7|58

9/2

513|

722/

151

8|75

5/1

564|

1048

/156

5|10

81/1

568|

1112

/157

2|11

56/1

572|

1183

/158

1|12

28/1

581|

1242

/159

3|13

19/1

596|

1344

/159

6|13

49/1

596|

1354

/160

1|14

21/1

602|

1456

/152

2|79

1/2

522|

791/

160

3|15

01/1

590|

1284

/146

0|11

6/1

458|

87/1

465|

216/

246

5|21

6/1

590|

1295

/159

8|13

82/1

603|

1481

/160

2|14

74/1

602|

1461

/146

9|23

1/1

593|

1326

/259

8|13

73/1

593|

1326

/160

3|14

94/1

590|

1292

/159

0|12

92/2

605|

1520

/147

8|38

2/1

588|

1266

/159

6|13

65/1

601|

1423

/159

0|12

94/1

602|

1454

/160

1|14

33/1

601|

1427

/159

3|13

13/1

590|

1293

/145

8|65

/146

2|13

6/2

465|

185/

146

2|13

9/1

462|

139/

346

2|13

9/2

458|

83/1

593|

1325

/146

0|11

9/1

593|

1325

/259

3|13

20/3

602|

1476

/145

6|56

/145

6|56

/1−

160

1|14

39/1

596|

1350

/146

5|21

4/2

568|

1117

/147

1|26

4/1

593|

1332

/145

6|33

/2−

145

6|33

/145

6|33

/260

1|14

40/1

601|

1434

/160

1|14

24/1

593|

1312

/159

3|13

20/2

593|

1320

/160

1|14

46/1

602|

1471

/160

1|14

44/1

590|

1288

/160

1|14

41/1

601|

1441

/260

2|14

64/1

541|

905/

247

2|28

8/1

603|

1482

/160

2|14

64/3

559|

1006

/154

1|90

5/1

458|

88/1

602|

1464

/245

8|82

/160

3|15

04/1

602|

1459

/145

8|68

/146

0|11

1/1

572|

1169

/257

0|11

32/2

469|

230/

147

1|26

3/1

564|

1056

/247

4|30

5/2

570|

1132

/156

4|10

56/3

572|

1169

/146

9|23

0/2

471|

263/

247

8|40

0/1−

147

8|40

0/2

478|

398/

1−1

480|

432/

147

8|39

8/1

478|

400/

160

3|14

93/1

603|

1486

/145

6|50

/146

4|16

2/1

464|

159/

145

6|45

/346

0|10

6/1

462|

141/

246

4|17

3/1

464|

153/

145

8|63

/245

6|36

/245

6|36

/145

8|63

/145

6|54

/145

6|45

/145

6|45

/257

2|11

52/1

462|

126/

2−1

588|

1265

/146

0|97

/159

3|13

18/1

−1

462|

144/

146

2|12

6/2

593|

1318

/151

3|70

1/1

472|

289/

149

2|52

6/1

593|

1322

/153

1|85

2/1

590|

1303

/159

0|12

97/1

590|

1304

/146

0|93

/159

3|13

14/1

458|

72/1

472|

277/

150

8|66

1/1

508|

661/

1−1

536|

882/

147

2|27

5/1

472|

275/

250

8|66

0/4

531|

834/

153

1|83

4/2

518|

734/

252

6|80

5/1

456|

31/2

462|

131/

146

2|14

1/1

508|

661/

250

8|66

0/3

456|

31/1

564|

1046

/156

4|10

41/2

564|

1036

/153

1|84

7/2

531|

831/

151

8|73

4/1

602|

1460

/156

4|10

41/1

531|

847/

150

8|66

0/1

497|

576/

145

6|46

/147

6|34

4/1

474|

304/

157

0|11

28/1

522|

762/

348

0|41

8/1

522|

762/

159

8|13

88/1

541|

923/

148

4|45

8/1

497|

573/

155

9|10

08/2

531|

836/

153

6|87

2/1

518|

744/

147

4|30

5/1

471|

252/

151

8|74

9/1

474|

321/

152

6|81

2/1

559|

1008

/147

4|32

1/2

541|

903/

260

3|14

84/1

541|

903/

153

1|85

7/1

497|

573/

255

4|97

3/2

554|

973/

152

6|80

8/1

513|

720/

1

Q =0.78503 c =58559|1018

522|769(+2)513|704513|694

480|421(+2)480|418478|404

478|372(+1)522|762513|699

570|1136568|1095478|406471|254

572|1161570|1133570|1128568|1108568|1102480|417

478|371(+1)476|344(+1)474|304(+2)472|271(+1)

471|251465|202464|165472|277469|239

469|231(+1)469|229

598|1388508|660518|734

564|1041531|834531|831

456|53456|41

462|141508|661472|275

456|31564|1036462|131

456|44456|33

536|882531|847

581|1233456|43

526|805456|46

464|153458|75

497|576588|1268

602|1460(+1)564|1046547|949541|903472|288

526|808(+1)518|748547|943536|872518|749554|973531|836497|573465|183541|905474|321531|857471|262

568|1094472|276

559|1008501|616469|241478|377478|376

572|1162469|225

603|1484(+1)590|1304465|188

593|1314462|121

460|93598|1373600|1391590|1303590|1297590|1282588|1276472|292465|200460|105464|173464|159

456|36456|56458|63456|45456|34

460|106464|162

456|37456|32

603|1486462|133460|114

603|1493460|113

456|49(+1)603|1483

456|57456|50

572|1169570|1132564|1056469|230471|268474|305471|263471|252541|911484|458

572|1154554|977508|667

572|1177568|1103518|744504|627554|988526|823541|920

531|852(+1)518|732513|693492|526492|522476|354513|701480|432

478|398(+1)465|185

576|1212536|897474|335

600|1409541|929

588|1259602|1468603|1499

456|38460|92456|39

590|1300602|1464(+1)603|1482(+1)

458|81(+1)458|74(+1)458|64(+1)

559|1006518|731

602|1471(+3)601|1441601|1444590|1285601|1446590|1288

601|1431(+1)601|1434601|1440593|1312593|1320601|1424526|822541|923526|812492|523513|720472|284

593|1322484|444472|289

554|979(+1)504|661492|542460|119

458|86593|1325

458|73(+1)458|67(+1)

458|82460|111

458|68458|71

601|1442601|1439601|1447602|1476465|214469|234

593|1332568|1117462|126

460|91588|1265581|1241603|1504596|1348

602|1459(+1)603|1494590|1292590|1284590|1293462|136

458|65456|54

462|139456|47

602|1454601|1427(+1)

593|1313596|1356596|1351588|1266593|1318

460|97572|1172559|1009480|434478|382

605|1520(+1)462|124(+1)

593|1326590|1281471|264

603|1502603|1481

602|1461(+2)601|1423590|1294598|1382588|1278547|952462|122

572|1152462|144

590|1295588|1254465|216465|205460|116

458|87596|1350

458|72603|1501522|791

602|1456596|1365601|1421596|1354596|1349596|1344593|1319581|1242581|1228572|1183572|1156568|1112565|1081564|1048518|755513|722497|589492|549489|507478|373471|256460|101

458|62

458|

62/2

458|

62/1

460|

101/

147

1|25

6/1

478|

373/

148

9|50

7/1

492|

549/

149

7|58

9/2

513|

722/

151

8|75

5/1

564|

1048

/156

5|10

81/1

568|

1112

/157

2|11

56/1

572|

1183

/158

1|12

28/1

581|

1242

/159

3|13

19/1

596|

1344

/159

6|13

49/1

596|

1354

/160

1|14

21/1

596|

1365

/160

2|14

56/1

522|

791/

252

2|79

1/1

603|

1501

/145

8|72

/159

6|13

50/1

460|

116/

145

8|87

/146

5|21

6/2

465|

216/

159

0|12

95/1

462|

144/

146

2|12

6/2−

159

8|13

82/1

601|

1423

/159

0|12

94/1

603|

1481

/160

2|14

74/1

602|

1461

/147

1|26

4/1

593|

1326

/259

8|13

73/1

593|

1326

/160

5|15

20/1

478|

382/

157

2|11

52/1

588|

1265

/146

0|97

/159

3|13

18/1

588|

1266

/160

2|14

54/1

601|

1433

/160

1|14

27/1

593|

1313

/146

2|13

9/1

462|

139/

346

2|13

9/2

590|

1293

/145

8|65

/146

2|13

6/2

465|

185/

160

3|14

94/1

590|

1292

/159

0|12

92/2

590|

1284

/160

2|14

59/1

603|

1504

/159

3|13

18/1

−1

462|

126/

246

5|21

4/2

568|

1117

/160

2|14

76/1

456|

56/1

−1

601|

1439

/145

8|82

/145

8|68

/146

0|11

1/1

458|

83/1

593|

1325

/146

0|11

9/1

593|

1325

/259

3|13

20/3

472|

289/

159

3|13

22/1

474|

321/

152

6|81

2/1

474|

321/

255

9|10

08/1

513|

720/

160

1|14

40/1

601|

1434

/160

1|14

24/1

593|

1312

/159

3|13

20/2

593|

1320

/160

1|14

46/1

602|

1471

/160

1|14

44/1

590|

1288

/160

1|14

41/1

601|

1441

/260

2|14

64/1

541|

905/

247

2|28

8/1

603|

1482

/160

2|14

64/3

559|

1006

/154

1|90

5/1

458|

88/1

602|

1464

/245

6|33

/2−

159

3|13

32/1

456|

33/2

456|

33/1

478|

400/

1−1

478|

400/

247

8|39

8/1−

148

0|43

2/1

478|

398/

147

8|40

0/1

513|

701/

149

2|52

6/1

531|

852/

148

4|45

8/1

518|

744/

147

4|30

5/1

572|

1169

/257

0|11

32/2

469|

230/

147

1|26

3/1

564|

1056

/247

4|30

5/2

570|

1132

/156

4|10

56/3

572|

1169

/146

9|23

0/2

471|

263/

260

3|14

93/1

603|

1486

/145

6|50

/146

4|16

2/1

464|

159/

146

0|10

6/1

456|

45/3

462|

141/

246

4|17

3/1

458|

63/2

464|

153/

145

6|31

/245

6|36

/245

6|56

/145

8|63

/145

6|45

/145

6|36

/145

6|54

/145

6|45

/256

4|10

41/2

590|

1303

/159

0|12

97/1

590|

1304

/146

0|93

/159

3|13

14/1

497|

573/

155

9|10

08/2

531|

836/

153

6|87

2/1

541|

923/

147

1|25

2/1

518|

749/

154

1|90

3/2

603|

1484

/154

1|90

3/1

531|

857/

149

7|57

3/2

554|

973/

255

4|97

3/1

526|

808/

147

2|27

7/1

508|

661/

150

8|66

1/1−

153

6|88

2/1

472|

275/

147

2|27

5/2

508|

660/

453

1|83

4/1

531|

834/

251

8|73

4/2

526|

805/

146

2|13

1/1

462|

141/

150

8|66

1/2

508|

660/

345

6|31

/156

4|10

46/1

564|

1036

/153

1|84

7/2

531|

831/

151

8|73

4/1

602|

1460

/156

4|10

41/1

531|

847/

150

8|66

0/1

497|

576/

145

6|46

/147

6|34

4/1

474|

304/

157

0|11

28/1

522|

762/

348

0|41

8/1

522|

762/

159

8|13

88/1

469|

231/

1

Q =0.73039 c =67

Figure 4: Modular sorting in matrix layout. Blue and red cells represent different strengths of infectionbetween virus and bacteria. Each block represent a different module. Left panel shows the default behavior(optimize at the total matrix), while right panel shows the component optimization. Generally the secondcase will have better resolution but smaller global modularity value. LPBrim was used for optimizing themodularity function in both cases.

Finally, the user can play with use_isocline, use_type_interactions, use_type_interaction, anduse_module_format to create interesting visualizations:

157 figure(4);158 set(gcf,'Position',[0+150 72 1754 922]);159 % First, lets come back to use the LeadingEigenvector algorithm160 bp.community = LeadingEigenvector(bp.matrix);161 %162 subplot(1,2,1);163 bp.plotter.use isocline = false;164 bp.plotter.use type interaction = false;165 bp.plotter.PlotModularMatrix();166 %

14

Page 15: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

167 subplot(1,2,2);168 % Isocline and divisions will not have the same color than modules169 bp.plotter.use module format = false;170 bp.plotter.use isocline = true;171 bp.plotter.isocline color = 'red';172 bp.plotter.division color = 'red';173 bp.plotter.back color = [0 100 180]/255;174 bp.plotter.cell color = 'white';175 bp.plotter.PlotModularMatrix();176 % Move right panel to the left177 set(gca,'position',get(gca,'position')−[0.07 0 0 0]);

472|288526|808(+1)

474|321518|748547|949541|903531|857547|943536|872518|749541|905

568|1094554|973472|276

559|1008531|836501|616471|262497|573465|183526|822478|377469|241492|523541|923526|812484|458478|376

572|1154554|977513|720508|667472|284

572|1177572|1162568|1103518|744504|627469|225

603|1484(+1)554|988541|911

559|1018522|769(+2)

513|704513|694

480|421(+2)480|418478|404

478|372(+1)456|54

522|762513|699462|139

570|1136568|1095478|406471|254

572|1161570|1133570|1128568|1108568|1102480|417

478|371(+1)476|344(+1)474|304(+2)472|271(+1)

471|251465|202464|165

456|39472|277469|239

469|231(+1)469|229

456|47593|1332598|1388508|660518|734

564|1041531|834531|831462|141

456|53456|44456|41456|33456|31

508|661472|275462|131

456|43564|1036581|1233536|882531|847526|805464|153

458|75456|46

497|576460|92

588|1268588|1259602|1468

602|1460(+1)603|1499

456|38590|1300564|1046593|1325590|1304465|188

458|86460|119

598|1373593|1326593|1314590|1281462|121

460|93458|73(+1)

600|1391590|1303590|1297590|1282588|1276472|292465|200

458|72458|67(+1)

460|105464|173464|159

456|56456|36458|63456|45456|34

464|162456|37

460|106456|32

601|1442601|1439601|1447596|1350602|1476593|1322526|823484|444472|289541|920

531|852(+1)518|732513|693492|526492|522476|354

554|979(+1)513|701504|661492|542

602|1471(+3)601|1441601|1444601|1434

601|1431(+1)590|1285601|1446601|1440593|1312593|1320601|1424590|1288462|126

460|91593|1318588|1265572|1152581|1241

460|97462|144

572|1172547|952462|122

603|1486462|133460|114

603|1493460|113

456|49(+1)603|1483

456|57456|50

480|432478|398(+1)

465|185576|1212536|897474|335

600|1409541|929

590|1293465|214462|136

458|65469|234

568|1117471|264

603|1502572|1169570|1132564|1056469|230471|268474|305471|263471|252

458|82460|111

603|1504596|1348

458|68602|1459(+1)

458|71602|1464(+1)603|1482(+1)

458|81(+1)458|74(+1)458|64(+1)

559|1006518|731

603|1494590|1292590|1284602|1454

601|1427(+1)593|1313601|1423590|1294596|1365596|1356596|1351588|1266559|1009480|434478|382

605|1520(+1)462|124(+1)

603|1481602|1461(+2)

598|1382588|1278590|1295588|1254465|216465|205460|116

458|87603|1501522|791

602|1456601|1421596|1354596|1349596|1344593|1319581|1242581|1228572|1183572|1156568|1112565|1081564|1048518|755513|722497|589492|549489|507478|373471|256460|101

458|62

458|

62/2

458|

62/1

460|

101/

147

1|25

6/1

478|

373/

148

9|50

7/1

492|

549/

149

7|58

9/2

513|

722/

151

8|75

5/1

564|

1048

/156

5|10

81/1

568|

1112

/157

2|11

56/1

572|

1183

/158

1|12

28/1

581|

1242

/159

3|13

19/1

596|

1344

/159

6|13

49/1

596|

1354

/160

1|14

21/1

602|

1456

/152

2|79

1/2

522|

791/

160

3|15

01/1

460|

116/

145

8|87

/146

5|21

6/2

465|

216/

159

0|12

95/1

598|

1382

/160

3|14

81/1

602|

1474

/160

2|14

61/1

605|

1520

/147

8|38

2/1

588|

1266

/159

6|13

65/1

601|

1423

/159

0|12

94/1

602|

1454

/160

1|14

33/1

601|

1427

/159

3|13

13/1

603|

1494

/159

0|12

92/1

590|

1292

/259

0|12

84/1

602|

1464

/154

1|90

5/2

472|

288/

160

3|14

82/1

602|

1464

/355

9|10

06/1

541|

905/

145

8|88

/160

2|14

64/2

458|

82/1

603|

1504

/160

2|14

59/1

458|

68/1

460|

111/

157

2|11

69/2

570|

1132

/246

9|23

0/1

471|

263/

156

4|10

56/2

474|

305/

257

0|11

32/1

564|

1056

/357

2|11

69/1

469|

230/

247

1|26

3/2

465|

214/

259

0|12

93/1

568|

1117

/147

1|26

4/1

458|

65/1

462|

136/

246

5|18

5/1

478|

400/

1−1

478|

400/

247

8|39

8/1−

148

0|43

2/1

478|

398/

147

8|40

0/1

603|

1493

/160

3|14

86/1

456|

50/1

572|

1152

/146

2|12

6/2−

158

8|12

65/1

460|

97/1

593|

1318

/1−

146

2|14

4/1

462|

126/

259

3|13

18/1

601|

1446

/160

2|14

71/1

601|

1444

/159

0|12

88/1

601|

1441

/160

1|14

40/1

601|

1434

/160

1|14

24/1

593|

1312

/160

1|14

41/2

593|

1320

/259

3|13

20/3

593|

1320

/151

3|70

1/1

472|

289/

149

2|52

6/1

593|

1322

/153

1|85

2/1

464|

162/

146

4|15

9/1

460|

106/

145

6|45

/346

2|14

1/2

464|

173/

145

8|63

/245

6|56

/146

4|15

3/1

456|

56/1

−1

456|

36/2

602|

1476

/145

8|63

/145

6|45

/145

6|36

/145

6|54

/160

1|14

39/1

456|

45/2

564|

1041

/259

6|13

50/1

590|

1303

/159

0|12

97/1

458|

83/1

593|

1326

/259

3|13

25/1

460|

119/

159

8|13

73/1

593|

1326

/159

3|13

25/2

590|

1304

/146

0|93

/159

3|13

14/1

458|

72/1

472|

277/

150

8|66

1/1

508|

661/

1−1

536|

882/

147

2|27

5/1

472|

275/

250

8|66

0/4

531|

834/

153

1|83

4/2

518|

734/

252

6|80

5/1

456|

31/2

456|

33/2

−1

456|

33/2

462|

131/

146

2|14

1/1

456|

33/1

593|

1332

/150

8|66

1/2

508|

660/

345

6|31

/156

4|10

46/1

564|

1036

/153

1|84

7/2

531|

831/

151

8|73

4/1

602|

1460

/156

4|10

41/1

531|

847/

150

8|66

0/1

497|

576/

145

6|46

/147

6|34

4/1

474|

304/

152

2|76

2/3

570|

1128

/148

0|41

8/1

598|

1388

/152

2|76

2/1

462|

139/

146

9|23

1/1

462|

139/

346

2|13

9/2

541|

923/

148

4|45

8/1

497|

573/

155

9|10

08/2

531|

836/

153

6|87

2/1

518|

744/

147

4|30

5/1

471|

252/

151

8|74

9/1

474|

321/

152

6|81

2/1

559|

1008

/147

4|32

1/2

541|

903/

260

3|14

84/1

541|

903/

153

1|85

7/1

497|

573/

255

4|97

3/2

554|

973/

152

6|80

8/1

513|

720/

1

472|288526|808(+1)

474|321518|748547|949541|903531|857547|943536|872518|749541|905

568|1094554|973472|276

559|1008531|836501|616471|262497|573465|183526|822478|377469|241492|523541|923526|812484|458478|376

572|1154554|977513|720508|667472|284

572|1177572|1162568|1103518|744504|627469|225

603|1484(+1)554|988541|911

559|1018522|769(+2)

513|704513|694

480|421(+2)480|418478|404

478|372(+1)456|54

522|762513|699462|139

570|1136568|1095478|406471|254

572|1161570|1133570|1128568|1108568|1102480|417

478|371(+1)476|344(+1)474|304(+2)472|271(+1)

471|251465|202464|165

456|39472|277469|239

469|231(+1)469|229

456|47593|1332598|1388508|660518|734

564|1041531|834531|831462|141

456|53456|44456|41456|33456|31

508|661472|275462|131

456|43564|1036581|1233536|882531|847526|805464|153

458|75456|46

497|576460|92

588|1268588|1259602|1468

602|1460(+1)603|1499

456|38590|1300564|1046593|1325590|1304465|188

458|86460|119

598|1373593|1326593|1314590|1281462|121

460|93458|73(+1)

600|1391590|1303590|1297590|1282588|1276472|292465|200

458|72458|67(+1)

460|105464|173464|159

456|56456|36458|63456|45456|34

464|162456|37

460|106456|32

601|1442601|1439601|1447596|1350602|1476593|1322526|823484|444472|289541|920

531|852(+1)518|732513|693492|526492|522476|354

554|979(+1)513|701504|661492|542

602|1471(+3)601|1441601|1444601|1434

601|1431(+1)590|1285601|1446601|1440593|1312593|1320601|1424590|1288462|126

460|91593|1318588|1265572|1152581|1241

460|97462|144

572|1172547|952462|122

603|1486462|133460|114

603|1493460|113

456|49(+1)603|1483

456|57456|50

480|432478|398(+1)

465|185576|1212536|897474|335

600|1409541|929

590|1293465|214462|136

458|65469|234

568|1117471|264

603|1502572|1169570|1132564|1056469|230471|268474|305471|263471|252

458|82460|111

603|1504596|1348

458|68602|1459(+1)

458|71602|1464(+1)603|1482(+1)

458|81(+1)458|74(+1)458|64(+1)

559|1006518|731

603|1494590|1292590|1284602|1454

601|1427(+1)593|1313601|1423590|1294596|1365596|1356596|1351588|1266559|1009480|434478|382

605|1520(+1)462|124(+1)

603|1481602|1461(+2)

598|1382588|1278590|1295588|1254465|216465|205460|116

458|87603|1501522|791

602|1456601|1421596|1354596|1349596|1344593|1319581|1242581|1228572|1183572|1156568|1112565|1081564|1048518|755513|722497|589492|549489|507478|373471|256460|101

458|62

458|

62/2

458|

62/1

460|

101/

147

1|25

6/1

478|

373/

148

9|50

7/1

492|

549/

149

7|58

9/2

513|

722/

151

8|75

5/1

564|

1048

/156

5|10

81/1

568|

1112

/157

2|11

56/1

572|

1183

/158

1|12

28/1

581|

1242

/159

3|13

19/1

596|

1344

/159

6|13

49/1

596|

1354

/160

1|14

21/1

602|

1456

/152

2|79

1/2

522|

791/

160

3|15

01/1

460|

116/

145

8|87

/146

5|21

6/2

465|

216/

159

0|12

95/1

598|

1382

/160

3|14

81/1

602|

1474

/160

2|14

61/1

605|

1520

/147

8|38

2/1

588|

1266

/159

6|13

65/1

601|

1423

/159

0|12

94/1

602|

1454

/160

1|14

33/1

601|

1427

/159

3|13

13/1

603|

1494

/159

0|12

92/1

590|

1292

/259

0|12

84/1

602|

1464

/154

1|90

5/2

472|

288/

160

3|14

82/1

602|

1464

/355

9|10

06/1

541|

905/

145

8|88

/160

2|14

64/2

458|

82/1

603|

1504

/160

2|14

59/1

458|

68/1

460|

111/

157

2|11

69/2

570|

1132

/246

9|23

0/1

471|

263/

156

4|10

56/2

474|

305/

257

0|11

32/1

564|

1056

/357

2|11

69/1

469|

230/

247

1|26

3/2

465|

214/

259

0|12

93/1

568|

1117

/147

1|26

4/1

458|

65/1

462|

136/

246

5|18

5/1

478|

400/

1−1

478|

400/

247

8|39

8/1−

148

0|43

2/1

478|

398/

147

8|40

0/1

603|

1493

/160

3|14

86/1

456|

50/1

572|

1152

/146

2|12

6/2−

158

8|12

65/1

460|

97/1

593|

1318

/1−

146

2|14

4/1

462|

126/

259

3|13

18/1

601|

1446

/160

2|14

71/1

601|

1444

/159

0|12

88/1

601|

1441

/160

1|14

40/1

601|

1434

/160

1|14

24/1

593|

1312

/160

1|14

41/2

593|

1320

/259

3|13

20/3

593|

1320

/151

3|70

1/1

472|

289/

149

2|52

6/1

593|

1322

/153

1|85

2/1

464|

162/

146

4|15

9/1

460|

106/

145

6|45

/346

2|14

1/2

464|

173/

145

8|63

/245

6|56

/146

4|15

3/1

456|

56/1

−1

456|

36/2

602|

1476

/145

8|63

/145

6|45

/145

6|36

/145

6|54

/160

1|14

39/1

456|

45/2

564|

1041

/259

6|13

50/1

590|

1303

/159

0|12

97/1

458|

83/1

593|

1326

/259

3|13

25/1

460|

119/

159

8|13

73/1

593|

1326

/159

3|13

25/2

590|

1304

/146

0|93

/159

3|13

14/1

458|

72/1

472|

277/

150

8|66

1/1

508|

661/

1−1

536|

882/

147

2|27

5/1

472|

275/

250

8|66

0/4

531|

834/

153

1|83

4/2

518|

734/

252

6|80

5/1

456|

31/2

456|

33/2

−1

456|

33/2

462|

131/

146

2|14

1/1

456|

33/1

593|

1332

/150

8|66

1/2

508|

660/

345

6|31

/156

4|10

46/1

564|

1036

/153

1|84

7/2

531|

831/

151

8|73

4/1

602|

1460

/156

4|10

41/1

531|

847/

150

8|66

0/1

497|

576/

145

6|46

/147

6|34

4/1

474|

304/

152

2|76

2/3

570|

1128

/148

0|41

8/1

598|

1388

/152

2|76

2/1

462|

139/

146

9|23

1/1

462|

139/

346

2|13

9/2

541|

923/

148

4|45

8/1

497|

573/

155

9|10

08/2

531|

836/

153

6|87

2/1

518|

744/

147

4|30

5/1

471|

252/

151

8|74

9/1

474|

321/

152

6|81

2/1

559|

1008

/147

4|32

1/2

541|

903/

260

3|14

84/1

541|

903/

153

1|85

7/1

497|

573/

255

4|97

3/2

554|

973/

152

6|80

8/1

513|

720/

1

Figure 5: Modular sorting in matrix layout. The user can play with the plotter properties in order to createinteresting matrix layout formats. LeadingEigenvector was used for optimizing the modularity function inboth cases.

3.2.7 Plotting in graph layout

Plotting in graph layout use the same three functions than matrix layout. You just need to replace the partMatrix in the function name by Graph. For example, for plotting the graph layout of modularity we willneed to type:

184 figure(6);185 % Matlab command to change the figure window;186 set(gcf,'Position',[19+800 72 932 922]);187 bp.plotter.PlotModularGraph();

15

Page 16: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

526|808(+1)474|321472|288547|949541|903531|857518|748547|943536|872518|749

568|1094554|973541|905472|276

559|1008531|836501|616497|573471|262465|183526|822478|377469|241541|923526|812492|523484|458478|376

572|1154554|977513|720508|667472|284

572|1177572|1162568|1103518|744504|627469|225

603|1484(+1)554|988541|911

559|1018522|769(+2)

513|704513|694

480|421(+2)480|418478|404

478|372(+1)522|762513|699

456|54462|139

572|1161570|1136570|1133570|1128568|1108568|1102568|1095480|417478|406

478|371(+1)476|344(+1)474|304(+2)472|271(+1)

471|254471|251465|202464|165472|277469|239

469|231(+1)469|229

456|47456|39

598|1388593|1332508|660518|734

564|1041531|834531|831462|141

456|53456|44456|41456|33

508|661472|275

456|31564|1036462|131

456|43581|1233536|882531|847526|805464|153

458|75456|46

497|576460|92

602|1468602|1460(+1)

588|1268588|1259603|1499

456|38590|1300564|1046593|1325590|1304465|188

458|86598|1373593|1326593|1314590|1281462|121460|119

460|93458|73(+1)

600|1391590|1303590|1297590|1282588|1276472|292465|200

458|72458|67(+1)

460|105464|173464|159

458|63456|56456|45456|36

464|162456|37456|34

460|106456|32

601|1447601|1442601|1439596|1350602|1476593|1322526|823484|444472|289541|920

531|852(+1)518|732513|693492|526492|522476|354

554|979(+1)513|701504|661492|542

602|1471(+3)601|1441601|1444601|1434

601|1431(+1)590|1285601|1446601|1440593|1312593|1320601|1424590|1288603|1494603|1486590|1292462|133460|114

603|1493590|1284460|113

456|49(+1)603|1483

456|57456|50

462|126460|91

593|1318588|1265572|1152581|1241

460|97462|144

572|1172547|952462|122

590|1293465|214462|136

458|65469|234

603|1502568|1117471|264480|432

478|398(+1)576|1212536|897474|335465|185

600|1409541|929

572|1169570|1132564|1056469|230474|305471|268471|263471|252

458|82460|111

603|1504596|1348

458|68602|1459(+1)

458|71602|1464(+1)603|1482(+1)

458|81(+1)458|74(+1)458|64(+1)

559|1006518|731

602|1454601|1427(+1)

593|1313601|1423590|1294596|1365596|1356596|1351588|1266559|1009480|434478|382

605|1520(+1)462|124(+1)

603|1481602|1461(+2)

598|1382588|1278590|1295588|1254465|216465|205460|116

458|87603|1501522|791

602|1456601|1421596|1354596|1349596|1344593|1319581|1242581|1228572|1183572|1156568|1112565|1081564|1048518|755513|722497|589492|549489|507478|373471|256460|101

458|62

513|720/1526|808/1554|973/1554|973/2497|573/2531|857/1541|903/1603|1484/1541|903/2474|321/2559|1008/1526|812/1474|321/1518|749/1471|252/1474|305/1518|744/1536|872/1531|836/1559|1008/2484|458/1497|573/1541|923/1462|139/2462|139/3469|231/1462|139/1522|762/1598|1388/1480|418/1522|762/3570|1128/1474|304/1476|344/1456|46/1497|576/1508|660/1531|847/1564|1041/1602|1460/1518|734/1531|831/1531|847/2564|1036/1564|1046/1456|31/1508|660/3508|661/2593|1332/1456|33/1462|141/1456|31/2456|33/2456|33/2−1462|131/1526|805/1518|734/2531|834/1531|834/2508|660/4472|275/2472|275/1536|882/1508|661/1−1472|277/1508|661/1458|72/1593|1314/1460|93/1590|1304/1593|1325/2593|1326/1598|1373/1460|119/1593|1325/1593|1326/2458|83/1590|1297/1590|1303/1564|1041/2596|1350/1456|45/2456|54/1601|1439/1456|36/1456|45/1458|63/1456|36/2602|1476/1456|56/1−1464|153/1456|56/1458|63/2462|141/2464|173/1456|45/3460|106/1464|159/1464|162/1531|852/1593|1322/1492|526/1472|289/1513|701/1593|1320/1593|1320/3593|1320/2601|1441/2593|1312/1601|1424/1601|1434/1601|1440/1601|1441/1590|1288/1601|1444/1602|1471/1601|1446/1590|1284/1590|1292/1590|1292/2603|1494/1456|50/1603|1486/1603|1493/1593|1318/1462|126/2462|144/1593|1318/1−1460|97/1588|1265/1462|126/2−1572|1152/1465|185/1462|136/2458|65/1465|214/2471|264/1568|1117/1590|1293/1478|400/1478|398/1480|432/1478|398/1−1478|400/1−1478|400/2471|263/2469|230/2572|1169/1564|1056/3570|1132/1471|263/1474|305/2564|1056/2469|230/1570|1132/2572|1169/2460|111/1458|68/1602|1459/1603|1504/1458|82/1602|1464/2458|88/1472|288/1541|905/1541|905/2559|1006/1602|1464/1602|1464/3603|1482/1593|1313/1601|1427/1601|1433/1602|1454/1590|1294/1601|1423/1596|1365/1588|1266/1478|382/1605|1520/1602|1461/1602|1474/1603|1481/1598|1382/1590|1295/1465|216/1465|216/2458|87/1460|116/1603|1501/1522|791/1522|791/2602|1456/1601|1421/1596|1354/1596|1349/1596|1344/1593|1319/1581|1242/1581|1228/1572|1183/1572|1156/1568|1112/1565|1081/1564|1048/1518|755/1513|722/1497|589/2492|549/1489|507/1478|373/1471|256/1460|101/1458|62/1458|62/2

Figure 6: Modular graph layout. Nodes and interactions are colored according to the module they belong to.Black color is used for interaction across modules. Left and right side nodes represent bacteria and phages,respectively.

3.2.8 Statistical analysis in the entire network

We can perform an statistical analysis in the entire network for nestedness and modularity. In order to makean statistical analysis of the structure values we need to decide how many replicates we will need and whatnull model is more convenient for what we need. File NullModels.m contain all the available null models,while file StatisticalTest.m contains all the functions required for performing this analysis. The current

16

Page 17: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

null models are:

NullModels.EQUIPROBABLE , Pij = E/(mn) – the connectance of the network is respected, but notthe number of interactions in which each node is involved.

NullModels.AVERAGE , Pij = (ki/n + dj/m)/2 – the connectance, and the expected number of inter-actions in which each node is involved, are respected

NullModels.AVERAGE COLS , Pij = ki/n – the connectance, and the expected number of interactionsof row nodes, are respected

NullModels.AVERAGE ROWS , Pij = dj/m – the connectance, and the expected number of interac-tions of column nodes, are respected

NullModels.FIXED - this model creates random matrices that respect the total sums of each row andcolumn of the bipartite adjacency matrix. It uses a random swapping algorithm.

To perform the statistical analysis of all the structure values we can just typebp.statistics.DoCompleteAnalysis(), which will perform an analysis using the default number ofrandom matrices (Options.REPLICATES) and the default null model (Options.DEFAULT_NULL_MODEL).However, here we will chose directly those parameters:

216 % Do an analysis of modularity and nestedness values using 100 random217 % matrices and the EQUIPROBABLE (Bernoulli) null model.218 bp.statistics.DoCompleteAnalysis(100, @NullModels.EQUIPROBABLE);

Creating 100 null random matrices...

Performing NODF statistical analysis...

Performing Modularity statistical analysis...

Performing NTC statistical analysis...

The last function call printed information about the current status of the simulation. For printing theresults we need to call:

222 % Both calls print the same information223 bp.printer.PrintStructureStatistics(); %Print the statistical values224 bp.statistics.Print(); %Print the statistical values

Modularity

Used algorithm: LeadingEigenvector

Null model: NullModels.EQUIPROBABLE

Replicates: 100

Qb value: 0.7951

mean: 0.4403

std: 0.0050

z-score: 71.2951

percentil: 100.0000

Qr value: 0.8333

mean: 0.1082

std: 0.0214

z-score: 33.8450

percentil: 100.0000

Nestedness

17

Page 18: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

Used algorithm: NestednessNODF

Null model: NullModels.EQUIPROBABLE

Replicates: 100

Nestedness value: 0.0341

mean: 0.0240

std: 0.0006

z-score: 16.5544

percentil: 100.0000

The printed information is as follows:

� Used algorithm: The algorithm that was used for calculating the metric.

� value: value to be tested (e.g. nestedness or modularity).

� replicates: number of replicates used during testing.

� mean: mean of the replicate values.

� std: standard deviation of the replicate values (note that distributions of network values are notnecessarily well described by a normal distribution).

� zscore: The z-score of value assuming that the replicate values represent the entire population.

� percentile: The percentage of replicate values that are smaller than value.

Additional information that can be acceded via code includes the mean, standard deviation, and t-testresults. Be aware that the number of replicates is especially critical parameter for the results of the statisticalanalysis. To chose this number consider the size and fill of the matrix. As a rule of thumb, 100 works fineas quick analysis, and 10,000 for a more accurate result (up to a matrix size of 300 by 300).

3.2.9 Statistical Analysis of the internal modules

In addition to be able to perform structure analysis in the entire network, we may be able (depending in thesize and module configuration of the tested matrix) to perform a structural analysis in the internal modules.We will show next (i) how to do an analysis of modularity and nestedness in the internal modules and (ii)how to test for a possible correlation between node labeling and module configuration. All the functions forperforming this kind of analysis is encoded in file InternalStatistics.m. For calculating the statisticalstructure of the internal modules we just need to call:

250 % 100 random matrices using the EQUIPROBABLE null model.251 bp.internal statistics.TestInternalModules(100,@NullModels.EQUIPROBABLE);

The last function call will print information about what is the current matrix (module) that is beingevaluated. Like this, the user knows at every moment the current status of the analysis:

Testing Matrix: 1 . . .

Testing Matrix: 2 . . .

Testing Matrix: 3 . . .

Testing Matrix: 4 . . .

Testing Matrix: 5 . . .

Testing Matrix: 6 . . .

Testing Matrix: 7 . . .

. . . and so on . . .

18

Page 19: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

Finally, to print the results we just need to call:

254 bp.printer.PrintStructureStatisticsOfModules(); % Print the results

Network, Qb,Qb mean,Qb z-score,Qb percent, Qr, Qr mean,Qr z-score,Qr percent, N, N mean,N z-score,N percent

1,0.28198,0.25424, 3.052, 100, 0.4052,-0.0090706, 8.6901, 100,0.53237,0.29431, 18.7592, 100

2,0.38344,0.28069, 8.11, 100, 0.59091, 0.082727, 8.7795, 100,0.37935,0.33732, 1.8029, 96

3,0.36091, 0.2856, 8.3161, 100, 0.3361, 0.022075, 5.3604, 100,0.36098,0.24427, 9.3941, 100

4, 0.495,0.40179, 4.61, 100, 0.66667, 0.29133, 5.7683, 100,0.34029,0.22005, 5.0641, 100

5,0.34295,0.25917, 6.5907, 100, 0.5614, 0.042982, 9.5962, 100,0.42548,0.37412, 1.9607, 98

6,0.37778, 0.311, 2.1714, 100, 0.6, 0.28533, 2.0792, 98,0.38468,0.37225, 0.21945, 55

7,0.49146,0.33043, 7.2185, 100, 0.91837, 0.20245, 8.548, 100,0.25255,0.33147, -1.695, 3

8,0.16272,0.18724, -1.7281, 3, 0.30769, 0.15, 1.1627, 83,0.76951,0.56351, 3.8483, 100

9,0.22222,0.17667, 1.5673, 90, 0.55556, 0.38444, 1.4824, 96,0.46154,0.56869, -1.0421, 14

10,0.10526,0.11098, -0.45415, 16, 0.21053, 0.21895, -0.1065, 7,0.66822, 0.6694,-0.013412, 45

11,0.48148,0.37346, 2.1981, 99, 0.77778, 0.41222, 2.5832, 98, 0.2483,0.31196, -1.0607, 10

12,0.13173,0.15876, -2.3413, 1,-0.052632, 0.1193, -1.2618, 6,0.74994,0.60985, 2.4645, 100

13, 0.4,0.30636, 1.9125, 97, 0.86667, 0.40667, 2.7075, 99,0.41398,0.40417, 0.092677, 55

14,0.06414,0.11336, -4.8795, 0, 0.55102, 0.2102, 3.7813, 100,0.38596,0.66925, -3.7248, 1

15, 0.25,0.20938, 0.97224, 81, 0.5, 0.31, 0.73365, 44,0.44444,0.61944, -0.84654, 11

16, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

17,0.16327,0.14531, 0.88196, 44, 0.42857, 0.42857, NaN, 0,0.66667,0.66667, 0.99499, 0

18, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

19, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

20, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

21, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

22, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

23, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

24, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

25, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

26, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

27, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

28, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

29, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

30, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

31, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

32, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

33, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

34, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

35, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

36, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

37, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

38, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

39, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

40, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

41, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

42, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

43, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

44, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

45, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

46, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

47, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

48, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

49, 0, 0, NaN, 0, 1, 1, NaN, 0, 0, 0, NaN, 0

The module indexing is in the same order that the plotted modularity matrix, in which Network 1corresponds to the one located at the top right of Figure 5. This last created table shows the same valuespreviouslly described. However it is specially usefull for describing some of the possible results that the usermay get at some point. What follows summarize some of the important points:

� NaN values appear in many of the z-scores. The reason of those values is because they are fullyconnected and mostly composed of only one node of each type (a matrix of size 1 × 1. Thereforeonly one permutation of the matrix exist and by consequence all the random matrices have the samestructure than the one being analyzed. This makes the standard deviation to be 0, and therefore thez-score to be 0/0 = NaN.

We can also study if a correlation exists between the row labeling and the module configuration. Forperforming this analysis we always will need a classification for rows and/or columns that group them indifferent sets. In this case we have as labeling the station number from which the bacteria and phageswere extracted. Therefore what we will study is if there exist a correlation between the station location(geography) and the module configuration. We will use the same method that was used in Flores et al 2012[3]. Given the labeling this method calculates the diversity index of the labeling inside each module andcompare it with random permutations of the labeling across the matrix.

266 %Using the labeling of bp and 1000 random permutations267 bp.internal statistics.TestDiversityRows(1000);

19

Page 20: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

268 % Using specific labeling and Shannon index269 bp.internal statistics.TestDiversityColumns( ...270 1000,moebus.phage stations,@Diversity.SHANNON INDEX);271 %Print the information of column diversity272 bp.printer.PrintColumnModuleDiversity();

Diversity index: Diversity.SHANNON_INDEX

Random permutations: 1000

Module,index value, zscore,percent

1, 2.4873, -1.9465, 2.6

2, 1.9722, -1.5477, 4.6

3, 2.2497, -5.9225, 0

4, 1.4791, -6.0072, 0

5, 1.8174, -5.9413, 0

6, 1.6094, 0.57569, 27.3

7, 1.0906, -8.7094, 0

8, 1.0042, -6.007, 0

9, 1.4942, -2.9247, 0.5

10, 1.7479,-0.41875, 12.4

11, 0.45056, -8.4223, 0

12, 1.7678, -2.8444, 0.5

13, 1.3322, -1.2948, 2.3

14, 1.677, -2.4976, 0.5

15, 1.0397, -2.0919, 0.6

16, 1.0986, 0.28398, 7.8

17, 0, NaN, 0

18, 0, NaN, 0

19, 0, NaN, 0

20, 0.63651, -2.8875, 0

21, 0, NaN, 0

22, 0, NaN, 0

23, 0, -5.6834, 0

24, 0.69315, 0.20402, 4

25, 0, NaN, 0

26, 0, -4.8339, 0

27, 0, NaN, 0

28, 0, NaN, 0

29, 0, NaN, 0

30, 0, NaN, 0

31, 0, NaN, 0

32, 0, NaN, 0

33, 0, NaN, 0

34, 0, NaN, 0

35, 0, NaN, 0

36, 0, NaN, 0

37, 0, NaN, 0

38, 0, NaN, 0

39, 0, NaN, 0

40, 0, NaN, 0

41, 0, NaN, 0

42, 0, NaN, 0

43, 0, NaN, 0

20

Page 21: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

44, 0, NaN, 0

45, 0, NaN, 0

46, 0, NaN, 0

47, 0, NaN, 0

48, 0, -5.8889, 0

Using a one tailed p-value of 0.05 we can see that 1-5,7-9,11-15 are not as diverse as random labeling andconclude that those modules have phages that were isolated from similar locations. The module indexing isin the same order that the plotted modularity matrix, in which module 1 corresponds to the one located atthe top of the plot. The NaN values happens because such modules have only a single phage and thereforethe standard deviation used for calculating the z-score is 0.

Before finishing this example, we must say that in order to analyze the statistical significance of nestednessand modularity of the internal modules, what BiMat is really performing is a meta analysis. This functionalityis encoded in the class MetaStatistics. This class makes use of the class MetaStatisticsPlotter to createinteresting visualization of the matrices being analyzed. We show how to use this functionality in the nextexample.

3.3 BiMat - Meta-Statistics Example

This example will introduce the user to the features about how to perform an statistical analysis of a groupof bipartite networks (matrices). For doing that we will use the data from Flores et Al 2011. This dataconsist of 38 bipartite adjacency matrices of different sizes. Each matrix is named according to the firstauthor paper from which it was extracted. We will perform an analysis of modularity and nestedness in theentire set.

This example is located on examples/group_matrices.m and make use ofexamples/phage_bacteria_meta_analysis.mat data file.

3.3.1 Contents

� Add the source to the MATLAB® path� Creating a MetaStatistics object� Perform an statististical analysis in the set of matrices� Using a MetaStatistics object to create your own plots

3.3.2 Add the source to the MATLAB® path

11 %Assuming that you run this script from examples directory12 g = genpath('../'); addpath(g);13 close all; %close all open figures

We need also to load the data from which we will be working on

16 load phage bacteria matrices.mat;

The loaded data is a set of 38 matrices together with a name that refer to the first author and year fromthe paper from which the matrix was extracted. These matrices were published by Flores et Al 2011 [2].

3.3.3 Creating a MetaStatistics object

If the number of random matrices and the null model are not assigned, 100 and AVERAGE are used asdefault. Here we will use 100 random matrices with the EQUIPROBABLE null model

21

Page 22: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

22 mstat = MetaStatistics(phage bacteria matrices.matrices); % Create the main object

3.3.4 Perform an statistical analysis in the set of matrices

Suppose that we are interested in calculating the modularity and nestedness using the NTC algorithm asFlores et Al 2011 did. In addition, following the approach of Flores et Al 2011 [2], we want to use theequiprobable model as null model in our random networks. The way to perform this analysis is by runningthe next lines:

30 mstat.replicates = 100; %How many random networks we want for each matrix31 mstat.null model = @NullModels.EQUIPROBABLE; %Our Null model32 mstat.modularity algorithm = @AdaptiveBrim; %Algorithm for modularity.33 mstat.nestedness algorithm = @NestednessNTC; %Algorithm for nestedness.34 mstat.do community = 1; % Perform Modularity analysis (default)35 mstat.do nestedness = 1; % Perform Nestedness analysis (default)36 mstat.names = phage bacteria matrices.name;37 mstat.DoMetaAnalyisis(); % Perform the analysis.

Testing Matrix: 1 . . .

Testing Matrix: 2 . . .

Testing Matrix: 3 . . .

Testing Matrix: 4 . . .

Testing Matrix: 5 . . .

Testing Matrix: 6 . . .

Testing Matrix: 7 . . .

. . . and so on . . .

Notice that DoMetaAnalysis method prints information about the current networks that is being ana-lyzed, such that the user will know at every moment the current status of the analysis. After the analysisis finished a simple statistical measure to say that a matrix is nested and/or modular is to chose a two tailp-value = 0.05 as Flores et al 2011 did. Therefore, the next lines of code will show how many matrices arefound nested and/or modular

46 fprintf('Number of nested matrices: %i\n',sum(mstat.N values.percentile ≥ 97.5));47 fprintf('Number of modular matrices: %i\n',sum(mstat.Qb values.percentile ≥ 97.5));

Number of nested matrices: 29

Number of modular matrices: 6

Because we only did 100 random matrices you may get different results. For a more accurate result youmay try 1.000 or even 10,000. Finally we can show detailed results for the entire set of matrices:

53 mstat.Print();

Network, Qb, Qb mean,Qb z-score,Qb percent, Qr, Qr mean,Qr z-score,Qr percent, N, N mean,N z-score,N percent

1, 0.30992, 0.24599, 2.5886, 99, 0.81818, 0.16636, 3.9627, 100,0.60166, 0.678, -0.75945, 24

2, 0.2144, 0.21253, 0.10036, 54, 0.44, 0.1024, 1.9222, 92,0.73351,0.69341, 0.37149, 66

3, 0.17556, 0.22576, -1.6619, 4, 0.13333, 0.12467, 0.055595, 55,0.99999,0.66398, 3.9396, 100

4, 0.22449, 0.24862, -0.86772, 12, -0.14286, 0.20143, -1.9187, 0,0.91927,0.74326, 1.3936, 91

5, 0.25652, 0.27901, -1.2848, 8, 0.074074, 0.11037, -0.35654, 32,0.93491,0.52914, 6.1977, 100

6, 0.2699, 0.2936, -0.68086, 26, 0.76471, 0.24, 3.0418, 99,0.76003,0.67532, 0.72106, 79

7, 0.21403, 0.21669, -0.143, 40, 0.58621, 0.10552, 2.9076, 99,0.95766,0.67737, 2.5286, 100

8, 0.174, 0.19425, -3.1699, 0, -0.15789,-0.064737, -1.2478, 1,0.76686,0.42858, 7.2945, 100

9, 0.21718, 0.23151, -1.4067, 9,-0.033898,-0.028136, -0.075524, 31,0.78982,0.43517, 6.8795, 100

10, 0.29191, 0.2811, 0.48576, 67, 0.28205, 0.17436, 0.85949, 70,0.64872,0.55895, 1.2204, 91

11, 0.24033, 0.29148, -2.5914, 0, 0.21951, 0.16439, 0.44398, 64,0.68685,0.55609, 1.6116, 93

22

Page 23: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

12, 0.4821, 0.40073, 2.8901, 100, 0.67568, 0.27568, 3.8592, 100,0.86948,0.64357, 2.7302, 100

13, 0.32099, 0.30988, 0.20222, 45, 0.11111, 0.34222, -1.057, 3,0.74467,0.76221, -0.13176, 46

14, 0.31667, 0.20973, 3.2725, 100, 0.63333, 0.38867, 4.0298, 100,0.78116, 0.643, 3.0432, 100

15, 0.20023, 0.20669, -0.79464, 26, 0.20548,-0.044384, 3.3436, 100, 0.7313,0.42032, 6.9832, 100

16, 0.18956, 0.18757, 0.37716, 65,-0.033493, -0.18445, 2.4474, 99,0.80411,0.33195, 14.855, 100

17,0.045608,0.040801, 2.5875, 99, -0.43931,-0.024509, -6.2235, 0,0.99822,0.90924, 3.0789, 100

18, 0.1231, 0.13176, -1.3919, 8, 0.17808,-0.050411, 1.773, 88,0.94654,0.69728, 2.9167, 100

19, 0, 0, NaN, 0, 1, 1, NaN, 0,0.99998,0.99998, -0.99499, 0

20, 0.30568, 0.30689, -0.093846, 47, 0.070707, 0.065455, 0.071881, 56,0.62854,0.48084, 2.6413, 99

21, 0.19136, 0.22327, -1.452, 7, 0.22222, 0.14889, 0.42528, 66,0.97959,0.76606, 1.8373, 99

22, 0.22015, 0.16726, 10.8245, 100, 0.36306, -0.15618, 9.6282, 100,0.96778,0.35335, 15.2339, 100

23, 0.08406, 0.10169, -4.5703, 0, 0.23762, -0.12762, 4.6519, 100,0.98762,0.60238, 6.0343, 100

24, 0.4102, 0.34589, 4.2458, 100, 0.82857, 0.13457, 8.9292, 100,0.69338,0.53292, 2.6264, 99

25, 0.14966, 0.15358, -0.24209, 32, 0.2381, 0.1, 0.65528, 51,0.92211,0.87686, 0.42745, 50

26,0.053624,0.048243, 1.1569, 89, 0.062112, 0.058261, 0.040003, 6,0.99319,0.89658, 3.6763, 100

27, 0.20209, 0.19155, 1.2751, 90, 0.093633, 0.064644, 0.52737, 67,0.83274,0.44163, 10.5648, 100

28, 0.37139, 0.3764, -0.31136, 45, 0.14019, 0.095701, 0.5921, 67,0.79046,0.57808, 4.1357, 100

29, 0.37622, 0.26208, 9.0336, 100, 0.70787, 0.039101, 8.168, 100,0.64449,0.47324, 2.7723, 100

30, 0.33347, 0.30927, 1.7178, 96, 0.54286, 0.095143, 5.5966, 100,0.85292,0.50253, 6.0303, 100

31, 0.22893, 0.24931, -0.99388, 14,-0.096774, 0.13032, -1.8803, 0,0.98194,0.61131, 4.2027, 100

32, 0.18341, 0.11878, 18.4957, 100, 0.28161, -0.15667, 5.4021, 100,0.94908,0.41311, 12.7962, 100

33, 0.3866, 0.37729, 0.76166, 77, 0.32432, 0.059189, 3.8055, 100,0.76762,0.59612, 4.2834, 100

34, 0.4876, 0.43471, 0.66412, 71, 0.45455, 0.47273, -0.091987, 26,0.65529,0.81606, -1.3744, 14

35,0.084203,0.085013, -0.312, 40, -0.24638, -0.14589, -0.93777, 0,0.94752,0.67504, 4.6206, 100

36, 0.61983, 0.5062, 1.4912, 93, 0.81818, 0.59818, 1.3411, 80,0.89709, 0.8485, 0.56436, 68

37, 0.21137, 0.27294, -7.4452, 0, -0.20755, -0.12006, -1.6681, 4, 0.8854,0.41533, 14.0797, 100

38, 0.68222, 0.56131, 3.9645, 100, 0.71429, 0.4302, 3.8722, 100,0.81505,0.80138, 0.35774, 60

3.3.5 Plotting results

The user can visualize the results of the last output in a graphical way. For example for visualizing theresults of modularity and NTC nestedness value, the user can type:

58 mstat.plotter.font size = 10; %Size for x−labels.59 figure(1);60 mstat.plotter.PlotModularValues();61 figure(2);62 mstat.plotter.PlotNestednessValues();

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

Kud

va 1

999

Kan

kila

199

4P

antu

cek

1998

Mid

delb

oe 2

009

Syn

ott 2

009

Kry

lov

2006

Miz

oguc

hi 2

003

Com

eau

2005

Bra

un−

Bre

ton

1981

Ste

nhol

m 2

009

Hol

mfe

ldt 2

007

McL

augh

lin 2

008

Han

sen

2007

Pat

erso

n 20

10W

iche

ls 1

998

Cey

ssen

s 20

09B

arra

ngou

200

2C

omea

u 20

06M

eyer

unp

ubC

ampb

ell 1

995

See

d 20

05D

oi 2

003

Cap

pare

lli 2

010

Cas

o 19

95D

ePao

la 1

998

Lang

ley

2003

Abe

200

7G

oodr

idge

200

3G

amag

e 20

04R

ybni

ker

2006

Pou

llain

200

8Q

uibe

roni

200

3S

ulliv

an 2

003

Mik

lic 2

003

Dup

less

is 2

001

Sut

tle 1

993

Wan

g 20

08Z

inno

201

0

Mod

ular

ity (

Q)

Measured ModularityRandom expectation

(a) Modularity statistics

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

Abe

200

7La

ngle

y 20

03Q

uibe

roni

200

3D

ePao

la 1

998

Sut

tle 1

993

Doi

200

3M

iklic

200

3H

anse

n 20

07B

arra

ngou

200

2G

amag

e 20

04C

aso

1995

Com

eau

2005

Sul

livan

200

3G

oodr

idge

200

3C

omea

u 20

06P

oulla

in 2

008

Hol

mfe

ldt 2

007

Zin

no 2

010

Pat

erso

n 20

10R

ybni

ker

2006

Dup

less

is 2

001

Wic

hels

199

8W

ang

2008

Cam

pbel

l 199

5M

izog

uchi

200

3C

appa

relli

201

0K

rylo

v 20

06S

ynot

t 200

9S

tenh

olm

200

9C

eyss

ens

2009

Mey

er u

npub

McL

augh

lin 2

008

See

d 20

05M

idde

lboe

200

9P

antu

cek

1998

Kan

kila

199

4K

udva

199

9B

raun

−B

reto

n 19

81

Nes

tedn

ess

(N)

Measured NestednessRandom expectation

(b) Nestedness (NTC) statistics

Figure 7: Visual representation of the statistical tests in the set of matrices. Red circles represent the valueof the analyzed networks. White circles represent the mean of the null model, while the error bars representthe networks that falls inside a two-tailed version of the random null model values. The margin of the errorbars are (p-value,1-p-value), where p-value can is an optional argument of the plot functions.

In addition the user can also plot the data in either graph or matrix layout. Here we show for graphnested layout and modular matrix layout. As in the case of a single network, is possible to specify some ofthe most fundamental format properties.

23

Page 24: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

68 mstat.plotter.p value = 0.05; %p−value for color labeling69 % Plot of nested graphs70 mstat.plotter.bead color rows = 'blue'; %Color of row nodes71 mstat.plotter.bead color columns = 'red'; %Color of column nodes72 mstat.plotter.link width = 0.5; %Edge width73 mstat.plotter.use isocline = false; %Do no show isocline inside modules74 figure(3);75 mstat.plotter.PlotModularMatrices(5,8); %Use a grid of 5 x 876 %Plot of modular matrices77 figure(4);78 mstat.plotter.PlotNestedGraphs(5,8);

Abe 2007 Barrangou 2002 Braun−Breton 1981 Campbell 1995 Capparelli 2010 Caso 1995

Ceyssens 2009

Comeau 2005

Comeau 2006

DePaola 1998

Doi 2003 Duplessis 2001 Gamage 2004 Goodridge 2003 Hansen 2007

Holmfeldt 2007

Kankila 1994 Krylov 2006 Kudva 1999 Langley 2003 McLaughlin 2008 Meyer unpub

Middelboe 2009

Miklic 2003

Mizoguchi 2003 Pantucek 1998 Paterson 2010 Poullain 2008 Quiberoni 2003 Rybniker 2006 Seed 2005 Stenholm 2009

Sullivan 2003Suttle 1993 Synott 2009 Wang 2008 Wichels 1998

Zinno 2010

Figure 8: The meta-set collected on Flores et al [2] plotted using the modularity algorithm of the BiMat

library. Red and blue labels represent significant modularity (p ≥ 0.975) and anti-modularity (p ≤ 0.275),respectively. For bibliographic information about these matrices see [2].

24

Page 25: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

2 4 6

2468

10

Abe 2007

2 4

2

4

6

Barrangou 2002

5 10

5

10

15

Braun−Breton 1981

1 2 3 4

12345

Campbell 1995

2 4 6 8

5

10

15

Capparelli 2010

2 4 6

2468

Caso 1995

2 4 6

2468

1012Ceyssens 2009

24681012

5101520

Comeau 2005

5 10

5

10

15

Comeau 2006

5 10

5

10

15

DePaola 1998

2 4 6

2468

10

Doi 2003

2 4 6

2468

1012Duplessis 2001

1 2 3 4

12345

Gamage 2004

510152025

10203040

Goodridge 2003

2468101214

510152025Hansen 2007

5101520

10203040

Holmfeldt 2007

5 1015

10

20

30

Kankila 1994

2 4 6

2468

10

Krylov 2006

2 4 6

2468

10

Kudva 1999

51015

10

20

30

Langley 2003

2 4

2

4

6

McLaughlin 2008

2468101214

510152025

Meyer unpub

24681012

5101520

Middelboe 2009

246810

5

10

15

Miklic 2003

2 4

2

4

6

Mizoguchi 2003

20 40

20406080

Pantucek 1998

20 40

20406080

Paterson 2010

24681012

5101520

Poullain 2008

246810

5

10

15

20Quiberoni 2003

2 4 6 8

5

10

15Rybniker 2006

2 4 6

2468

10

Seed 2005

24681012

5101520

Stenholm 2009

5101520

10203040

Sullivan 2003

2 4

2

4

6

Suttle 1993

2 4 6 8

5

10

15

Synott 2009

2 4

2

4

6

8

Wang 2008

102030

1020304050

Wichels 1998

5 1015

510152025

Zinno 2010

Figure 9: NODF nestedness values of a set of 38 matrices of phage-bacteria networks. A two-tail p-valueof 0.05 was used for labeling the names. Blue and and red lebels represent anti and statistical significance,respectively. Notice that this Figure shows an smaller number of nested matrices than the NTC plot of theprevious figure.

25

Page 26: BiMat : Start Guidebimat.github.io/bimat_start_guide.pdf · 3.1.5 Optional input BiMat has two di erent types of optional input. The rst type is for node labeling and the main use

References

[1] Michael Barber. Modularity and community detection in bipartite networks. Physical Review E,76:066102, 2007.

[2] Cesar O Flores, Justin R Meyer, Sergi Valverde, Lauren Farr, and Joshua S Weitz. Statistical structureof host–phage interactions. Proceedings of the National Academy of Sciences, 108(28):E288–E297, 2011.

[3] Cesar O Flores, Sergi Valverde, and Joshua S Weitz. Multi-scale structure and geographic drivers ofcross-infection within marine bacteria and phages. The ISME journal, 7(3):520–532, 2013.

[4] K Moebus and H Nattkemper. Bacteriophage sensitivity patterns among bacteria isolated from marinewaters. Helgolander Meeresuntersuchungen, 34(3):375–385, 1981.

[5] Timothee Poisot. An a posteriori measure of network modularity. F1000Research, 2, 2013.

26