2021-06-24 22:38:16 +02:00
|
|
|
library(data.table)
|
2021-10-15 12:24:28 +02:00
|
|
|
library(plotly)
|
2021-06-24 22:38:16 +02:00
|
|
|
|
|
|
|
|
#' Draw a scatter plot containing gene positions.
|
2021-08-26 12:50:03 +02:00
|
|
|
#'
|
|
|
|
|
#' @param results Results from [`process_input()`].
|
2021-08-29 13:25:12 +02:00
|
|
|
#' @param species Species to be displayed.
|
2021-09-16 00:06:54 +02:00
|
|
|
#' @param genes Genes to be displayed.
|
|
|
|
|
#' @param distances Distance data to display.
|
|
|
|
|
scatter_plot <- function(results, species, genes, distances) {
|
2021-08-26 12:50:03 +02:00
|
|
|
species_ids <- species[, id]
|
2021-06-24 22:38:16 +02:00
|
|
|
|
2021-08-26 12:50:03 +02:00
|
|
|
data <- merge(
|
2021-09-16 00:06:54 +02:00
|
|
|
genes[, .(id, name)],
|
|
|
|
|
distances[species %in% species_ids],
|
2021-08-26 12:50:03 +02:00
|
|
|
by.x = "id", by.y = "gene"
|
|
|
|
|
)
|
2021-06-24 22:38:16 +02:00
|
|
|
|
2021-10-15 12:24:28 +02:00
|
|
|
data[name == "", name := "Unknown"]
|
|
|
|
|
|
|
|
|
|
plot_ly(
|
|
|
|
|
data = data,
|
|
|
|
|
x = ~species,
|
|
|
|
|
y = ~distance,
|
|
|
|
|
color = ~id,
|
|
|
|
|
name = ~name,
|
|
|
|
|
type = "scatter",
|
|
|
|
|
mode = "markers"
|
|
|
|
|
) |> layout(
|
|
|
|
|
xaxis = list(
|
|
|
|
|
title = "Species",
|
|
|
|
|
tickvals = species_ids,
|
|
|
|
|
ticktext = species[, name]
|
|
|
|
|
),
|
|
|
|
|
yaxis = list(title = "Distance to telomeres [Bp]")
|
|
|
|
|
)
|
2021-06-24 22:38:16 +02:00
|
|
|
}
|