dnadiff_dist_matrix.py¶
Usage¶
The usage and help documentation of dnadiff_dist_matrix.py
can be seen by
running pyhton dnadiff_dist_matrix -h
:
usage: - [-h] [--min_coverage MIN_COVERAGE] [--fasta_names FASTA_NAMES]
[--plot_image_extension PLOT_IMAGE_EXTENSION] [--skip_dnadiff]
[--skip_matrix] [--skip_plot]
output_folder fasta_files [fasta_files ...]
Output distance matrix between fasta files using dnadiff from MUMmer. Generates
dnadiff output files in folders:
output_folder/fastaname1_vs_fastaname2/
output_folder/fastaname1_vs_fastaname3/
etc
where fastaname for each fasta file can be supplied as an option to the script.
Otherwise they are just counted from 0 to len(fastafiles)
The distance between each bin is computed using the 1-to-1 alignments of the
report files (not M-to-M):
1 - AvgIdentity if min(AlignedBases) >= min_coverage. Otherwise distance is 1.
Or 0 to itself.
Resulting matrix is printed to stdout and to output_folder/dist_matrix.tsv. The
rows and columns of the matrix follow the order of the supplied fasta files. The
names given to each fasta file are also outputted to the file
output_folder/fasta_names.tsv
A hierarchical clustering of the distance using euclidean average linkage
clustering is plotted. This can be deactivated by using --skip_plot. The
resulting heatmap is in output_folder/hclust_heatmap.pdf or
output_folder/hclust_dendrogram.pdf. The image extension can be changed.
positional arguments:
output_folder Output folder
fasta_files fasta files to compare pairwise using MUMmer's dnadiff
optional arguments:
-h, --help show this help message and exit
--min_coverage MIN_COVERAGE
Minimum coverage of bin in percentage to calculate
distance otherwise distance is 1. Default is 50.
--fasta_names FASTA_NAMES
File with names for fasta file, one line each. Could
be sample names, bin names, genome names, whatever you
want. The names are used when storing the MUMmer
dnadiff results as in
output_folder/fastaname1_vs_fastaname2/. The names are
also used for the plots.
--plot_image_extension PLOT_IMAGE_EXTENSION
Type of image to plotted e.g. pdf, png, svg.
--skip_dnadiff Skips running MUMmer and uses output_folder as given
input to calculate the distance matrix. Expects
dnadiff output as
output_folder/fastaname1_vs_fastaname2/out.report
--skip_matrix Skips Calculating the distance matrix.
--skip_plot Skips plotting the distance matrix. By default the
distance matrix is clustered hierarchically using
euclidean average linkage clustering. This step
requires seaborn and scipy.
Example¶
An example of how to run dnadiff_dist_matrix
on the test data:
cd CONCOCT/scripts
python dnadiff_dist_matrix.py test_dnadiff_out tests/test_data/bins/sample*.fa
This results in the following output files in the folder test_dnadiff_out/
:
dist_matrix.stv
The distance matrixfasta_names.tsv
The names given to each bin (or fasta file)hcust_dendrogram.pdf
Dendrogram of the clustering (click for example)hcust_heatmap.pdf
Heatmap of the clustering (click for example)
Then there is also for each pairwise dnadiff
alignment the following output
files in a subfolder fastaname1_vs_fastaname2/
:
out.1coords
out.1delta
out.cmd
out.delta
out.mcoords
out.mdelta
out.qdiff
out.rdiff
out.report
out.snps
out.unqry
out.unref
See MUMmer’s own manual for an explanation of each file with dnadiff --help
.