Attributes {brainGraph} | R Documentation |
Set graph, vertex, and edge attributes common in MRI analyses
Description
set_brainGraph_attr
is a convenience function that sets a number of
graph, vertex, and edge attributes for a given graph object. Specifically, it
calculates measures that are common in MRI analyses of brain networks.
Usage
set_brainGraph_attr(g, type = c("observed", "random"),
use.parallel = TRUE, A = NULL, xfm.type = c("1/w", "-log(w)",
"1-w", "-log10(w/max(w))", "-log10(w/max(w)+1)"),
clust.method = "louvain")
xfm.weights(g, xfm.type = c("1/w", "-log(w)", "1-w", "-log10(w/max(w))",
"-log10(w/max(w)+1)"), invert = FALSE)
Arguments
g |
A graph object |
type |
Character string indicating the type of graphs. Default:
|
use.parallel |
Logical indicating whether to use foreach.
Default: |
A |
Numeric matrix; the (weighted) adjacency matrix, which can be used
for faster calculation of local efficiency. Default: |
xfm.type |
Character string specifying how to transform the weights.
Default: |
clust.method |
Character string indicating which method to use for
community detection. Default: |
invert |
Logical indicating whether or not to invert the transformation.
Default: |
Details
Including type='random'
in the function call will reduce the number of
attributes calculated. It will only add graph-level attributes for:
clustering coefficient, characteristic path length, rich club coefficient,
global efficiency, and modularity.
Value
A graph object with the following attributes:
Graph-level |
Density, connected component sizes, diameter, # of triangles, transitivity, average path length, assortativity, global & local efficiency, modularity, vulnerability, hub score, rich-club coefficient, # of hubs, edge asymmetry |
Vertex-level |
Degree, strength; betweenness, eigenvector, and leverage centralities; hubs; transitivity (local); k-core, s-core; local & nodal efficiency; color (community, lobe, component); membership (community, lobe, component); gateway and participation coefficients, within-module degree z-score; vulnerability; and coordinates (x, y, and z) |
Edge-level |
Color (community, lobe, component), edge betweenness, Euclidean distance (in mm), weight (if weighted) |
xfm.weights
returns the same graph object, with transformed
edge weights plus a graph attribute (xfm.type
) recording the method
of transformation
Negative edge weights
If there are any negative edge weights in the graph, several of the distance-based metrics will not be calculated, because they can throw errors which is undesirable when processing a large dataset. The metrics are: local and nodal efficiency, diameter, characteristic path length, and hubness.
Transforming edge weights
For distance-based measures, it is important to transform the edge weights so that the strongest connections are re-mapped to having the lowest weights. Then you may calculate e.g., the shortest path length which will include the strongest connections.
xfm.type
allows you to choose from 5 options for transforming edge
weights when calculating distance-based metrics (e.g., shortest paths). There
is no “best-practice” for choosing one over the other, but the reciprocal is
probably most common.
1/w
reciprocal (default)
-log(w)
the negative (natural) logarithm
1-w
subtract weights from 1
-log10(w/max(w))
negative (base-10) log of normalized weights
-log10(w/max(w)+1)
same as above, but add 1 before taking the log
To transform the weights back to original values, specify invert=TRUE
.
Community detection
clust.method
allows you to choose from any of the clustering
(community detection) functions available in igraph
. These functions
begin with cluster_
; the function argument should not include this
leading character string. There are a few possibilities, depending on the
value and the type of input graph:
By default,
louvain
is used, callingcluster_louvain
Uses
spinglass
if there are any negative edges and/or the selected method isspinglass
Uses
walktrap
if there are any negative edge weights and any other method (besidesspinglass
) is selectedAutomatically transforms the edge weights if
edge_betweenness
is selected and the graph is weighted, because the algorithm considers edges as distances
Author(s)
Christopher G. Watson, cgwatson@bu.edu
See Also
components
, diameter
,
centr_betw
, betweenness
,
centr_eigen
, transitivity
,
distances
, assortativity
,
coreness
, communities
,
knn