transroutes: Assessment of transmission routes using theoretical SNP...

Description Usage Arguments Details Value See Also Examples

View source: R/transroutes.r

Description

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

Usage

1
2
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?

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.

Value

Returns calculated values:

maxpostsource

Vector of maximum posterior probability transmission sources corresponding to ID.

likelihood

A 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.

posterior

A matrix of posterior transmission probabilities. The [i,j]th entry provides the posterior probability that the i-th individual infected the j-th individual.

closestsource

A list of the individuals carrying the most genetically similar genotype. Each entry corresponds to ID.

reject

Matrix 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.

See Also

expsnps

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
  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

seedy documentation built on May 29, 2017, 10:58 a.m.