Learn R Programming

OutbreakTools (version 0.1-13)

obkData-class: Formal class "obkData"

Description

The class obkData is a formal (S4) class for storing data collected during outbreaks. This includes:
  • individual data (age, sex, onset of symptoms, ...)
  • time-stamped samples and records (swabs, serology, accession numbers, ...)
  • genetic sequences
  • contact information
  • contextual information
  • phylogenetic trees

Usage

## S3 method for class 'obkData':
initialize(.Object, individuals=NULL, records=NULL,
          dna=NULL, trees=NULL, contacts=NULL, context=NULL,
          contacts.start=NULL, contacts.end=NULL,
          contacts.duration=NULL, contacts.directed=FALSE,
          date.format=NULL, dna.individualID=NULL, dna.date=NULL,
          dna.date.format=date.format, dna.sep="_", quiet=FALSE,
          check=TRUE, individuals=NULL, records=NULL, \dots)

get.nrecords(x, ...) get.records(x, ...) ## S3 method for class 'obkData': get.records(x, \dots) ## S3 method for class 'obkData': get.nrecords(x, \dots)

get.ncontext(x, ...) get.context(x, ...) ## S3 method for class 'obkData': get.context(x, \dots) ## S3 method for class 'obkData': get.ncontext(x, \dots)

get.ntrees(x, ...) get.trees(x, ...) ## S3 method for class 'obkData': get.ntrees(x, \dots) ## S3 method for class 'obkData': get.trees(x, \dots)

## S3 method for class 'obkData': get.dna(x, locus=NULL, id=NULL, \dots)

## S3 method for class 'obkData': get.ncontacts(x, from=NULL, to=NULL, \dots) ## S3 method for class 'obkData': get.contacts(x, from=NULL, to=NULL, \dots)

Arguments

.Object
the prototype of an obkData object, created automatically by new.
individuals
a data.frame with a mandatory column named 'individualID', providing unique identifiers for the individuals; if missing, row names are used as identifiers.
records
a list of data.frames, each of which has 2 mandatory fields, 'individualID' and 'date'. Dates can be specified as Date or characters, in which case they will be converted to dates. Most sensible formats will be detect
dna
a list matrices of DNA sequences in DNAbin or character format, each component of the list being a different gene. A matrix can be provided if there is a single gene.
dna.date
a vector of collection dates for the DNA sequences; see obkSequences manpage for more information.
dna.individualID
a vector of individual from which DNA sequences where obtained; see obkSequences manpage for more information.
dna.date.format
a character string indicating the format of the date in dna.date if ambiguous; see obkSequences manpage for more information.
dna.sep
the character string used to separate fields (e.g. sequenceID/individualID/date) in sequences labels; see obkSequences manpage for more information.
contacts
a matrix of characters indicating contacts using two columns; if contacts are directed, the first column is 'from', the second is 'to'; values should match individual IDs (as returned by get.individuals(x)); if numeric values are provided, the
context
a list of data.frames, each of which has 1 mandatory field: 'date'. Each item of the list should be named according to the type of information recorded, e.g. 'intervention', 'vaccination', 'climat' (temperature, humidity, etc.), or schools
contacts.start
a vector of dates indicating the beginning of each contact.
contacts.end
a vector of dates indicating the end of each contact.
contacts.duration
another way to specify contacts.end, as duration of contact in days.
contacts.directed
a logical indicating if contacts are directed; defaults to FALSE.
trees
a list of phylogenetic trees with the class multiPhylo (from the ape package)
date.format
a character string indicating the date format (see as.Date); if NULL, date format is detected automatically, which is usually a sensible option.
x
an obkData object.
locus
an indication of the locus, either by its name, or using integers or logicals matching get.locus.
id
an indication of the sequences, either by their names, or using integers or logicals matching get.sequences.
from,to
dates indicating the time span to consider for active contacts (for dynamic networks only).
...
arguments passed to other methods.
quiet
a logical indicating whether informative messages should be displayed to the screen.
check
a logical indicating whether supplementary consistency checks should be performed.

Objects from the class obkData

obkData objects can be created using new("obkData", ...), where '...' corresponds to the arguments of the corresponding initialize method (see 'Usage' section in this page).

See Also

Examples

Run this code
## LOAD DATA ##
data(ToyOutbreakRaw)
attach(ToyOutbreakRaw)

## CONSTRUCTING AN OBKDATA OBJECT ##
x <- new ("obkData", individuals=individuals, records=records,
          contacts=contacts, contacts.start=contacts.start,
          contacts.end=contacts.end, dna=dna,
          dna.individualID=dna.info$individualID,
          dna.date=dna.info$date, sample=dna.info$sample, trees=trees)

detach(ToyOutbreakRaw)


## EXAMINING THE OBJECT ##
head(x@individuals)
names(x@records)
lapply(x@records, head)
x@contacts
x@dna
x@trees


## HEAD, TAIL, SUMMARY ##
head(x)
tail(x)
summary(x)


##  ACCESSORS
get.nlocus(x)
get.locus(x)
get.nindividuals(x)
head(get.individuals(x))
get.individuals(x, data="contacts")
get.nsequences(x)
get.dna(x, locus="gene2")
get.dna(x, locus=1)
head(get.data(x, "Fever"))
head(get.data(x, "Age", showSource=TRUE))
head(get.data(x, c("Age","Sex", "infector"), showSource=TRUE))


## GRAPHICS ##
## default plot (timeline of information) ##
plot(x)
plot(x, colorBy='Sex')
plot(x, colorBy='Sex', orderBy='Sex')
plot(subset(x, 1:50), colorBy='Sex', size=4)

## plot contacts ##
plot(x, "contacts", main="Contacts")

## visualize data on a map ##
plot(x,'geo',location=c('lon','lat'),zoom=15,colorBy='Sex')

## plot the tree ##
plotggphy(x)
plotggphy(subset(x, 1:50), tip.color="Sex", color.pal="Set1")

Run the code above in your browser using DataLab