BipartiteNull.jl

BipartiteNull. jl is a tool for building null model of bipartite network.
Author JiangXingChi
Popularity
0 Stars
Updated Last
2 Years Ago
Started In
November 2022

BipartiteNull.jl

Overview

BipartiteNull.jl is a tool for building null model of bipartite network. This work refers to the R package bipartite.

Install

  • Install this package by Julia:
using Pkg;
Pkg.add("BipartiteNull")
  • Install this package by Github:
using Pkg;
Pkg.add(PackageSpec(url="https://github.com/JiangXingChi/BipartiteNull.jl"))
  • Install this package by Gitee:
using Pkg;
Pkg.add(PackageSpec(url="https://gitee.com/pandalinux/bipartite-null.jl"))

Example

Example1:

using BipartiteNull,DataFrames;
data=ExampleData(2);
print(data);
df=NullNetworkLevel(data)

Function

Data handling

ExampleData
`ExampleData(order::Int)`
Some simple examples.
# Argument
* `order`:1~7.
# Return
* `data`:One dataframe.
# Example
using BipartiteNull,DataFrames;
data=ExampleData(1)
ReadCSV
`ReadCSV(file::String)`
Read the csv file and convert it to dataframe.
# Argument
* `file`:File name (including path).
# Return
* `data`:One dataframe.
WriteCSV
`WriteCSV(file::String,df::DataFrame)`
Write a csv file.
# Argument
* `file`:File name (including path).
* `df`:A dataframe.
RmZeroCol
`RmZeroCol(data::DataFrame)`
Delete all 0 columns.
# Argument
* `data`:Adjacency matrix of a bipartite network.
# Return
* `newdata`:The columns that are all 0 are deleted on the basis of data.
# Example
using BipartiteNull,DataFrames;
data=ExampleData(1);
print(data);
newdata=RmZeroCol(data)
RmZeroRow
`RmZeroRow(data::DataFrame)`
Delete all 0 rows.
# Argument
* `data`:Adjacency matrix of a bipartite network.
# Return
* `newdata`:The rows that are all 0 are deleted on the basis of data.
# Example
using BipartiteNull,DataFrames;
data=ExampleData(1);
print(data);
newdata=RmZeroRow(data)
Weight2Bool
`Weight2Bool(data::DataFrame)`
Convert weight values in the matrix to Boolean values.
# Argument
* `data`:Weight adjacency matrix of a bipartite network.
# Return
* `newdata`:Boolean adjacency matrix of a bipartite network.
# Example
using BipartiteNull,DataFrames;
data=ExampleData(5);
print(data);
newdata=Weight2Bool(data)
SampleVector
`SampleVector(v::Vector)`
Reorder.
# Argument
* `v`:Vector.
# Return
* `vnull`:New vector.
# Example
using BipartiteNull;
v=[1,2,3,4,5,6,7,8,9];
print(v);
vnull=SampleVector(v)
Coin
`Coin(pvalue::Float64)`
Output true by probability
# Argument
* `pvalue`:Probability of true output(greater than 0 but less than 1).Please enter the value to one decimal place or two decimal places.
# Return
* `Bool`:2 values, true or false.
# Example
using BipartiteNull;
Coin(0.5)
CoinTest
`CoinTest(pvalue::Float64,testnumber::Int)`
Test Coin function.
# Argument
* `pvalue`:Probability of true output(greater than 0 but less than 1).Please enter the value to one decimal place or two decimal places.
* `testnumber`:Test number.
# Return
* `Bool`:The frequency of true is theoretically close to pvalue.
# Example
using BipartiteNull;
CoinTest(0.5,100000)
Row2Edge
`Row2Edge(data::DataFrame)`
Convert nodes represented by rows to edges.
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `newdata`:One-mode network after projection.
# Example
using BipartiteNull,DataFrames;
data=ExampleData(6);
print(data);
newdata=Row2Edge(data)
Col2Edge
`Col2Edge(data::DataFrame)`
Convert nodes represented by columns to edges.
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `newdata`:One-mode network after projection.
# Example
using BipartiteNull,DataFrames;
data=ExampleData(6);
print(data);
newdata=Col2Edge(data)
Splicing4Matrix
`Splicing4Matrix(data::DataFrame)`
The bipartite network is expanded into a one-mode network through matrix splicing.
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `newdata`:One-mode network after splicing.
# Example
using BipartiteNull,DataFrames;
data=ExampleData(6);
print(data);
newdata=Splicing4Matrix(data)
Bipartite2Graph
`Bipartite2Graph(data::DataFrame,model::String)`
Convert the adjacency matrix of the bipartite network into the network structure under Graphs.jl through projection or expansion.
# Argument
* `data`:The adjacency matrix of a bipartite network.
* `fun`:Select the conversion method and support three functions:"Row2Edge","Col2Edge","Splicing4Matrix".
# Return
* `omm`:One-mode matrix by projection or expansion.
* `graph`:The network structure under Graphs.jl.
# Example
using BipartiteNull,DataFrames,Graphs;
data=ExampleData(6);
print(data);
omm,graph=Bipartite2Graph(data,"Row2Edge")
PN1
`PN1(v::Vector)`
Calculate the number of -1*1.
# Argument
* `v`:A vector.
# Return
* `c`:The number of -1*1.
# Example
v=[1,1,-1,0];
PN1(v)

