% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fancy.R
\name{fancy}
\alias{fancy}
\title{Run the full Fancy hybrid network inference pipeline}
\usage{
fancy(
  data,
  n_bootstrap = 100L,
  k = 5L,
  find_k = FALSE,
  k_values = c(2L, 3L, 4L, 5L, 6L, 7L, 8L, 10L, 15L, 18L, 20L),
  cpus = 4L,
  use_mrnet = TRUE,
  w1 = 0.3,
  w2 = 0.7,
  score_type = "multiplicative",
  dcor_rescue_percentile = NULL,
  threshold_method = "quantile",
  threshold_value = 0.7,
  save_path = NULL,
  verbose = TRUE
)
}
\arguments{
\item{data}{Numeric matrix or data.frame of CLR-transformed abundances with
\strong{samples as rows and MAGs as columns}. Pass \code{t(clr_normalize(counts))}
or use the Samples x MAGs orientation directly.}

\item{n_bootstrap}{Integer; number of bootstrap iterations (default 100).}

\item{k}{Integer; kNN parameter for MI estimation (default 5).}

\item{find_k}{Logical; if \code{TRUE}, run \code{\link[=find_optimal_k]{find_optimal_k()}} to choose k
automatically via the elbow method (default \code{FALSE}).}

\item{k_values}{Integer vector of k values to evaluate when
\code{find_k = TRUE}.}

\item{cpus}{Integer; number of parallel workers (default 4).}

\item{use_mrnet}{Logical; if \code{TRUE} (default), apply MRNET to the MI
matrix for sparse edge selection.}

\item{w1}{Numeric weight for edge frequency in the hybrid score
(default 0.3).}

\item{w2}{Numeric weight for dCor stability in the hybrid score
(default 0.7).}

\item{score_type}{Character; \code{"multiplicative"} (default) or
\code{"additive"}. See \code{\link[=hybrid_score]{hybrid_score()}} for details.}

\item{dcor_rescue_percentile}{Numeric between 0 and 1, or \code{NULL}
(default). When set, edges with dCor stability above this
percentile receive a minimum EdgeFrequency floor in
multiplicative mode. See \code{\link[=hybrid_score]{hybrid_score()}}.}

\item{threshold_method}{Character; one of \code{"quantile"}, \code{"score"}, or
\code{"top_n"} (default \code{"quantile"}).}

\item{threshold_value}{Numeric; meaning depends on \code{threshold_method}
(default 0.7, i.e. top 30 percent of edges for quantile method).}

\item{save_path}{Optional directory path for saving bootstrap results.}

\item{verbose}{Logical; if \code{TRUE} (default), emit progress messages.}
}
\value{
A list with class \code{"fancy"} containing:
\describe{
\item{\code{edges}}{The final thresholded edge data.frame.}
\item{\code{all_edges}}{All scored edges before thresholding (for
re-thresholding).}
\item{\code{all_edges_unfiltered}}{All 4950 scored pairs before the
hard frequency/stability filter. Useful for inspecting edges
that were dropped by the pre-filter.}
\item{\code{k}}{The k value used.}
\item{\code{n_bootstrap}}{Number of bootstrap iterations run.}
\item{\code{params}}{List of all parameters for reproducibility.}
}
}
\description{
Convenience wrapper that chains preprocessing, bootstrap network inference,
edge scoring, and thresholding into a single call. Uses MI (via MRNET) and
distance correlation with bootstrap resampling to produce a ranked,
thresholded edge list.
}
\examples{
\donttest{
data(fancy_tiny_clr)
result <- fancy(t(fancy_tiny_clr), n_bootstrap = 2, cpus = 1)
head(result$edges)
plot(result)
}
}
