mirror of
https://github.com/johrpan/geposanui.git
synced 2025-10-26 11:17:24 +01:00
Reindent code to use just two spaces
This commit is contained in:
parent
47b8d7a1f0
commit
13b5efc1e3
10 changed files with 1000 additions and 999 deletions
193
R/results.R
193
R/results.R
|
|
@ -1,20 +1,20 @@
|
|||
#' Construct UI for the detailed results panel.
|
||||
#' @noRd
|
||||
results_ui <- function(id) {
|
||||
verticalLayout(
|
||||
div(
|
||||
style = "margin-top: 16px",
|
||||
splitLayout(
|
||||
cellWidths = "auto",
|
||||
uiOutput(NS(id, "copy")),
|
||||
downloadButton(NS(id, "download"), "Download CSV")
|
||||
)
|
||||
),
|
||||
div(
|
||||
style = "margin-top: 16px",
|
||||
DT::DTOutput(NS(id, "genes"))
|
||||
)
|
||||
verticalLayout(
|
||||
div(
|
||||
style = "margin-top: 16px",
|
||||
splitLayout(
|
||||
cellWidths = "auto",
|
||||
uiOutput(NS(id, "copy")),
|
||||
downloadButton(NS(id, "download"), "Download CSV")
|
||||
)
|
||||
),
|
||||
div(
|
||||
style = "margin-top: 16px",
|
||||
DT::DTOutput(NS(id, "genes"))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
#' Server for the detailed results panel.
|
||||
|
|
@ -24,92 +24,93 @@ results_ui <- function(id) {
|
|||
#'
|
||||
#' @noRd
|
||||
results_server <- function(id, filtered_results) {
|
||||
moduleServer(id, function(input, output, session) {
|
||||
output$copy <- renderUI({
|
||||
results <- filtered_results()
|
||||
moduleServer(id, function(input, output, session) {
|
||||
output$copy <- renderUI({
|
||||
results <- filtered_results()
|
||||
|
||||
gene_ids <- results[, gene]
|
||||
names <- results[name != "", name]
|
||||
gene_ids <- results[, gene]
|
||||
names <- results[name != "", name]
|
||||
|
||||
genes_text <- paste(gene_ids, collapse = "\n")
|
||||
names_text <- paste(names, collapse = "\n")
|
||||
genes_text <- paste(gene_ids, collapse = "\n")
|
||||
names_text <- paste(names, collapse = "\n")
|
||||
|
||||
splitLayout(
|
||||
cellWidths = "auto",
|
||||
rclipboard::rclipButton(
|
||||
"copy_ids_button",
|
||||
"Copy gene IDs",
|
||||
genes_text,
|
||||
icon = icon("clipboard")
|
||||
),
|
||||
rclipboard::rclipButton(
|
||||
"copy_names_button",
|
||||
"Copy gene names",
|
||||
names_text,
|
||||
icon = icon("clipboard")
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
columns <- c(
|
||||
"rank",
|
||||
"gene",
|
||||
"name",
|
||||
"chromosome",
|
||||
"distance",
|
||||
method_ids,
|
||||
"score",
|
||||
"percentile"
|
||||
splitLayout(
|
||||
cellWidths = "auto",
|
||||
rclipboard::rclipButton(
|
||||
"copy_ids_button",
|
||||
"Copy gene IDs",
|
||||
genes_text,
|
||||
icon = icon("clipboard")
|
||||
),
|
||||
rclipboard::rclipButton(
|
||||
"copy_names_button",
|
||||
"Copy gene names",
|
||||
names_text,
|
||||
icon = icon("clipboard")
|
||||
)
|
||||
|
||||
column_names <- c(
|
||||
"",
|
||||
"Gene",
|
||||
"",
|
||||
"Chromosome",
|
||||
"Distance",
|
||||
method_names,
|
||||
"Score",
|
||||
"Percentile"
|
||||
)
|
||||
|
||||
output_data <- reactive({
|
||||
filtered_results()[, ..columns][,
|
||||
distance := paste0(
|
||||
format(
|
||||
round(distance / 1000000, digits = 2),
|
||||
nsmall = 2,
|
||||
),
|
||||
" Mbp"
|
||||
)
|
||||
]
|
||||
})
|
||||
|
||||
output$download <- downloadHandler(
|
||||
filename = "geposan_filtered_results.csv",
|
||||
content = function(file) {
|
||||
fwrite(output_data(), file = file)
|
||||
},
|
||||
contentType = "text/csv"
|
||||
)
|
||||
|
||||
output$genes <- DT::renderDT({
|
||||
dt <- DT::datatable(
|
||||
output_data(),
|
||||
rownames = FALSE,
|
||||
colnames = column_names,
|
||||
options = list(
|
||||
rowCallback = js_link,
|
||||
columnDefs = list(list(visible = FALSE, targets = 2)),
|
||||
pageLength = 25
|
||||
)
|
||||
)
|
||||
|
||||
DT::formatPercentage(
|
||||
dt,
|
||||
c(method_ids, "score", "percentile"),
|
||||
digits = 2
|
||||
)
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
columns <- c(
|
||||
"rank",
|
||||
"gene",
|
||||
"name",
|
||||
"chromosome",
|
||||
"distance",
|
||||
method_ids,
|
||||
"score",
|
||||
"percentile"
|
||||
)
|
||||
|
||||
column_names <- c(
|
||||
"",
|
||||
"Gene",
|
||||
"",
|
||||
"Chromosome",
|
||||
"Distance",
|
||||
method_names,
|
||||
"Score",
|
||||
"Percentile"
|
||||
)
|
||||
|
||||
output_data <- reactive({
|
||||
filtered_results()[, ..columns][
|
||||
,
|
||||
distance := paste0(
|
||||
format(
|
||||
round(distance / 1000000, digits = 2),
|
||||
nsmall = 2,
|
||||
),
|
||||
" Mbp"
|
||||
)
|
||||
]
|
||||
})
|
||||
|
||||
output$download <- downloadHandler(
|
||||
filename = "geposan_filtered_results.csv",
|
||||
content = function(file) {
|
||||
fwrite(output_data(), file = file)
|
||||
},
|
||||
contentType = "text/csv"
|
||||
)
|
||||
|
||||
output$genes <- DT::renderDT({
|
||||
dt <- DT::datatable(
|
||||
output_data(),
|
||||
rownames = FALSE,
|
||||
colnames = column_names,
|
||||
options = list(
|
||||
rowCallback = js_link,
|
||||
columnDefs = list(list(visible = FALSE, targets = 2)),
|
||||
pageLength = 25
|
||||
)
|
||||
)
|
||||
|
||||
DT::formatPercentage(
|
||||
dt,
|
||||
c(method_ids, "score", "percentile"),
|
||||
digits = 2
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue