knitr::opts_chunk$set(echo = TRUE)
Load the package
library(rcombinator)
Create the sequences and the Kimura-80 model matrix for point mutations.
sequences <- get_random_sequence(sequence_length = 500, num_sequences = 6) transition_matrix <- get_k80_matrix(time_jump = 10^6)
Let the sequences evolve.
seq_data <- simulate_point_mutation_markov(sequences, num_jumps = 50, transition_matrix)
Collect the data.
library(magrittr) pairwise_dist_data <- pairwise_distances(seq_data) pairwise_dist_data <- pairwise_dist_data %>% tidyr::unite(seq1, seq2, col="comparing", sep=" and ")
Plot the data.
library(ggplot2) p <- ggplot(data = pairwise_dist_data, aes(x=time, y=seq_dist, colour=comparing)) p <- p + geom_step() p <- p + labs(x = "time (in 1M years)", y = "sequence distance", title = "Comparing sequence distances over time using the K80 model for mutations") print(p)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.