wgcna2graphDF: Convert adjacency or TOM matrix to igraph data.frame

View source: R/utility_functions.R

wgcna2graphDFR Documentation

Convert adjacency or TOM matrix to igraph data.frame

Description

Convert TOM matrix (from WGCNA analysis) to igraph data.frame and filter top connections. Uses igraph::graph_from_adjacency_matrix to convert matrix to data.frame.

Usage

wgcna2graphDF(
  w.mat,
  top.n = NULL,
  top.percentile = NULL,
  graph.type = "undirected"
)

Arguments

w.mat

TOM or adjacency matrix.

top.n

Numeric specifying N top connections to return (N < number of connections). If top.n and top.percentile are NULL, all connections retained.

top.percentile

Numeric [0,1] specifying Nth percetile of top connections to return. If top.n and top.percentile are NULL, all connections retained.

graph.type

Type of graph. Default is "undirected"

Value

igraph data.frame

Author(s)

Nicholas Mikolajewicz

Examples


# get connectivity for specified module
module.name <- names(module.list.all)[names(module.list.all) %in% which.modules]
module.gene.cur <- module.list.all[[module.name]]
w.cur <- w.mat[rownames(w.mat) %in% module.gene.cur, colnames(w.mat) %in% module.gene.cur]

# get igraph data.frame for subset of connections
w.df.top <- wgcna2graphDF(w.cur, top.n = top.n.interactions)
w.df.top$module.membership <- module.name



NMikolajewicz/scMiko documentation built on June 28, 2023, 1:41 p.m.