knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(RScelestial) # We load igraph for drawing trees. If you do not want to draw, # there is no need to import igraph. library(igraph)
The RScelestial package could be installed easily as follows
Here we show a simulation. We build a data set with following command.
# Following command generates ten samples with 20 loci. # Rate of mutations on each edge of the evolutionary tree is 1.5. D = synthesis(10, 20, 5, seed = 7) D
seq = as.ten.state.matrix(D$seqeunce) SP = scelestial(seq, return.graph = TRUE) SP
You can draw the graph with following command
tree.plot(SP, vertex.size = 30)
Also, we can make a rooted tree with cell "C8" as the root of the tree as follows:
SP = scelestial(seq, root.assign.method = "fix", root = "C8", return.graph = TRUE) tree.plot(SP, vertex.size = 30)
Setting root.assign.method to "balance" lets the algorithm decide for a root that produces minimum height tree.
SP = scelestial(seq, root.assign.method = "balance", return.graph = TRUE) tree.plot(SP, vertex.size = 30)
Following command calculates the distance array between pairs of samples.
D.distance.matrix <- distance.matrix.true.tree(D) D.distance.matrix SP.distance.matrix <- distance.matrix.scelestial(SP) SP.distance.matrix ## Difference between normalized distance matrices vertices <- rownames(SP.distance.matrix) sum(abs(D.distance.matrix[vertices,vertices] - SP.distance.matrix))
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.