Bipartite network attributes

Connectance
`Connectance(data::DataFrame)`
Realised proportion of possible links.
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `value`:Connectance value.
# Example
using BipartiteNull,DataFrames;
data=ExampleData(6);
print(data);
value=Connectance(data)
LinksPerSpecies
`LinksPerSpecies(data::DataFrame)`
Sum of links divided by number of species(consider the overall and individual situation).
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `all`:Sum of links divided by number of all species.
* `agroup`:Sum of links divided by number of the species of rows.
* `bgroup`:Sum of links divided by number of the species of columns.
# Example
using BipartiteNull,DataFrames;
data=ExampleData(6);
print(data);
all,agroup,bgroup=LinksPerSpecies(data)
Cscore
`Cscore(data::DataFrame)`
Calculate checkerboard units.
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `all`:Checkerboard units/2*2 units.
* `agroup`:C score of the species of rows.
* `bgroup`:C score of the species of columns.
# Example
using BipartiteNull,DataFrames,Graphs;
data=ExampleData(2);
print(data);
all,agroup,bgroup=Cscore(data)
Cscore22
`Cscore22(data::DataFrame)`
Calculate checkerboard units.
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `all`:Checkerboard units/2*2 units.
* `agroup`:C score of the species of rows.
* `bgroup`:C score of the species of columns.
# Example
using BipartiteNull,DataFrames,Graphs;
data=ExampleData(2);
print(data);
all,agroup,bgroup=Cscore22(data)
GlobalClusterCoefficient
`GlobalClusterCoefficient(data::DataFrame)`
Calculate the global cluster coefficient of the bipartite network.
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `agroup`:Global cluster coefficient of the species of rows.
* `bgroup`:Global cluster coefficient of the species of columns.
# Example
using BipartiteNull,DataFrames,Graphs;
data=ExampleData(6);
print(data);
agroup,bgroup=GlobalClusterCoefficient(data)
GlobalClusterCoefficientQuaternion
`GlobalClusterCoefficientQuaternion(data::DataFrame)`
Calculate the global cluster coefficient(quaternion) of the bipartite network.
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `value`:Global cluster coefficient(quaternion).
# Example
using BipartiteNull,DataFrames,Graphs;
data=ExampleData(3);
print(data);
vlaue=GlobalClusterCoefficientQuaternion(data)
MeanLocalClusteringCoefficient
`MeanLocalClusteringCoefficient(data::DataFrame)`
Calculate the local cluster coefficient of the bipartite network.
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `agroup`:Local cluster coefficient of the species of rows.
* `bgroup`:Local cluster coefficient of the species of columns.
# Example
using BipartiteNull,DataFrames,Graphs;
data=ExampleData(6);
print(data);
agroup,bgroup=MeanLocalClusteringCoefficient(data)
ModularityLabelPropagation
`ModularityLabelPropagation(data::DataFrame)`
Calculate the modularity by label propagation.
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `all`:Modularity of all species.
* `agroup`:Modularity of the species of rows.
* `bgroup`:Modularity of the species of columns.
# Example
using BipartiteNull,DataFrames,Graphs;
data=ExampleData(1);
print(data);
all,agroup,bgroup=ModularityLabelPropagation(data)

Vertex attributes

LocalClusteringCoefficient
`LocalClusteringCoefficient(data::DataFrame)`
Calculate the local cluster coefficient of the bipartite network.
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `agroup`:Local cluster coefficient of the species of rows.
* `bgroup`:Local cluster coefficient of the species of columns.
# Example
using BipartiteNull,DataFrames,Graphs;
data=ExampleData(6);
print(data);
agroup,bgroup=LocalClusteringCoefficient(data)
LabelPropagation
`LabelPropagation(data::DataFrame)`
Mark the label by label propagation.
# Argument
* `data`:The adjacency matrix of a bipartite network.
* `maxiter`:Return after maxiter iterations if convergence has not completed.
# Return
* `newlabel`:Vertex and label information.
# Example
using BipartiteNull,DataFrames,Graphs;
data=ExampleData(1);
print(data);
newlabel=LabelPropagation(data)
BetweennessCentrality
`BetweennessCentrality(data::DataFrame)`
Calculate the betweenness centrality of the bipartite network.
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `all`:Betweenness centrality of all species.
* `agroup`:Betweenness centrality of the species of rows.
* `bgroup`:Betweenness centrality of the species of columns.
# Example
using BipartiteNull,DataFrames,Graphs;
data=ExampleData(1);
print(data);
all,agroup,bgroup=BetweennessCentrality(data)
ClosenessCentrality
`ClosenessCentrality(data::DataFrame)`
Calculate the closeness centrality of the bipartite network.
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `all`:Closeness centrality of all species.
* `agroup`:Closeness centrality of the species of rows.
* `bgroup`:Closeness centrality of the species of columns.
# Example
using BipartiteNull,DataFrames,Graphs;
data=ExampleData(1);
print(data);
all,agroup,bgroup=ClosenessCentrality(data)
DegreeCentrality
`DegreeCentrality(data::DataFrame)`
Calculate the degree centrality of the bipartite network.
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `all`:Degree centrality of all species.
* `agroup`:Degree centrality of the species of rows.
* `bgroup`:Degree centrality of the species of columns.
# Example
using BipartiteNull,DataFrames,Graphs;
data=ExampleData(1);
print(data);
all,agroup,bgroup=DegreeCentrality(data)

Null model

Null1
`Null1(data::DataFrame)`
Null model 1, the constraint condition is that the number of species remains unchanged and the connectivity remains unchanged.
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `nulldata`:Dataframe generated by null model 1.
# Example
using BipartiteNull,DataFrames;
data=ExampleData(7);
print(data);
nulldata=Null1(data)
Null2
`Null2(data::DataFrame,coinpvalue::Float64)`
Keep the degree distribution of the original node unchanged.
# Argument
* `data`:The adjacency matrix of a bipartite network.
* `coinpvalue`:Probability of true output(greater than 0 but less than 1).Please enter the value to one decimal place or two decimal places.
# Return
* `nulldata`:Dataframe generated by null model 2.
# Example
using BipartiteNull,DataFrames;
data=ExampleData(7);
print(data);
nulldata=Null2(data,0.5)
Null3
`Null3(data::DataFrame)`
Keep the degree distribution of the original node unchanged.
# Argument
* `data`:The adjacency matrix of a bipartite network.
# Return
* `nulldata`:Dataframe generated by null model 3.
# Example
using BipartiteNull,DataFrames;
data=ExampleData(7);
print(data);
nulldata=Null3(data)

Result integration

NetworkLevel
`NetworkLevel(data::DataFrame,ID::String)`
Integration of some indicators of the bipartite network.
# Argument
* `data`:The adjacency matrix of a bipartite network.
* `ID`:The name of the network.
# Return
* `df`:Integration of some indicators of the bipartite network.
# Example
using BipartiteNull,DataFrames;
data=ExampleData(7);
print(data);
df=NetworkLevel(data,"original")
NullNetworkLevel
`NullNetworkLevel(data::DataFrame;num=100,fun="Null3",coinpvalue=0.5)`
Integration of some indicators of the bipartite network(original and null model).
# Argument
* `data`:The adjacency matrix of a bipartite network.
* `num`:Generated quantity of null model.
* `fun`:Generation method of null model, you can select "Null1","Null2","Null3".
* `coinpvalue`:Probability of true output(greater than 0 but less than 1).Please enter the value to one decimal place or two decimal places.
# Return
* `df`:Integration of some indicators of the bipartite network(original and null model).
# Example
using BipartiteNull,DataFrames;
data=ExampleData(2);
print(data);
df=NullNetworkLevel(data)