  We introduce a method---called Fisher exact scanning (FES)---for testing and
identifying variable dependency that generalizes Fisher's exact test on
$2\times 2$ contingency tables to $R\times C$ contingency tables and continuous
sample spaces. FES proceeds through scanning over the sample space using
windows in the form of $2\times 2$ tables of various sizes, and on each window
completing a Fisher's exact test. Based on a factorization of Fisher's
multivariate hypergeometric (MHG) likelihood into the product of the univariate
hypergeometric likelihoods, we show that there exists a coarse-to-fine,
sequential generative representation for the MHG model in the form of a
Bayesian network, which in turn implies the mutual independence (up to
deviation due to discreteness) among the Fisher's exact tests completed under
FES. This allows an exact characterization of the joint null distribution of
the $p$-values and gives rise to an effective inference recipe through simple
multiple testing procedures such as \v{S}id\'{a}k and Bonferroni corrections,
eliminating the need for resampling. In addition, FES can characterize
dependency through reporting significant windows after multiple testing
control. The computational complexity of FES is approximately linear in the
sample size, which along with the avoidance of resampling makes it ideal for
analyzing massive data sets. We use extensive numerical studies to illustrate
the work of FES and compare it to several state-of-the-art methods for testing
dependency in both statistical and computational performance. Finally, we apply
FES to analyzing a microbiome data set and further investigate its relationship
with other popular dependency metrics in that context.
