StatFas.com

Home › Blogs › Mantel network analysis

Mantel Network Analysis Explained: When to Use It and How to Run It

By StatFas · Published 3 November 2026

Many datasets arrive as a table of measurements, and the first question is rarely "which test?" but "what is connected to what?" Mantel network analysis answers that by combining three things: a correlation heatmap that shows how measured variables relate, Mantel tests that compare the dissimilarity patterns between samples, and a network figure that draws the strongest links. This guide explains the idea, when it fits, how to explain the result, and how to run it in StatFas, R, Python and SPSS.

Mantel Network Analysis: draw your figure free, click here
No account needed to run the analysis

What is Mantel network analysis?

Correlation-based network analysis starts from pairwise associations and draws variables as nodes and associations as edges. In the Mantel Network Analysis Calculator on StatFas, a matrix of correlations (Pearson or Spearman) appears as an upper-triangle heatmap. Variables chosen as network variables sit on the left and are linked to each matrix variable by an edge.

Each edge is a Mantel test. For every variable, a Euclidean distance matrix between samples is built. The Mantel statistic is the Pearson correlation between the upper triangles of two distance matrices, and significance comes from permuting sample labels. Line width shows the size of |Mantel r| and line colour shows the permutation p-value. In other words, distance matrix correlation is presented as an edge-weighted graph, a small matrix-to-network pipeline that runs in the browser.

When to use it

Know the limits. The Mantel Network Analysis Calculator runs a simple Mantel test for each pair of variables. It does not run a multivariate Mantel test across a group of variables, a partial Mantel test, weighted correlation network analysis (WGCNA) modules, or spatial-autocorrelation corrections. Critiques of the Mantel test in spatial analysis (Legendre, Fortin and Borcard, 2015) are worth reading if your samples are spatially structured.

How to explain the result

Describe the heatmap first: square colour and size show the correlation coefficient, and stars mark p < .05, .01 and .001. Then describe the network: thicker lines mean larger |Mantel r| (below 0.25, 0.25 to 0.5, 0.5 and above), orange lines mean p < .01, purple lines mean .01 to .05, and dashed grey lines are not significant.

A plain-language reading of a significant link is: "samples that differ more in soil pH also tend to differ more in microbial biomass." That is an association between dissimilarity patterns, not evidence of cause. Remember that permutation p-values depend on the number of permutations (with 499, the smallest possible p is 1/500 = .002) and that many links mean many tests, so interpret borderline results cautiously.

How to run it in StatFas

  1. Open the Mantel Network Analysis Calculator.
  2. Paste or upload CSV or Excel data with a header row and one observation per row (at least 5 observations).
  3. Choose the matrix variables and the network variables. A variable can belong to either group.
  4. Pick Pearson or Spearman for the matrix, the permutation count (499 for exploring, 999 or more for reporting), the network significance threshold, the minimum |r| and how to handle missing data.
  5. Run the analysis, drag network nodes to tidy the figure, then download the A4 figure, the network edge list (CSV) or a Word file with APA 7 interpretation. Downloads need a free account; running the analysis does not.

How to do it in R

library(vegan)
d    <- read.csv("soil.csv")
mat  <- c("Soil_pH", "Sand", "Clay")
net  <- c("Microbial_biomass", "Enzyme_activity")

edges <- do.call(rbind, lapply(mat, function(v)
  do.call(rbind, lapply(net, function(n) {
    m <- mantel(dist(d[[v]]), dist(d[[n]]), method = "pearson", permutations = 999)
    data.frame(matrix_var = v, network_var = n, r = m$statistic, p = m$signif)
  })))

library(corrplot)
corrplot(cor(d[mat]), type = "upper")   # heatmap of the matrix correlations
library(igraph)                          # draw edges with graph_from_data_frame(edges)

How to do it in Python

import pandas as pd
from scipy.spatial.distance import pdist, squareform
from skbio import DistanceMatrix
from skbio.stats.distance import mantel

df = pd.read_csv("soil.csv")
dm = lambda s: DistanceMatrix(squareform(pdist(s.to_numpy().reshape(-1, 1))))
r, p, n = mantel(dm(df["Soil_pH"]), dm(df["Microbial_biomass"]),
                 method="pearson", permutations=999)

# heatmap: seaborn.heatmap(df.corr()); network: networkx.from_pandas_edgelist(edges, ...)

How to do it in SPSS

SPSS has no built-in Mantel test. Use Analyze, Correlate, Bivariate for the correlation matrix, and Analyze, Correlate, Distances to create distance matrices. Permutation p-values need an R or Python extension or a custom macro, so most SPSS users run the Mantel step in StatFas or R and bring the results back into their write-up.

Reporting example

Using illustrative numbers: "Mantel tests with 999 permutations showed that dissimilarity in soil pH was related to dissimilarity in microbial biomass, Mantel r = .52, p = .003." Report the correlation method, the number of permutations, the sample size for each link and the threshold used to draw the network.

Common mistakes to avoid

The most frequent error is reading a thick line as proof that one variable drives another. A Mantel link only says that pairwise differences between samples line up. A second error is using too few observations: with a handful of samples there are very few distinct permutations, so p-values are coarse. A third is ignoring missing data. Pairwise deletion can give each matrix correlation a different sample size, so state which option you chose and report n for each link.

Finally, avoid filtering the network until only significant lines remain without saying so. Keep the dashed grey lines visible while exploring, set the minimum |r| and significance threshold deliberately, and describe both in the methods. Treat the figure as a map for the next analysis, such as a regression, an ordination or a formal model, rather than as the final result.

Related methods

Partial Mantel networks, differential correlation networks, multiplex networks and WGCNA extend the same idea and are usually run in R packages such as vegan, WGCNA, qgraph and igraph. The network edge list from StatFas can be converted to an adjacency matrix in R or Python for graph-theoretic comparison. For direct network metrics, see the Network Analysis tool. For the building blocks, read our guides on Pearson correlation, Spearman rank correlation, partial correlation and canonical correlation analysis.

Mantel Network Analysis: draw your figure free, click here

Try it now: open the Mantel Network Analysis Calculator, load the example data and see a correlation heatmap and Mantel network in one figure. Related: Heatmap, Correlation, Partial Correlation and Network Analysis.