Function to find the most recent common infector (MRCI) matrix from "who infected whom" information.

findMRCIs(wiw)

Arguments

wiw

a two-column matrix where the first column gives the infectors and the second column gives the infectees; each row corresponds to a transmission event from an infector to an infectee.

Value

Returns three objects:

  • sourceCase: the number of the node which is the source case, i.e. the common infector of all cases (outputs a warning if there is more than one source case).

  • mrcis: a matrix where, for each pair of individuals i and j, the entry (i,j) is the node number of their MRCI. Note that if i infected j then this entry is i itself.

  • mrciDepths: a matrix where, for each pair of individuals i and j, the entry (i,j) is the depth of their MRCI, defined as the number of edges from the source case. The source case has depth zero, its direct infectees have depth 1, and so on.

Author

Michelle Kendall michelle.louise.kendall@gmail.com

Examples


## a simple who infected whom matrix:
tree1 <- cbind(Infector=1:5,Infectee=2:6) 
findMRCIs(tree1)
#> $sourceCase
#> [1] 1
#> 
#> $mrcis
#>   1 2 3 4 5 6
#> 1 1 1 1 1 1 1
#> 2 1 2 2 2 2 2
#> 3 1 2 3 3 3 3
#> 4 1 2 3 4 4 4
#> 5 1 2 3 4 5 5
#> 6 1 2 3 4 5 6
#> 
#> $mrciDepths
#>   1 2 3 4 5 6
#> 1 0 0 0 0 0 0
#> 2 0 1 1 1 1 1
#> 3 0 1 2 2 2 2
#> 4 0 1 2 3 3 3
#> 5 0 1 2 3 4 4
#> 6 0 1 2 3 4 5
#>