Convert to R package

This commit is contained in:
Elias Projahn 2021-10-20 15:34:52 +02:00
parent b2e2dbf1af
commit d4611f47cf
15 changed files with 799 additions and 114 deletions

33
R/scatter_plot.R Normal file
View file

@ -0,0 +1,33 @@
# 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.
scatter_plot <- function(results, species, genes) {
species_ids <- species[, id]
data <- merge(
genes[, .(id, name)],
geposan::distances[species %in% species_ids],
by.x = "id", by.y = "gene"
)
data[name == "", name := "Unknown"]
plotly::plot_ly(
data = data,
x = ~species,
y = ~distance,
color = ~id,
name = ~name,
type = "scatter",
mode = "markers"
) |> plotly::layout(
xaxis = list(
title = "Species",
tickvals = species_ids,
ticktext = species[, name]
),
yaxis = list(title = "Distance to telomeres [Bp]")
)
}