matrix2graph: Convert transition matrix to an igraph object

View source: R/network.functions.R

matrix2graphR Documentation

Convert transition matrix to an igraph object

Description

Function to convert a transition matrix to an igraph object

Usage

matrix2graph(trans, SOM, SOM.hc, col.set, diag = FALSE)

Arguments

trans

a transition matrix (usually obtained from comp.trans.mat)

SOM

a kohonen object that form the network

SOM.hc

a vector of cluster assignment for SOM neurons

col.set

a vector of colors used for the SOM clusters

diag

boolean condition to include diagonal elements

Value

An igraph object, with SOM properties annotated

Author(s)

Stefano Motta stefano.motta@unimib.it

Examples

#Read example SOM data
som_model <- readRDS(system.file("extdata", "SOM_HIFa.rds", package = "SOMMD"))
#Divide the SOM in the selected number of clusters
som_cl <- cutree(hclust(dist(som_model$codes[[1]], method="euclidean"), method="complete"), 4)
#Compute transition matrix
tr_mat <- comp.trans.mat(som_model, start = 1)
#Define a set of colors
colors <- c("#1f78b4", "#33a02c", "#e31a1c", "#ffff88", "#6a3d9a")
#Create graph object
net <- matrix2graph(tr_mat, som_model, som_cl, colors, diag=FALSE)

SOMMD documentation built on Oct. 2, 2024, 5:07 p.m.