News and Announcements » – Fits a model between two distance matrices and plots the result


Fits a spatial autocorrelation model between two matrices and plots the result. This script will work with two distance matrices but will ignore the 0s at the diagonal and the values that go to N/A. See

Usage: [options]

Input Arguments:



-x, --input_path_x
Path to distance matrix to be displayed in the x axis
-y, --input_path_y
Path to distance matrix to be displayed in the y axis
-o, --output_path
Output path. directory for batch processing, filename for single file operation


-b, --binning
Binning ranges. Format: [increment,top_limit], when top_limit is -1=infinitum; you can specify several ranges using the same format, i.e. [2.5,10][50,-1] will set two bins, one from 0-10 using 2.5 size steps and from 10-inf using 50 size steps. Note that the binning is used to clean the plots (reduce number of points) but ignored to fit the model. [default: None]
This will overpass the error raised when the matrices have different sizes/samples
X axis max limit [default: auto]
X axis min limit [default: auto]
Y axis max limit [default: auto]
Y axis min limit [default: auto]
-X, --x_label
Label for the x axis [default: Distance Dissimilarity (m)]
-Y, --y_label
Label for the y axis [default: Community Dissimilarity]
-t, --fig_title
Title of the plot [default: Semivariogram]
Dot color for plot, more info: [default: white]
Dot color for plot, more info: [default: o]
Line color for plot, more info: [default: blue]
Alpha for dots, more info: [default: 1]
Alpha for dots, more info: [default: 1]
Model to be fitted to the data. Valid choices are:nugget, exponential, gaussian, periodic, linear. [default: exponential]
-p, --print_model
Print in the title of the plot the function of the fit. [default: False]
-c, --category
Category to color each of the trajectories when you have multiple treatments [default: None]
-m, --mapping_fp
Metadata mapping file, only used when coloring by a category, a file with the legends and color coding will be created with the suffix legend [default: None]


The resulting output file consists of a pdf image containing the plot between the two distances matrices and the fitted model


For this script, the user supplies two distance matrices (i.e. resulting file from, along with the output filename (e.g. semivariogram), and the model to fit, as follows: -x distance.txt -y unifrac.txt -o semivariogram_exponential.png

Modify the the default method to gaussian -x distance.txt -y unifrac.txt --model gaussian -o semivariogram_gaussian.png

Color semivariograms by a category in the metadata mapping file:

Using a header name in the mapping file (Time), create two separate semivariograms in the same plot, an accompanying file with the color coding will be created(categories_legend.eps), both the legends and the plot will be in eps format. -y unweighted_unifrac_dm.txt -x time_dm.txt --model gaussian -m Fasting_Map.txt -o categories.eps -c Treatment