mirror of
https://github.com/johrpan/geposanui.git
synced 2025-10-26 11:17:24 +01:00
37 lines
No EOL
939 B
R
37 lines
No EOL
939 B
R
library(data.table)
|
|
library(plotly)
|
|
|
|
#' Draw a scatter plot containing gene positions.
|
|
#'
|
|
#' @param results Results from [`process_input()`].
|
|
#' @param species Species to be displayed.
|
|
#' @param genes Genes to be displayed.
|
|
#' @param distances Distance data to display.
|
|
scatter_plot <- function(results, species, genes, distances) {
|
|
species_ids <- species[, id]
|
|
|
|
data <- merge(
|
|
genes[, .(id, name)],
|
|
distances[species %in% species_ids],
|
|
by.x = "id", by.y = "gene"
|
|
)
|
|
|
|
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]")
|
|
)
|
|
} |