Sequence: The Sequence class

Description Usage Arguments Fields and Methods Author(s) See Also Examples

Description

This is the class representing a sequence. The backbone of the Sequence objects are lists aggregating Site objects. The class has fields for keeping track of cumulative site rates, the sum of all active event rates and methods for performing actions on a collection of sites (positions).

The Sequence objects have a field specifying an ancestral object, which can be a Sequence object (when the object is obtained through clone() ) or the "Root insertion process" object (for newly created objects).

Package:
Class Sequence

Object
~~|
~~+--PSRoot
~~~~~~~|
~~~~~~~+--Sequence

Directly known subclasses:
AminoAcidSequence, BinarySequence, CodonSequence, NucleotideSequence

public static class Sequence
extends PSRoot

Usage

1
2
Sequence(name=NA, string=NA, length=NA, alphabets=NA, processes=NA, ancestral.obj=NA,
  ...)

Arguments

name

The name of the Sequence object.

string

A string containing symbols belonging to the associated Alphabet object. It can be used to set the initial states of the aggregated Site objects. It also specifies the length of the sequence

length

The length of the sequence. It cannot be used when 'string' is specified.

alphabets

A list of Alphabet objects to be associated with the Site objects. The list is recycled in the case it is shorter than the sequence length.

processes

A list of lists of Process objects to be attached (recycled if shorter than sequence length).

ancestral.obj

The ancestral object (Sequence or Process).

...

Not used.

Fields and Methods

Methods:

as.character -
attachProcess -
checkConsistency -
clearStates -
clone -
copySubSequence -
deleteSubSequence -
detachProcess -
getAlphabets -
getAncestral -
getBigRate -
getCumulativeRates -
getCumulativeRatesFromRange -
getDeletionTolerance -
getEvents -
getId -
getInsertionTolerance -
getLength -
getName -
getOmegas -
getParameterAtSites -
getProcesses -
getRateMultipliers -
getSites -
getStates -
getString -
getSymbolFreqs -
getTotalRates -
getTotalRatesFromRange -
getUniqueAlphabets -
getUniqueProcesses -
getWriteProtected -
insertSequence -
is -
plot -
plotParametersAtSites -
plusGamma -
plusInvGamma -
sampleStates -
setAlphabets -
setAncestral -
setBigRate -
setCumulativeRates -
setDeletionTolerance -
setId -
setInsertionTolerance -
setLength -
setName -
setOmegas -
setParameterAtSites -
setProcesses -
setRateMultipliers -
setStates -
setString -
setTotalRates -
setUniqueAlphabets -
setUniqueProcesses -
setWriteProtected -
summary -

Methods inherited from PSRoot:
checkConsistency, enableVirtual, getComments, getMethodsList, globalConsistencyCheck, intersect.list, is, is.na, ll, my.all.equal, plot, setComments, setMethodsList, summary, virtualAssignmentForbidden

Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, names, objectSize, print, save

Author(s)

Botond Sipos, Gregory Jordan

See Also

Alphabet Site Process Event

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
	# create a sequence object by
	# providng alphabets, processes and states
	s.one<-Sequence(
		name="Seq",
		string="AATTGGCCTTAAGGCCTTAA",
		alphabets=list(NucleotideAlphabet()),
		processes=list(list(JC69()))
	)
	s.one
	# check if inherits from Sequence
	is.Sequence(s.one)
	# get object summary
	summary(s.one)
	# create a sequence object,
	# specifying length, alphabets
	# and ancestral object
	s<-Sequence(
		name="Seq",
		length=20,
		ancestral.obj=s.one
	)
	# get sequence string
	s$string
	# get the list of site objects
	s$sites
	# get object id
	s$id
	# set and get name
	s$name<-"SeqSeq"
	s$seq
	# get length
	s$length
	# get and set ancestral object
	s$ancestral
	s$ancestral<-Sequence();
	# set alphabets
	setAlphabets(s,list(NucleotideAlphabet()))
	# set states
	# "A"-s in the range 1:10
	setStates(s,"A",1:10)
	# a pattern of "ATGC"-s in the range 11:20
	setStates(s,c("A","T","G","C"),11:20)
	# get states from range 10:12
	getStates(s,10:12)
	# attach a JC69 process to range 1:10
	jc69<-JC69()
	attachProcess(s,jc69,1:10)
	# set the rate multiplier site-process specific parameter for jc69
	setParameterAtSites(s,jc69,"rate.multiplier",2,1:10)
	# get "rate.multiplier" for jc69 from range 1:2
	getParameterAtSites(s, jc69, "rate.multiplier",1:2)
	# attach a GTR process to range 11:20
	gtr<-GTR()
	attachProcess(s,gtr,11:20)
	# set and get rate multipliers for gtr
	setRateMultipliers(s, gtr, c(0,5,1), 11:20)
	getRateMultipliers(s, gtr, 11:20)
	# get processes from range 1:5
	getProcesses(s,1:5)
	# replace the processes with a (GTR, JC69), JC69 pattern
	s$processes<-list(list(GTR(), JC69()), list(JC69()))
	# get processes from range 1:2
	getProcesses(s,1:2)
	# get unique processes
	s$uniqueProcesses
	# get unique alphabets
	s$uniqueAlphabets
	# get symbol frequencies
	getSymbolFreqs(s)
	# get the big rate
	s$bigRate
	# get a vector of total rates from range 1:4
	getTotalRatesFromRange(s,1:4)
	# get a vector of cumulative rates from range 1:4
	getCumulativeRatesFromRange(s,1:4)
	# reset all site states
	clearStates(s)
	s
	# sample states from the equilibrium distributions
	# of the attached substitution processes
	sampleStates(s)
	s
	# clone s
	s.clone<-clone(s)
	# insert a sequence in s.clone after position 2
	insertSequence(s.clone,NucleotideSequence(string="AAAAAA"),2)
	s.clone
	# delete positions 1,2,3 and 10
	deleteSubSequence(s.clone, c(1:3,10))
	s.clone
	# copy positions 7:10 into a new sequence object
	sc<-copySubSequence(s.clone, 7:10)
	sc
	# get events from sc in the range 1:2
	getEvents(sc,1:2)
 

phylosim documentation built on Nov. 22, 2019, 1:07 a.m.