mirror of
https://github.com/johrpan/ubigen.git
synced 2025-10-27 04:07:25 +01:00
Include trend line in GSEA plot
This commit is contained in:
parent
cc17c13888
commit
aed13425ed
2 changed files with 10 additions and 4 deletions
BIN
R/sysdata.rda
BIN
R/sysdata.rda
Binary file not shown.
|
|
@ -25,20 +25,26 @@ result <- if (file.exists(file_path)) {
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
result[, result := lapply(analysis, function (a) a$result)]
|
result[, result := lapply(analysis, function(a) a$result)]
|
||||||
result <- result[, rbindlist(result), by = bucket]
|
result <- result[, rbindlist(result), by = bucket]
|
||||||
|
|
||||||
data <- result[, .(count = .N), by = c("bucket", "source")]
|
data <- result[, .(count = .N), by = c("bucket", "source")]
|
||||||
|
data[, total := sum(count), by = bucket]
|
||||||
|
smooth_model <- loess(total ~ bucket, data, span = 0.25)
|
||||||
|
|
||||||
fig <- plotly::plot_ly() |>
|
fig <- plotly::plot_ly(data) |>
|
||||||
plotly::add_bars(
|
plotly::add_bars(
|
||||||
data = data,
|
|
||||||
x = ~bucket,
|
x = ~bucket,
|
||||||
y = ~count,
|
y = ~count,
|
||||||
color = ~source
|
color = ~source
|
||||||
) |>
|
) |>
|
||||||
|
plotly::add_lines(
|
||||||
|
x = ~bucket,
|
||||||
|
y = predict(smooth_model),
|
||||||
|
name = "All (smoothed)"
|
||||||
|
) |>
|
||||||
plotly::layout(
|
plotly::layout(
|
||||||
xaxis = list(title = "Bucket of genes (n = 500)"),
|
xaxis = list(title = glue::glue("Bucket of genes (n = {bucket_size})")),
|
||||||
yaxis = list(title = "Number of associated terms"),
|
yaxis = list(title = "Number of associated terms"),
|
||||||
barmode = "stack",
|
barmode = "stack",
|
||||||
legend = list(title = list(text = "<b>Source of term</b>"))
|
legend = list(title = list(text = "<b>Source of term</b>"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue