Learn R Programming

phyclust (version 0.1-34)

gen.seq: Generate Sequences Given a Rooted Tree.

Description

These functions call seqgen to generate sequences by evolutions models based on a rooted tree. gen.seq.HKY is to generate nucleotide sequences, and gen.seq.SNP is to generate SNP sequences.

Usage

gen.seq.HKY(rooted.tree, pi, kappa, L, rate.scale = 1,
            anc.seq = NULL)
gen.seq.SNP(rooted.tree, pi, L, rate.scale = 1, anc.seq = NULL)

Value

Return an object in Class seqgen.

Arguments

rooted.tree

a rooted tree in Class phylo.

pi

equilibrium probabilities, sums to 1.

kappa

transition and transversion bias.

L

number of sites.

rate.scale

a scale to all branch lengths.

anc.seq

an ancestral sequence either in nids or sids, length = \(L\).

Author

Wei-Chen Chen wccsnow@gmail.com

Details

The rooted.tree should be in a phylo class of ape, and may be created by ms.

The pi has length 4 for nucleotide sequences, and 2 for SNP sequences.

The rate.scale is equivalent to rescale the height of rooted.tree.

References

Phylogenetic Clustering Website: https://snoweye.github.io/phyclust/

See Also

gen.star.tree, seqgen.

Examples

Run this code

library(phyclust, quiet = TRUE)

# Generate a tree
set.seed(1234)
ret.ms <- ms(nsam = 5, nreps = 1, opts = "-T")
tree.ms <- read.tree(text = ret.ms[3])

# Generate nucleotide sequences
anc.HKY <- rep(0:3, 3)
pi.HKY <- c(0.2, 0.2, 0.3, 0.3)
kappa <- 1.1
L <- length(anc.HKY)
set.seed(1234)
paste(nid2code(anc.HKY, lower.case = FALSE), collapse = "")
(HKY.1 <- gen.seq.HKY(tree.ms, pi.HKY, kappa, L, anc.seq = anc.HKY))

# evolve 5 times longer
(HKY.2 <- gen.seq.HKY(tree.ms, pi.HKY, kappa, L,
                      rate.scale = 5, anc.seq = anc.HKY))

# Generate SNP sequences
anc.SNP <- rep(0:1, 6)
pi.SNP <- c(0.4, 0.6)
L <- length(anc.SNP)
set.seed(1234)
paste(sid2snp(anc.SNP), collapse = "")
(SNP.1 <- gen.seq.SNP(tree.ms, pi.SNP, L, anc.seq = anc.SNP))

# evolve 5 times longer
(SNP.2 <- gen.seq.SNP(tree.ms, pi.SNP, L, rate.scale = 5,
                      anc.seq = anc.SNP))

Run the code above in your browser using DataLab