Computing Manhattan distances between genomes
Computes the (weighted) Manhattan distances beween all pairs of genomes.
An optional scale to control how copy numbers should affect the distances.
Vector of optional weights of gene clusters.
The Manhattan distance is defined as the sum of absolute elementwise differences between two vectors. Each genome is represented as a vector (row) of integers in pan.matrix. The Manhattan distance between two genomes is the sum of absolute difference between these rows. If two rows (genomes) of the pan.matrix are identical, the corresponding Manhattan distance is 0.0.
The scale can be used to control how copy number differences play a role in the distances computed. Usually we assume that going from 0 to 1 copy of a gene is the big change of the genome, and going from 1 to 2 (or more) copies is less. Prior to computing the Manhattan distance, the pan.matrix is transformed according to the following affine mapping: If the original value in pan.matrix is x, and x is not 0, then the transformed value is 1 + (x-1)*scale. Note that with scale=0.0 (default) this will result in 1 regardless of how large x was. In this case the Manhattan distance only distinguish between presence and absence of gene clusters. If scale=1.0 the value x is left untransformed. In this case the difference between 1 copy and 2 copies is just as big as between 1 copy and 0 copies. For any scale between 0.0 and 1.0 the transformed value is shrunk towards 1, but a certain effect of larger copy numbers is still present. In this way you can decide if the distances between genomes should be affected, and to what degree, by differences in copy numbers beyond 1. Notice that as long as scale=0.0 (and no weighting) the Manhattan distance has a nice interpretation, namely the number of gene clusters that differ in present/absent status between two genomes.
When summing the difference across gene clusters we can also up- or downweight some clusters compared to others. The vector weights must contain one value for each column in pan.matrix. The default is to use flat weights, i.e. all clusters count equal. See
geneWeights for alternative weighting strategies.
dist object (see
dist) containing all pairwise Manhattan distances between genomes.
Lars Snipen and Kristian Hovde Liland.
1 2 3 4 5 6 7 8
# Loading two Panmat objects in the micropan package data(list=c("Mpneumoniae.blast.panmat","Mpneumoniae.domain.panmat"),package="micropan") # Manhattan distances based on a BLAST clustering Panmat object Mdist.blast <- distManhattan(Mpneumoniae.blast.panmat) # Manhattan distances based on domain sequence clustering Panmat object Mdist.domains <- distManhattan(Mpneumoniae.domain.panmat,scale=0.5)