mirror of
https://github.com/johrpan/geposanui.git
synced 2025-10-26 11:17:24 +01:00
Convert to R package
This commit is contained in:
parent
b2e2dbf1af
commit
d4611f47cf
15 changed files with 799 additions and 114 deletions
33
R/scatter_plot.R
Normal file
33
R/scatter_plot.R
Normal 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]")
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue