get_tripartite {triversity} | R Documentation |
Build a properly-structured tripartite graph from raw data.
Description
get_tripartite
builds a properly-structured tripartite graph
from a file or from a data.frame
containing raw data. This object can then
be used by the other functions of this package. The structure
of the input data and of the resulting structure is detailed below.
Usage
get_tripartite(filename = NULL, data = NULL)
Arguments
filename |
A string giving the path to the file containing the raw data. The input file should contain
at least four columns, separated by spaces. Each row gives a link between
two nodes belonging to two different levels of the tripartite graph.
The first column gives the level of the first node (any integer in
{ |
data |
A This |
Value
A properly-structured tripartite graph that can be used by the other functions
of the triversity
package.
The resulting object encodes the names of the nodes at the three levels of the tripartite
graph, as well as the transition matrices of random walks following different paths
between levels (encoded as sparse matrices of floats in [0
,1
], with all
rows summing to 1
). These transition matrices
are then used by functions such as get_distribution_from_path
to
compute the probability distributions of such random walks, or such as
get_diversity_from_path
to compute the diversity of these distributions.
Assuming the object returned by get_tripartite
is stored in the tripartite
variable, then:
-
tripartite$nodes
is a list of string vectors giving the names of the nodes constituting the three levels of the tripartite graph (resp.tripartite$nodes$level1
,tripartite$nodes$level2
, andtripartite$nodes$level3
). -
tripartite$transitions
is adata.tree
whose nodes each contains the transition matrix of the corresponding random walk. For example,tripartite$transitions$level1$level2$mat
gives the transition matrix from level 1 to level 2.
Examples
data (tripartite_example)
tripartite <- get_tripartite (data=tripartite_example)
tripartite$nodes$level1
tripartite$nodes$level2
tripartite$level1$level2$mat
tripartite