generateInsert.GeneralInsertor: Generate an insert

Description Usage Arguments Value Author(s) See Also Examples

Description

Generate an insert.

This method uses the function stgored in the proposeBy virtual field to sample the insert length and then calls the function stored in the generateBy field to generate the insert.

The default generateBy function set by the GeneralInsertor constructor truncates/repeats the template sequence stored in the templateSeq field to have the sequence with the right size and then calls the sampleStates method on the resulting object. That means that if we start with a template sequence which has NA states, but has a substitution process attached, then the resulting sequence will be different every time the generateInsert method is called.

The generateBy, proposeBy and templateSeq fields must be set in order to use this method.

Usage

1
2
## S3 method for class 'GeneralInsertor'
generateInsert(this, length=NA, target.seq=NA, event.pos=NA, insert.pos=NA, ...)

Arguments

this

A GeneralInsertor object.

length

Generate an insert with the specified length if this argument is present.

target.seq

The Sequence object targeted by the insertion (optional). This argument is passed to the generateBy method.

event.pos

The position of the site proposing the insertion (optional). This argument is passed to the generateBy method.

insert.pos

The position of the insertion in the target sequence (optional). This argument is passed to the generateBy method.

...

Not used.

Value

A Sequence object.

Author(s)

Botond Sipos, Gregory Jordan

See Also

For more information see GeneralInsertor.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
	# build the template sequence
	ts<-NucleotideSequence(length = 10,processes=list(list(JC69())));
	# fix some site states
	setStates(ts,"A",c(1,2));
	setStates(ts,"T",c(5,6));
	setStates(ts,"C",c(9,10));
	# print template sequence
	ts
	# create a GeneralInsertor object
	i<-GeneralInsertor(
		rate=0.5,
		template.seq=ts,
		propose.by=function(process){sample(c(5:50),1)}, # inserts between 5 and 50
	)
	# generate some inserts
	generateInsert(i)
	generateInsert(i)
	generateInsert(i)
	generateInsert(i)
 

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