Skip to content

Commit

Permalink
feat: added download files tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliversinn committed Jan 3, 2024
1 parent 9cf6bb9 commit 82ad7c7
Show file tree
Hide file tree
Showing 4 changed files with 478 additions and 36 deletions.
144 changes: 144 additions & 0 deletions Dashboard/downloads.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# combined_cases_dt ----
combined_cases_dt <- function(data) {
data <- datatable(
data,
extensions = "Buttons",
rownames = FALSE,
options = list(
language = list(
url = "//cdn.datatables.net/plug-ins/1.13.7/i18n/es-ES.json"
),
dom = "Bfrtip",
buttons = list(
list(
extend = "csv",
filename = "base_de_datos_casos"
),
list(
extend = "excel",
filename = "base_de_datos_casos"
)
),
scrollX = TRUE,
scrollY = "600px",
pageLength = 25
)
)
return(data)
}

# combined_demographics_dt ----
combined_demographics_dt <- function(data) {
data <- datatable(
data,
extensions = "Buttons",
rownames = FALSE,
options = list(
language = list(
url = "//cdn.datatables.net/plug-ins/1.13.7/i18n/es-ES.json"
),
dom = "Bfrtip",
buttons = list(
list(
extend = "csv",
filename = "base_de_datos_casos_demografia"
),
list(
extend = "excel",
filename = "base_de_datos_casos_demografia"
)
),
scrollX = TRUE,
scrollY = "600px",
pageLength = 25
)
)
return(data)
}

# combined_diagnosis_dt ----
combined_diagnosis_dt <- function(data) {
data <- datatable(
data,
extensions = "Buttons",
rownames = FALSE,
options = list(
language = list(
url = "//cdn.datatables.net/plug-ins/1.13.7/i18n/es-ES.json"
),
dom = "Bfrtip",
buttons = list(
list(
extend = "csv",
filename = "base_de_datos_casos_diagnostico"
),
list(
extend = "excel",
filename = "base_de_datos_casos_diagnostico"
)
),
scrollX = TRUE,
scrollY = "600px",
pageLength = 25
)
)
return(data)
}

# files_results_dt ----
files_results_dt <- function(data) {
data <- datatable(
data,
extensions = "Buttons",
rownames = FALSE,
options = list(
language = list(
url = "//cdn.datatables.net/plug-ins/1.13.7/i18n/es-ES.json"
),
dom = "Bfrtip",
buttons = list(
list(
extend = "csv",
filename = "base_de_datos_archivos"
),
list(
extend = "excel",
filename = "base_de_datos_archivos"
)
),
scrollX = TRUE,
scrollY = "600px",
pageLength = 25
)
)
return(data)
}

# files_cases_dt ----
files_cases_dt <- function(data) {
data <- datatable(
data,
extensions = "Buttons",
rownames = FALSE,
options = list(
language = list(
url = "//cdn.datatables.net/plug-ins/1.13.7/i18n/es-ES.json"
),
dom = "Bfrtip",
buttons = list(
list(
extend = "csv",
filename = "mapeo_archivos_casos_proyecto"
),
list(
extend = "excel",
filename = "mapeo_archivos_casos_proyecto"
)
),
scrollX = TRUE,
scrollY = "600px",
pageLength = 25
)
)
return(data)
}
1 change: 1 addition & 0 deletions Dashboard/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ source("project.R")
source("diagnosis.R")
source("demographics.R")
source("files.R")
source("downloads.R")
105 changes: 80 additions & 25 deletions Dashboard/server.R
Original file line number Diff line number Diff line change
@@ -1,29 +1,4 @@
function(input, output, session) {
# Filters ---
## projects_reactive ----
projects_reactive <- reactive({
projects <- GenomicDataCommons::projects() %>%
GenomicDataCommons::filter(program.name == "TCGA") %>%
GenomicDataCommons::facet(c("name", "project_id"))

if (input$project_id != "TODOS") {
projects <- projects %>%
GenomicDataCommons::filter(project_id == input$project_id)
}

if (input$disease_type != "TODOS") {
projects <- projects %>%
GenomicDataCommons::filter(disease_type == input$disease_type)
}

if (input$primary_site != "TODOS") {
projects <- projects %>%
GenomicDataCommons::filter(primary_site == input$primary_site)
}

projects <- projects %>%
GenomicDataCommons::results_all()
})

## combined_cases_reactive ----
combined_cases_reactive <- reactive({
Expand Down Expand Up @@ -1950,4 +1925,84 @@ function(input, output, session) {
)
)
})

## Downloads ----
### combined_cases_dt ----
output$combined_cases_dt <- DT::renderDataTable({
combined_cases_dt(
combined_cases_reactive() %>%
dplyr::filter(
case_id %in% case_ids$case_id
)
)
})

### combined_diagnosis_dt ----
output$combined_diagnosis_dt <- DT::renderDataTable({
combined_diagnosis_dt(
combined_diagnoses_reactive() %>%
dplyr::filter(
case_id %in% case_ids$case_id
)
)
})

### combined_demographics_dt ----
output$combined_demographics_dt <- DT::renderDataTable({
combined_demographics_dt(
combined_demographics_reactive() %>%
dplyr::filter(
case_id %in% case_ids$case_id
)
)
})

### files_cases_dt ----
output$files_cases_dt <- DT::renderDataTable({
files_cases_dt(
files_cases_reactive() %>%
dplyr::filter(
file_id %in% file_ids$file_id &
case_id %in% case_ids$case_id
)
)
})

### files_results_dt ----
output$files_results_dt <- DT::renderDataTable({
files_results_dt(
files_results_reactive() %>%
dplyr::filter(
file_id %in% file_ids$file_id
)
)
})

output$install_gdc <- renderPrint({
cat(
paste(
"if (!require(\"BiocManager\", quietly = TRUE))",
" install.packages(\"BiocManager\")",
" BiocManager::install(\"GenomicDataCommons\")",
sep = "\n"
)
)
})

output$download_gdc <- renderPrint({
cat(
paste(
"# Cargar la librería de GenomicDataCommons",
"library(\"GenomicDataCommons\")",
"",
"# Cargar el manifiesto a la sesión de R",
"# read.csv recibe como parametro la ruta del archivo",
"manifiesto <- read.csv(\"base_de_datos_archivos.csv\")",
"",
"# Descarga de archivos genómicos",
"vfile_names <- lapply(file_names$file_id, gdcdata)",
sep = "\n"
)
)
})
}
Loading

0 comments on commit 82ad7c7

Please sign in to comment.