Package {TestNet}


Type: Package
Title: A Method for Inferring Microbial Networks with FDR Control
Version: 1.0
Date: 2026-05-28
Description: A testing method for inferring microbial networks. It differs from existing microbial network analyses in that it provides calibrated results by controlling the false discovery rate. The method accounts for the complex features of taxa count data. It also accommodates both independent and clustered samples, offers separate linear and nonlinear tests for each pair of taxa, and includes an omnibus test that bypasses the need to specify the type of relationship for each pair of taxa.
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
RoxygenNote: 7.3.2
Depends: R (≥ 3.5.0)
Imports: permute, matrixStats, dcov, stats, utils
Suggests: R.rsp, testthat
URL: https://github.com/yijuanhu/TestNet
BugReports: https://github.com/yijuanhu/TestNet/issues
Encoding: UTF-8
LazyData: true
NeedsCompilation: no
Packaged: 2026-05-29 12:29:27 UTC; yhu30
Author: Yi-Juan Hu [aut, cre]
Maintainer: Yi-Juan Hu <yijuanhu@bicmr.pku.edu.cn>
Repository: CRAN
Date/Publication: 2026-06-02 09:40:02 UTC

A testing method for inferring microbial networks

Description

This function generates a p-value and a q-value for each (linear, nonlinear, or omnibus) test of a pair of taxa.

Usage

TestNet(
  otu.tab,
  clustered.data = FALSE,
  cluster.id = NULL,
  fdr.nominal = 0.1,
  n.perm.max = NULL,
  seed = NULL,
  verbose = TRUE
)

Arguments

otu.tab

An n.sam by n.otu matrix of read counts.

clustered.data

A logical variable indicating whether the samples are clustered. The default is FALSE.

cluster.id

An array of n.sam cluster identifiers, used in the permutation procedure to shuffle the samples as a whole across clusters and simultaneously shuffle the samples within clusters when clustered.data=TRUE. The default is NULL.

fdr.nominal

The nominal FDR level. The default is 0.1.

n.perm.max

The maximum number of permutation replicates. The default is NULL, in which case a maximum of n.otu * n.rej.stop * (1/fdr.nominal) are used, where n.rej.stop is set to 20.

seed

A single-value integer seed for the random process of drawing permutation replicates. The default is NULL.

verbose

A logical variable indicating whether to write information messages to the console. The default is TRUE.

Value

a list consisting of

p.linear

An n.otu by n.otu matrix of p-values for the linear tests

q.linear

An n.otu by n.otu matrix of q-values for the linear tests

p.nonlinear

An n.otu by n.otu matrix of p-values for the nonlinear tests

q.nonlinear

An n.otu by n.otu matrix of q-values for the nonlinear tests

p.omni

An n.otu by n.otu matrix of p-values for the omnibus tests

q.omni

An n.otu by n.otu matrix of q-values for the omnibus tests

which.pmin

An n.otu by n.otu matrix of 0, 1, and 2 values, where 0 and 1 indicate that the nonlinear and linear tests, respectively, achieved the minimum p-value between the two, and 2 indicates that both tests yielded similar p-values.

seed

the seed used to generate the permutation replicates

Author(s)

Yi-Juan Hu <yijuanhu@bicmr.pku.edu.cn>

References

Su C, Mao Y, He M, Van Doren VE, Kelley CF, Hu YJ (2026). TestNet: a method for inferring microbial networks with false discovery rate control for clustered and unclustered samples. Genome Biology, in press.

Examples

data(sim.otu.tab)
TestNet.res <- TestNet(otu.tab = sim.otu.tab, n.perm.max = 100) # recommend to use n.perm.max = NULL

OTU count table of the simulated microbiome samples

Description

This table contains read count data simulated for 100 samples and 46 OTUs and under the AR1 dependence structure

Usage

data("sim.otu.tab")

Format

A data frame with 100 observations on 46 OTUs

Examples

data(sim.otu.tab)