View source: R/network_analysis.R
addNodeStats | R Documentation |
Given a list of network objects returned by
buildRepSeqNetwork()
or
generateNetworkObjects()
,
computes a specified set of network properties for the network nodes.
The list of network objects is returned
with each property added as a variable to the node metadata.
addNodeStats(
net,
stats_to_include = chooseNodeStats(),
cluster_fun = "fast_greedy",
cluster_id_name = "cluster_id",
overwrite = FALSE,
verbose = FALSE,
...
)
net |
A |
stats_to_include |
Specifies which network properties to compute.
Accepts a vector created using
|
cluster_fun |
A character string specifying the clustering algorithm to use when
computing cluster membership.
Applicable only when |
cluster_id_name |
A character string specifying the name of the cluster membership variable
to be added to the node metadata.
Applicable only when |
overwrite |
Logical. If |
verbose |
Logical. If |
... |
Named optional arguments to the function specified by |
Node-level network properties are properties that pertain to each individual node in the network graph.
Some are local properties, meaning that their value for a given node depends only on a subset of the nodes in the network. One example is the network degree of a given node, which represents the number of other nodes that are directly joined to the given node by an edge connection.
Other properties are global properties, meaning that their value for a given node
depends on all of the nodes in the network. An example is the authority score of
a node, which is computed using the entire graph adjacency matrix (if we denote
this matrix by A
, then the principal eigenvector of A^T A
represents
the authority scores of the network nodes).
See chooseNodeStats()
for a list of the available node-level network properties.
The list net
must contain the named elements
igraph
(of class igraph
),
adjacency_matrix
(a matrix
or
dgCMatrix
encoding edge connections),
and node_data
(a data.frame
containing node metadata),
all corresponding to the same network. The lists returned by
buildRepSeqNetwork()
and
generateNetworkObjects()
are examples of valid inputs for the net
argument.
A modified copy of net
,
with net$node_data
containing an additional column
for each new network property computed.
See chooseNodeStats()
for the network property names,
which are used as the column names,
except for the cluster membership variable,
whose name is the value of cluster_id_name
.
Brian Neal (Brian.Neal@ucsf.edu)
Hai Yang, Jason Cham, Brian Neal, Zenghua Fan, Tao He and Li Zhang. (2023). NAIR: Network Analysis of Immune Repertoire. Frontiers in Immunology, vol. 14. doi: 10.3389/fimmu.2023.1181825
chooseNodeStats()
set.seed(42)
toy_data <- simulateToyData()
net <- generateNetworkObjects(
toy_data, "CloneSeq"
)
# Add default set of node properties
net <- addNodeStats(net)
# Modify default set of node properties
net <- addNodeStats(
net,
stats_to_include =
chooseNodeStats(
closeness = TRUE,
page_rank = FALSE
)
)
# Add only the spepcified node properties
net <- addNodeStats(
net,
stats_to_include =
exclusiveNodeStats(
degree = TRUE,
transitivity = TRUE
)
)
# Add all node-level network properties
net <- addNodeStats(
net,
stats_to_include = "all"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.