mirror of
https://github.com/johrpan/geposan.git
synced 2025-10-26 18:57:25 +01:00
Fix and enhance hover info in plots
This commit is contained in:
parent
b17eb049d1
commit
d83dfa0574
2 changed files with 27 additions and 23 deletions
|
|
@ -22,6 +22,7 @@ Depends:
|
||||||
R (>= 2.10)
|
R (>= 2.10)
|
||||||
Imports:
|
Imports:
|
||||||
data.table,
|
data.table,
|
||||||
|
glue,
|
||||||
keras,
|
keras,
|
||||||
rlang,
|
rlang,
|
||||||
progress,
|
progress,
|
||||||
|
|
|
||||||
49
R/plots.R
49
R/plots.R
|
|
@ -73,8 +73,12 @@ plot_positions <- function(species_ids, gene_sets) {
|
||||||
data = gene_set_data[gene %chin% gene_set],
|
data = gene_set_data[gene %chin% gene_set],
|
||||||
x = ~species,
|
x = ~species,
|
||||||
y = ~distance,
|
y = ~distance,
|
||||||
text = ~name,
|
|
||||||
name = gene_set_name,
|
name = gene_set_name,
|
||||||
|
text = ~glue::glue(
|
||||||
|
"<b>{name}</b><br>",
|
||||||
|
"{round(distance / 1000000, digits = 2)} MBp"
|
||||||
|
),
|
||||||
|
hoverinfo = "text",
|
||||||
marker = list(
|
marker = list(
|
||||||
size = 10,
|
size = 10,
|
||||||
color = gene_set_color(index)
|
color = gene_set_color(index)
|
||||||
|
|
@ -151,14 +155,13 @@ plot_rankings <- function(rankings, gene_sets) {
|
||||||
x = ranking_name,
|
x = ranking_name,
|
||||||
y = ~score,
|
y = ~score,
|
||||||
name = gene_set_name,
|
name = gene_set_name,
|
||||||
text = ~name,
|
text = ~glue::glue(
|
||||||
customdata = ~percentile,
|
"<b>{name}</b><br>",
|
||||||
hovertemplate = paste0(
|
"Score: {round(score, digits = 2)}<br>",
|
||||||
"<b>%{text}</b><br>",
|
"Rank: {rank}<br>",
|
||||||
"Score: %{y:.3}<br>",
|
"Percentile: {round(percentile * 100, digits = 2)}%"
|
||||||
"Percentile: %{customdata:.2%}",
|
|
||||||
"<extra></extra>"
|
|
||||||
),
|
),
|
||||||
|
hoverinfo = "text",
|
||||||
showlegend = is_first,
|
showlegend = is_first,
|
||||||
marker = list(
|
marker = list(
|
||||||
size = 10,
|
size = 10,
|
||||||
|
|
@ -235,15 +238,13 @@ plot_scores <- function(ranking, gene_sets = NULL, max_rank = NULL) {
|
||||||
x = ~percentile,
|
x = ~percentile,
|
||||||
y = ~score,
|
y = ~score,
|
||||||
name = gene_set_name,
|
name = gene_set_name,
|
||||||
text = ~name,
|
text = ~glue::glue(
|
||||||
customdata = ~rank,
|
"<b>{name}</b><br>",
|
||||||
hovertemplate = paste0(
|
"Score: {round(score, digits = 2)}<br>",
|
||||||
"<b>%{text}</b><br>",
|
"Rank: {rank}<br>",
|
||||||
"Score: %{y:.3}<br>",
|
"Percentile: {round(percentile * 100, digits = 2)}%"
|
||||||
"Rank: %{customdata}<br>",
|
|
||||||
"Percentile: %{x:.2%}",
|
|
||||||
"<extra></extra>"
|
|
||||||
),
|
),
|
||||||
|
hoverinfo = "text",
|
||||||
marker = list(
|
marker = list(
|
||||||
size = 10,
|
size = 10,
|
||||||
color = gene_set_color(index)
|
color = gene_set_color(index)
|
||||||
|
|
@ -439,13 +440,15 @@ plot_scores_by_position <- function(ranking,
|
||||||
x = ~start_position,
|
x = ~start_position,
|
||||||
y = ~score,
|
y = ~score,
|
||||||
name = ~gene_set,
|
name = ~gene_set,
|
||||||
text = ~name,
|
text = ~glue::glue(
|
||||||
hovertemplate = paste0(
|
"<b>{name}</b><br>",
|
||||||
"<b>%{text}</b><br>",
|
"Position: ",
|
||||||
"Position: %{x:.0} Bp<br>",
|
"{round(start_position / 1000000, digits = 2)} MBp<br>",
|
||||||
"Score: %{y:.3}<br>",
|
"Score: {round(score, digits = 2)}<br>",
|
||||||
"<extra></extra>"
|
"Rank: {rank}<br>",
|
||||||
)
|
"Percentile: {round(percentile * 100, digits = 2)}%"
|
||||||
|
),
|
||||||
|
hoverinfo = "text",
|
||||||
) |>
|
) |>
|
||||||
plotly::layout(
|
plotly::layout(
|
||||||
xaxis = list(title = "Position (Bp)"),
|
xaxis = list(title = "Position (Bp)"),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue