# Gets pairwise distances from the sequence data of a simulation
simulate_pairwise_distances_cheap <- function(seq_data, timestamp)
{
num_sequences <- length(seq_data$sequences[[1]])
num_seq_pairs <- (num_sequences * (num_sequences-1))/2
size <- num_seq_pairs
pair_data <- data.frame(time = rep(NA_integer_, size),
seq1 = rep(NA_integer_, size),
seq2 = rep(NA_integer_, size),
seq_dist = rep(NA, size))
assign_row <- function(time_index, seq_data, num_seq_pairs)
{
new_rows <- dist_to_data_frame(stringdist_ape(seq_data$sequences[[1]]))
assign_row_inner <- function(seq_index, new_rows, time_index)
{
row_index <- seq_index
new_row <- list(time_index,
new_rows$seq1[seq_index], new_rows$seq2[seq_index],
new_rows$dist_1_2[seq_index])
pair_data[row_index, ] <<- new_row
}
map(1:num_seq_pairs, assign_row_inner, new_rows, time_index)
}
assign_row(timestamp, seq_data, num_seq_pairs)
return(pair_data)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.