mirror of
https://github.com/johrpan/geposan.git
synced 2025-10-26 18:57:25 +01:00
plots: Simplify positions plot
This commit is contained in:
parent
a347bf0ad4
commit
f940d7d9b0
1 changed files with 11 additions and 9 deletions
20
R/plots.R
20
R/plots.R
|
|
@ -15,26 +15,28 @@ plot_positions <- function(species_ids, gene_sets) {
|
|||
# Prefilter data by species.
|
||||
data <- geposan::distances[species %chin% species_ids]
|
||||
|
||||
sample_data <- data[sample(nrow(data), 1000)]
|
||||
species_max_distance <- data[,
|
||||
.(max_distance = max(distance)),
|
||||
by = species
|
||||
]
|
||||
|
||||
# Prefilter species.
|
||||
species <- geposan::species[id %chin% species_ids]
|
||||
|
||||
plot <- plotly::plot_ly(colors = "Set2") |>
|
||||
plotly::add_markers(
|
||||
data = sample_data,
|
||||
x = ~species,
|
||||
y = ~distance,
|
||||
color = "All genes",
|
||||
hoverinfo = "skip"
|
||||
) |>
|
||||
plotly::layout(
|
||||
xaxis = list(
|
||||
title = "Species",
|
||||
tickvals = species$id,
|
||||
ticktext = species$name
|
||||
),
|
||||
yaxis = list(title = "Distance to telomeres [Bp]")
|
||||
yaxis = list(title = "Distance to telomeres [Bp]"),
|
||||
bargap = 0.9
|
||||
) |> plotly::add_bars(
|
||||
data = species_max_distance,
|
||||
x = ~species,
|
||||
y = ~max_distance,
|
||||
color = "All genes"
|
||||
)
|
||||
|
||||
if (length(gene_sets) > 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue