suppressPackageStartupMessages({
    library("plotlyutils")
    library("plotly")
})

data(GBMtopTable, package="plotlyvignettes")
set.seed(42)
tt <- GBMtopTable[sample(seq_len(nrow(GBMtopTable)), 1000), ]
title <- "Glioblastoma - IDH1 mutant vs wt"
xtitle <- "log<sub>2</sub>(fold-change)"
ytitle <- "-log<sub>10</sub>(FDR-adjusted p-value)"
colours <- c("#0000ff", "#000000", "#ff0000")

plot_ly(tt, 
    x = ~logFC, 
    y = ~-log10(P.Value),
    color = ~ Group,  
    text = ~ Symbol,
    hoverinfo = "x+y+text",
    type = "scatter", 
    mode = "markers") %>%
    layout(title = "Glioblastoma - IDH1 mutant vs wt",
        xaxis = list(title = xtitle),
        yaxis = list(title = ytitle))
linked_scatter_plot(
    x = tt[["logFC"]],
    xlab = xtitle,
    y = -log10(tt[["adj.P.Val"]]),
    ylab = ytitle,
    xlim = c(-max(abs(tt[["logFC"]])), max(abs(tt[["logFC"]]))) * 1.1,
    text = tt[["Text"]],
    links = tt[["Links"]],
    groups = tt[["Group"]],
    title = title,
    colours = colours)