Learn R Programming

OutbreakTools (version 0.1-0)

subset: Subset data in "obkData" objects

Description

subset is a generic function with methods for obkData, obkSequences and obkContacts objects. It can be used to subset data by specified individuals, samples, loci, sequences, or date range. Note that several subsetting criteria can be specified at the same time.

Usage

## S3 method for class 'obkData':
subset(x, individuals=NULL, locus=NULL, sequences=NULL,
       date.from=NULL, date.to=NULL, date.format=NULL, \dots)

## S3 method for class 'obkSequences': subset(x, sequences=NULL, locus=NULL, individuals=NULL, date.from=NULL, date.to=NULL, date.format=NULL, \dots)

## S3 method for class 'obkContacts': subset(x, individuals=NULL, date.from=NULL, date.to=NULL, date.format=NULL, \dots)

Arguments

x
an obkData object.
individuals
labels of retained individuals; if integer, numeric or logical are provided, they are assumed to indicate individuals as returned by get.individuals.
locus
labels of retained loci; if integer, numeric or logical are provided, they are assumed to indicate locus as returned by get.locus.
sequences
labels of retained loci; if integer, numeric or logical are provided, they are assumed to indicate sequences as returned by get.sequences.
date.from, date.to
the range of dates (in Date format) of retained samples.
date.format
the format for dates if in character strings; defaults to "%Y-%m-%d" (see ?as.Date).
...
currently not used.

Examples

Run this code
## LOAD ToyOutbreak obkData object ##
data(ToyOutbreak)
x <- ToyOutbreak


## TEST VARIOUS SUBSETTING ##
## by individual
get.individuals(x)
plot(x)
plot(subset(x, individuals=1:10))
subset(x, individuals=1)
subset(x, individuals="15")

## by locus
get.locus(x)
subset(x, locus=2)

## by locus and sequences
subset(x, locus=1, sequence=1:10)
plot(subset(x, locus=1, sequence=1:10))
plot(subset(x, locus=1, sequence=1:10), "phy")

## by dates
get.dates(x)
plotIndividualTimeline(subset(x, date.to="2000-01-05"), "dna")

Run the code above in your browser using DataLab