Type: Package
Title: Phylogeny-Guided Bayesian Microbial Network Inference
Version: 0.1.2
Description: Implements a phylogeny-aware Bayesian graphical modeling framework for microbial network inference using a shrinkage precision estimator guided by a phylogenetic kernel, with optional hyperparameter-ensemble edge reliability analysis.
License: GPL-3
Encoding: UTF-8
RoxygenNote: 7.3.3
Imports: stats, ape, GUniFrac, compositions
Suggests: testthat (≥ 3.0.0), knitr, rmarkdown
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2026-02-20 07:54:36 UTC; rosa
Author: Rosa Aghdam [aut, cre]
Maintainer: Rosa Aghdam <rosaaghdam@gmail.com>
Repository: CRAN
Date/Publication: 2026-02-25 10:10:07 UTC

Build a phylogenetic kernel from a distance matrix

Description

Build a phylogenetic kernel from a distance matrix

Usage

kernel_from_dist(dist, alpha, kernel = c("gaussian", "laplacian"))

Arguments

dist

A taxa x taxa distance matrix.

alpha

Positive bandwidth parameter.

kernel

Either "gaussian" or "laplacian".

Value

A taxa x taxa kernel matrix.


Fit a single PhyMapNet model

Description

Fit a single PhyMapNet model

Usage

phymapnet_fit(
  otu,
  tree,
  alpha = 0.05,
  k = 5,
  epsilon1 = 0,
  epsilon2 = 0,
  kernel = c("gaussian", "laplacian"),
  th_sparsity = 0.95,
  normalization = c("log", "gmpr", "clr", "tss"),
  prune_tree = TRUE
)

Arguments

otu

samples x taxa matrix.

tree

phylo tree with tips matching taxa.

alpha

kernel bandwidth (>0).

k

neighborhood scaling (integer >= 1). Uses K_neighbors = k * p internally.

epsilon1

diagonal jitter for omega_hat.

epsilon2

jitter for IB.

kernel

"gaussian" or "laplacian".

th_sparsity

quantile level for sparsification (e.g., 0.95).

normalization

"log","gmpr","clr","tss".

prune_tree

prune tree tips not in OTU.

Value

A list with precision_map, adjacency, threshold, taxa, dist, kernel_mat.


Internal PhyMapNet precision MAP estimator

Description

Internal PhyMapNet precision MAP estimator

Usage

phymapnet_precision(Y, nue, epsilon1, epsilon2, C)

Prepare inputs for PhyMapNet

Description

Computes the patristic distance matrix from a phylogenetic tree and aligns taxa between the OTU table and the tree.

Usage

phymapnet_prepare_inputs(otu, tree, prune = TRUE)

Arguments

otu

A samples x taxa count/abundance matrix (rownames=samples, colnames=taxa).

tree

A phylo object with tip labels as taxa names.

prune

Logical; if TRUE, prunes tree tips not found in OTU.

Value

A list with otu (aligned), dist (aligned), taxa.


Edge reliability via hyperparameter ensemble

Description

Runs an ensemble over (alpha, k, epsilon1, epsilon2, kernel, normalization) and returns edge reliability as selection frequency under fixed sparsification threshold.

Usage

phymapnet_reliability(
  otu,
  tree,
  th_fixed = 0.95,
  alpha_range = seq(0.01, 0.12, by = 0.01),
  k_range = 2:10,
  epsilon1_range = seq(0, 1, by = 0.1),
  epsilon2_range = seq(0, 1, by = 0.1),
  kernels = c("gaussian"),
  normalizations = c("log", "gmpr", "clr", "tss"),
  consensus_cut = 0.5,
  prune_tree = TRUE,
  progress = TRUE,
  progress_every = 500
)

Arguments

otu

samples x taxa matrix.

tree

phylo tree.

th_fixed

fixed quantile threshold for sparsification across all models (e.g., 0.95).

alpha_range

numeric vector.

k_range

integer vector.

epsilon1_range

numeric vector.

epsilon2_range

numeric vector.

kernels

character vector: "gaussian" and/or "laplacian".

normalizations

character vector: subset of c("log","gmpr","clr","tss").

consensus_cut

reliability cutoff for binary consensus (default 0.5).

prune_tree

prune tree tips not in OTU.

progress

print progress every progress_every models.

progress_every

integer.

Value

A list with rel_mat, consensus_mat, edge_list, N_models, grid.


Quantile sparsification

Description

Quantile sparsification

Usage

sparse_quantile(Isigma_star, quantile_level)