CSV#
CSV (comma-separated values) is a simple tabular format for distance matrices, easy to read and edit in spreadsheet applications. PhyloZoo supports a header row with taxon labels and optional custom delimiters (e.g. tab for TSV).
See also
Comma-separated values — Wikipedia
Classes and extensions#
Classes: DistanceMatrix
File extensions: .csv (and optionally .tsv with delimiter="\t")
Structure#
The first row is a header: an empty first cell followed by taxon labels. Each following row has a taxon label in the first column and then the distances:
,A,B,C
A,0.0,1.0,2.0
B,1.0,0.0,1.0
C,2.0,1.0,0.0
Examples#
from phylozoo import DistanceMatrix
import numpy as np
matrix = np.array([[0, 1, 2], [1, 0, 1], [2, 1, 0]])
dm = DistanceMatrix(matrix, labels=['A', 'B', 'C'])
dm.save("distances.csv", format="csv")
dm2 = DistanceMatrix.load("distances.csv", format="csv")
dm.save("distances.tsv", format="csv", delimiter="\t")
See also#
I/O Operations — Save/load and format detection
NEXUS — NEXUS distance format
PHYLIP — PHYLIP distance format
Pairwise Distances — Distance matrices