% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/build_graph_from_mat.R
\name{build_graph_from_mat}
\alias{build_graph_from_mat}
\title{Build a correlation-based network from a matrix}
\usage{
build_graph_from_mat(
  mat,
  transfrom.method = c("none", "scale", "center", "log2", "log10", "ln", "rrarefy",
    "rrarefy_relative"),
  r.threshold = 0.7,
  p.threshold = 0.05,
  method = c("WGCNA", "SpiecEasi", "SPARCC", "cor", "Hmisc"),
  cor.method = c("pearson", "kendall", "spearman"),
  proc = c("holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none"),
  module.method = c("Fast_greedy", "Walktrap", "Edge_betweenness", "Spinglass"),
  SpiecEasi.method = c("mb", "glasso"),
  sparcc_R = 20,
  node_annotation = NULL,
  top_modules = 15,
  seed = 1115
)
}
\arguments{
\item{mat}{Numeric matrix.
A numeric matrix with samples in colums and variables in rows}

\item{transfrom.method}{Character.
Data transformation methods applied before correlation analysis.
Options include:
"none" (raw data),
"scale" (z-score standardization),
"center" (mean centering only),
"log2" (log2 transfrom),
"log10" (log10 transfrom),
"ln" (natural transfrom ),
"rrarefy" (random rarefaction using \code{vegan::rrarefy}),
"rrarefy_relative" (rarefy then convert to relative abundance).}

\item{r.threshold}{Numeric.
Correlation coefficient threshold; edges are kept only if |r| >= r.threshold.}

\item{p.threshold}{Numeric.
Significance threshold for correlations; edges are kept only if p < p.threshold.}

\item{method}{Character.
Relationship analysis methods.
Options include: "WGCNA", "SpiecEasi", "SPARCC", "cor", and "Hmisc".}

\item{cor.method}{Character.
Correlation analysis method.
Options include "pearson", "kendall", and "spearman".}

\item{proc}{Character.
Correlation p-value adjustment methods.
Options include:
"holm", "hochberg", "hommel", "bonferroni",
"BH", "BY", "fdr", and "none".}

\item{module.method}{Character.
Network community detection (module identification) method.
Options include "Fast_greedy", "Walktrap", "Edge_betweenness", and "Spinglass".}

\item{SpiecEasi.method}{Character.
Method used in \code{SpiecEasi} network inference; options include "mb" and "glasso".}

\item{sparcc_R}{Integer.
Number of bootstrap/permutation replicates for SparCC p-values (when \code{method = "SPARCC"}).
Default 20.}

\item{node_annotation}{Data frame.
Optional node annotation table, containing metadata such as taxonomy or functional categories.}

\item{top_modules}{Integer.
Number of top-ranked modules to retain for downstream visualization or analysis.}

\item{seed}{Integer (default = 1115).
Random seed for reproducibility.}
}
\value{
A graph object representing the correlation-based microbial network.
Node/edge attributes include correlation statistics and (optionally) module labels.
}
\description{
Build a correlation-based network from a matrix
}
\examples{
\donttest{
set.seed(1)
mat <- matrix(stats::rnorm(40 * 20), nrow = 40, ncol = 20)
rownames(mat) <- paste0("feature", seq_len(40))
colnames(mat) <- paste0("sample",  seq_len(20))
obj <- build_graph_from_mat(
  mat           = mat,
  method        = "cor",
  cor.method    = "pearson",
  proc          = "none",
  r.threshold   = 0.3,
  p.threshold   = 0.05,
  module.method = "Fast_greedy"
)
obj
}
}
