plots: Improve scores plot performance

This commit is contained in:
Elias Projahn 2021-12-06 11:17:11 +01:00
parent 35fb5e3884
commit 1f5909cc02

View file

@ -156,13 +156,17 @@ plot_scores <- function(ranking, gene_sets = NULL, max_rank = NULL) {
stop("Please install \"plotly\" to use this function.") stop("Please install \"plotly\" to use this function.")
} }
# To speed up rendering, don't show every single gene.
sample_ranking <- ranking[seq(1, nrow(ranking), 5)]
plot <- plotly::plot_ly(colors = "Set2") |> plot <- plotly::plot_ly(colors = "Set2") |>
plotly::add_markers( plotly::add_lines(
data = ranking, data = sample_ranking,
x = ~rank, x = ~rank,
y = ~score, y = ~score,
color = "All genes", color = "All genes",
hoverinfo = "skip" hoverinfo = "skip",
line = list(width = 4)
) |> ) |>
plotly::layout( plotly::layout(
xaxis = list(title = "Rank"), xaxis = list(title = "Rank"),