subset: Subset data in "obkData" objects

Description Usage Arguments Author(s) Examples

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## S4 method for signature 'obkData'
subset(x, individuals=NULL, locus=NULL, sequences=NULL,
       date.from=NULL, date.to=NULL, date.format=NULL, ...)

## S4 method for signature 'obkSequences'
subset(x, sequences=NULL, locus=NULL, individuals=NULL,
       date.from=NULL, date.to=NULL, date.format=NULL, ...)

## S4 method for signature 'obkContacts'
subset(x, individuals=NULL, date.from=NULL,
        date.to=NULL, date.format=NULL, ...)

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.

Author(s)

Thibaut Jombart

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## 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")

thibautjombart/OutbreakTools documentation built on Oct. 26, 2019, 10:56 p.m.