diff --git a/DESCRIPTION b/DESCRIPTION
index 62a79aa..fd98d07 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -22,6 +22,7 @@ Depends:
R (>= 2.10)
Imports:
data.table,
+ glue,
keras,
rlang,
progress,
diff --git a/R/plots.R b/R/plots.R
index fa31d3b..84b21cd 100644
--- a/R/plots.R
+++ b/R/plots.R
@@ -73,8 +73,12 @@ plot_positions <- function(species_ids, gene_sets) {
data = gene_set_data[gene %chin% gene_set],
x = ~species,
y = ~distance,
- text = ~name,
name = gene_set_name,
+ text = ~glue::glue(
+ "{name}
",
+ "{round(distance / 1000000, digits = 2)} MBp"
+ ),
+ hoverinfo = "text",
marker = list(
size = 10,
color = gene_set_color(index)
@@ -151,14 +155,13 @@ plot_rankings <- function(rankings, gene_sets) {
x = ranking_name,
y = ~score,
name = gene_set_name,
- text = ~name,
- customdata = ~percentile,
- hovertemplate = paste0(
- "%{text}
",
- "Score: %{y:.3}
",
- "Percentile: %{customdata:.2%}",
- ""
+ text = ~glue::glue(
+ "{name}
",
+ "Score: {round(score, digits = 2)}
",
+ "Rank: {rank}
",
+ "Percentile: {round(percentile * 100, digits = 2)}%"
),
+ hoverinfo = "text",
showlegend = is_first,
marker = list(
size = 10,
@@ -235,15 +238,13 @@ plot_scores <- function(ranking, gene_sets = NULL, max_rank = NULL) {
x = ~percentile,
y = ~score,
name = gene_set_name,
- text = ~name,
- customdata = ~rank,
- hovertemplate = paste0(
- "%{text}
",
- "Score: %{y:.3}
",
- "Rank: %{customdata}
",
- "Percentile: %{x:.2%}",
- ""
+ text = ~glue::glue(
+ "{name}
",
+ "Score: {round(score, digits = 2)}
",
+ "Rank: {rank}
",
+ "Percentile: {round(percentile * 100, digits = 2)}%"
),
+ hoverinfo = "text",
marker = list(
size = 10,
color = gene_set_color(index)
@@ -439,13 +440,15 @@ plot_scores_by_position <- function(ranking,
x = ~start_position,
y = ~score,
name = ~gene_set,
- text = ~name,
- hovertemplate = paste0(
- "%{text}
",
- "Position: %{x:.0} Bp
",
- "Score: %{y:.3}
",
- ""
- )
+ text = ~glue::glue(
+ "{name}
",
+ "Position: ",
+ "{round(start_position / 1000000, digits = 2)} MBp
",
+ "Score: {round(score, digits = 2)}
",
+ "Rank: {rank}
",
+ "Percentile: {round(percentile * 100, digits = 2)}%"
+ ),
+ hoverinfo = "text",
) |>
plotly::layout(
xaxis = list(title = "Position (Bp)"),