Function to find the distance between transmission trees by comparing their MRCI depth matrices; to be precise, by finding the Euclidean distance between the tree vectors, restricted to their sampled node entries.

wiwTreeDist(matList, sampled = NULL)

Arguments

matList

a list of matrices, each of which is the output of findMRCIs$mrciDepths

sampled

a vector of node IDs which corresponds to those nodes which are sampled cases. Default is to treat all nodes as sampled cases.

Value

Returns a distance matrix, where entry (i,j) is the transmission tree distance between matrices i and j in matList

Author

Michelle Kendall michelle.louise.kendall@gmail.com

Examples

# create some simple "who infected whom" scenarios:
tree1 <- cbind(Infector=1:5,Infectee=2:6) 
tree2 <- cbind(Infector=c(1,5,2,2,3),Infectee=2:6)
tree3 <- cbind(Infector=c(2,2,3,4,5),Infectee=c(1,3,4,5,6)) 
# create list of the MRCI depth matrices:
matList <- lapply(list(tree1,tree2,tree3), function(x) findMRCIs(x)$mrciDepths)

# transmission tree distance, assuming all cases are sampled:
wiwTreeDist(matList)
#>          1        2
#> 2 5.916080         
#> 3 5.099020 5.567764
# transmission tree distance when cases 1, 2 and 4 are sampled:
wiwTreeDist(matList, sampled=c(1,2,4))
#>          1        2
#> 2 1.000000         
#> 3 2.236068 2.000000