make_corex_tidygraph: Make a tidygraph object from an rcorex object or objects

View source: R/make_corex_tidygraph.R

make_corex_tidygraphR Documentation

Make a tidygraph object from an rcorex object or objects

Description

Function to created a tidygraph object from a fitted corex object or list of objects that represent hierarchical data structures

Usage

make_corex_tidygraph(corexes)

Arguments

corexes

A single corex object, or a list of corex objects that should be each a layer of a hierarchy (see examples)

Value

Returns a tidygraph object that represent the learned structure in the supplied corex object or objects. In the tidygraph object edge thickness is proportional to mutual information and node size is represents mutual multivariate information among children

Examples

 ## Not run: 
library(rcorex)
library(ggraph)

data("iris")
# Need to convert species factor variable to indicator variables
iris <- data.frame(iris , model.matrix(~iris$Species)[,2:3])
iris$Species <- NULL

# fit two layers of corex
layer1 <- biocorex(iris, 3, 2, marginal_description = "gaussian", repeats = 5)
layer2 <- biocorex(layer1$labels, 1,2, marginal_description = "discrete", repeats = 5)

# make a tidygraph of one layer
g1 <- make_corex_tidygraph( layer1 )
# make a tidygraph of two layers
g_hier <- make_corex_tidygraph( list(layer1, layer2))

# Plot network graph of one layer
ggraph(g1, layout = "fr") +
    geom_node_point(aes(size = node_size), show.legend = FALSE) +
    geom_edge_hive(aes(width = thickness), alpha = 0.75, show.legend = FALSE) +
    #scale_edge_width(range = c(0.2, 2)) +
    geom_node_text(aes(label = names), repel = TRUE) +
    theme_graph()

# Plot network graph of both layers
ggraph(g_hier, layout = "fr") +
    geom_node_point(aes(size = node_size), show.legend = FALSE) +
    geom_edge_hive(aes(width = thickness), alpha = 0.75, show.legend = FALSE) +
    #scale_edge_width(range = c(0.2, 2)) +
    geom_node_text(aes(label = names), repel = TRUE) +
    theme_graph()
    
## End(Not run)


jpkrooney/rcorex documentation built on July 25, 2022, 1:37 a.m.