Learn R Programming

seedy (version 1.3)

transroutes: Assessment of transmission routes using theoretical SNP distribution

Description

Calculates likelihood and posterior probability of each potential transmission route using a geometric-Poisson approximation of SNP distance.

Usage

transroutes(ID, GD, sample.times, inf.times, rec.times=NULL, mut.rate, eq.size, 
            bottle.size=1, p.level=0.95, geninterval=NULL, summary=TRUE)

Arguments

ID
Vector of individual IDs.
GD
Matrix of genetic distances, with the [i,j]-th entry corresponding to the genetic distance between samples from the ith and jth entry of ID.
sample.times
Vector of genome sampling times (same length as ID).
inf.times
Vector of infection times (same length as ID).
rec.times
Vector of recovery times (same length as ID if specified).
mut.rate
Mutation rate.
eq.size
Equilibrium within-host effective population size.
bottle.size
Size of population bottleneck.
p.level
Probability level at which to reject potential transmission routes.
geninterval
Generation interval (if bottle.size>1).
summary
Should a summary for each ID be printed to screen?

Value

  • Returns calculated values:
  • maxpostsourceVector of maximum posterior probability transmission sources corresponding to ID.
  • likelihoodA matrix of likelihood values from the geometric-Poisson distribution. The [i,j]th entry provides the likelihood that the i-th individual infected the j-th individual.
  • posteriorA matrix of posterior transmission probabilities. The [i,j]th entry provides the posterior probability that the i-th individual infected the j-th individual.
  • closestsourceA list of the individuals carrying the most genetically similar genotype. Each entry corresponds to ID.
  • rejectMatrix indicating whether a transmission route would be rejected at the specified probability level. The [i,j]th entry is equal to 1 if the route from i to j is rejected at this level.

Details

Calculates the likelihood and posterior probability (given a flat prior) for each potential transmission route, as well as indicating which transmission routes would be rejected at a given probability level. If recovery times are not specified, each individual is assumed to be infectious for the duration of the outbreak.

See Also

expsnps

Examples

Run this code
data(transmission)
  W <- transmission
  ID <- unique(W$sampledata[,1])
  GD <- gd(W$sampledata[,3], W$libr, W$nuc, W$librstrains)
  
  sample.times <- W$sampledata[,2]
  inf.times <- numeric(length(ID))
  rec.times <- numeric(length(ID))
  truesource <- numeric(length(ID))
  for (i in 1:length(ID)) {
    inf.times[i] <- W$epidata[which(W$epidata[,1]==ID[i]),2]
    rec.times[i] <- W$epidata[which(W$epidata[,1]==ID[i]),3]
    truesource[i] <- W$epidata[which(W$epidata[,1]==ID[i]),4]
  }
  
  K <- transroutes(ID=ID, GD=GD, sample.times=sample.times, inf.times=inf.times, 
                   rec.times=rec.times, mut.rate=0.01, eq.size=5000, 
                   bottle.size=1, p.level=0.95, summary=TRUE)
  truesource
  K$maxpostsource

Run the code above in your browser using DataLab