Skip to content

Commit

Permalink
feat: added project plots and graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliversinn committed Dec 31, 2023
1 parent a353db3 commit d758e9c
Show file tree
Hide file tree
Showing 4 changed files with 526 additions and 3 deletions.
7 changes: 6 additions & 1 deletion Dashboard/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ library(htmltools)
library(GenomicDataCommons)
library(DT)
library(BiocManager)
options(repos = BiocManager::repositories())
# options(repos = BiocManager::repositories())

Check warning on line 14 in Dashboard/global.R

View workflow job for this annotation

GitHub Actions / lint-project

file=Dashboard/global.R,line=14,col=3,[commented_code_linter] Commented code should be removed.
load(file = "tcga.RData")
tcga_project_ids_list <- c("TODOS", tcga_project_ids_list)

Expand All @@ -21,8 +21,13 @@ projects <- GenomicDataCommons::projects() %>%
GenomicDataCommons::facet(c("name", "project_id")) %>%
results_all()

vb_style <- function(msg = '', style="font-size: 100%;") {

Check warning on line 24 in Dashboard/global.R

View workflow job for this annotation

GitHub Actions / lint-project

file=Dashboard/global.R,line=24,col=28,[quotes_linter] Only use double-quotes.

Check warning on line 24 in Dashboard/global.R

View workflow job for this annotation

GitHub Actions / lint-project

file=Dashboard/global.R,line=24,col=37,[infix_spaces_linter] Put spaces around all infix operators.
tags$p( msg , style = style )

Check warning on line 25 in Dashboard/global.R

View workflow job for this annotation

GitHub Actions / lint-project

file=Dashboard/global.R,line=25,col=10,[spaces_inside_linter] Do not place spaces after parentheses.

Check warning on line 25 in Dashboard/global.R

View workflow job for this annotation

GitHub Actions / lint-project

file=Dashboard/global.R,line=25,col=14,[commas_linter] Commas should never have a space before.

Check warning on line 25 in Dashboard/global.R

View workflow job for this annotation

GitHub Actions / lint-project

file=Dashboard/global.R,line=25,col=30,[spaces_inside_linter] Do not place spaces before parentheses.
}


Sys.setenv(OPENSSL_CONF = "/dev/null")
options(shiny.fullstacktrace = TRUE)

source("explorer.R")
source("project.R")
269 changes: 269 additions & 0 deletions Dashboard/project.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
# project_disease_type_treemap ----
project_disease_type_treemap <- function(data) {
project_disease_type_tree <- data %>%

Check warning on line 3 in Dashboard/project.R

View workflow job for this annotation

GitHub Actions / lint-project

file=Dashboard/project.R,line=3,col=40,[trailing_whitespace_linter] Trailing whitespace is superfluous.
group_by(project_id, disease_type) %>%

Check warning on line 4 in Dashboard/project.R

View workflow job for this annotation

GitHub Actions / lint-project

file=Dashboard/project.R,line=4,col=43,[trailing_whitespace_linter] Trailing whitespace is superfluous.
tally(name = "Casos") %>%

Check warning on line 5 in Dashboard/project.R

View workflow job for this annotation

GitHub Actions / lint-project

file=Dashboard/project.R,line=5,col=30,[trailing_whitespace_linter] Trailing whitespace is superfluous.
mutate(
disease_type = paste(
Casos, disease_type
)
) %>%

Check warning on line 10 in Dashboard/project.R

View workflow job for this annotation

GitHub Actions / lint-project

file=Dashboard/project.R,line=10,col=10,[trailing_whitespace_linter] Trailing whitespace is superfluous.
rename(
"parent" = 1,
"label" = 2
)

project_disease_type_tree <- data %>%
dplyr::select(project_id) %>%
mutate(
parent = "Número de casos por proyecto y por tipo de enfermedad"
) %>%
group_by(parent, project_id) %>%
tally(name = "Casos") %>%
rename(
"parent" = 1,
"label" = 2
) %>%
rbind(., project_disease_type_tree) %>%
replace(is.na(.), "Sin dato")

# project_disease_type_treemap ----
project_disease_type_treemap <- plot_ly(
data = project_disease_type_tree,
branchvalues = "total",
type = "treemap",
#ids = ~ids,
labels = ~label,
parents = ~parent,
values = ~Casos
)

return(project_disease_type_treemap)
}

project_disease_type_treedt <- function(data) {
data <- data %>%
group_by(project_id, disease_type) %>%
tally(name = "Número de casos", sort = TRUE) %>%
rename(
"Proyecto" = 1,
"Tipo de enfermedad" = 2
) %>%
datatable(
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 = "casos_por_proyecto_tipo_enfermedad"
),
list(
extend = "excel",
filename = "casos_por_proyecto_tipo_enfermedad"
)
),
paging = FALSE,
scrollY = "400px",
scrollX = TRUE
)
)
return(data)
}

# project_bar ----
project_bar <- function(data) {
fig <- data %>%
group_by(project_id) %>%
tally(name = "Número de casos", sort = TRUE) %>%
rename("Proyecto" = 1) %>%
plot_ly(
x = ~Proyecto, y = ~`Número de casos`, type = "bar"
) %>%
layout(
xaxis = list(
title = "Proyecto",
categoryorder = "total descending"
),
yaxis = list(
title = "Número de casos"
)
) %>%
config(
displaylogo = FALSE,
modeBarButtonsToRemove = c(
"sendDataToCloud", "editInChartStudio", "pan2d", "select2d",
"drawclosedpath", "drawline", "drawrect", "drawopenpath",
"drawcircle", "eraseshape", "zoomIn2d", "zoomOut2d", "toggleSpikelines",
"lasso2d"
)
)
return(fig)
}

# project_bardt ----
project_bardt <- function(data) {
data <- data %>%
group_by(project_id, project_name) %>%
tally(name = "Número de casos", sort = TRUE) %>%
rename("Proyecto" = 1, "Nombre" = 2) %>%
datatable(
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 = "casos_por_proyecto"
),
list(
extend = "excel",
filename = "casos_por_proyecto"
)
),
paging = FALSE,
scrollY = "400px",
scrollX = TRUE
)
)
return(data)
}

# disease_type_bar ----
disease_type_bar <- function(data) {
fig <- data %>%
group_by(disease_type) %>%
tally(name = "Número de casos", sort = TRUE) %>%
rename("Tipo de enfermedad" = 1) %>%
plot_ly(
x = ~`Tipo de enfermedad`, y = ~`Número de casos`, type = "bar"
) %>%
layout(
xaxis = list(
title = "Tipo de enfermedad",
categoryorder = "total descending"
),
yaxis = list(
title = "Número de casos"
)
) %>%
config(
displaylogo = FALSE,
modeBarButtonsToRemove = c(
"sendDataToCloud", "editInChartStudio", "pan2d", "select2d",
"drawclosedpath", "drawline", "drawrect", "drawopenpath",
"drawcircle", "eraseshape", "zoomIn2d", "zoomOut2d", "toggleSpikelines",
"lasso2d"
)
)
return(fig)
}

# disease_type_bardt ----
disease_type_bardt <- function(data) {
data <- data %>%
group_by(disease_type) %>%
tally(name = "Número de casos", sort = TRUE) %>%
rename("Tipo de enfermedad" = 1) %>%
datatable(
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 = "casos_por_tipo_enfermedad"
),
list(
extend = "excel",
filename = "casos_por_tipo_enfermedad"
)
),
paging = FALSE,
scrollY = "400px",
scrollX = TRUE
)
)
return(data)
}

# primary_site_bar ----
primary_site_bar <- function(data) {
data <- data %>%
group_by(primary_site) %>%
tally(name = "Número de casos", sort = TRUE) %>%
rename("Sitio primario" = 1)

xticks_labels <- as.list(substr(data$`Sitio primario`, 1, 30))

fig <- plot_ly(
data,
x = ~`Sitio primario`, y = ~`Número de casos`, type = "bar"
) %>%
layout(
xaxis = list(
title = "Sitio primario",
categoryorder = "total descending",
ticktext = xticks_labels,
tickvals = as.list(c(0:nrow(data))),
tickmode = "array"
),
yaxis = list(
title = "Número de casos"
)
) %>%
config(
displaylogo = FALSE,
modeBarButtonsToRemove = c(
"sendDataToCloud", "editInChartStudio", "pan2d", "select2d",
"drawclosedpath", "drawline", "drawrect", "drawopenpath",
"drawcircle", "eraseshape", "zoomIn2d", "zoomOut2d", "toggleSpikelines",
"lasso2d"
)
)
return(fig)
}

# primary_site_bardt ----
primary_site_bardt <- function(data) {
data <- data %>%
group_by(primary_site) %>%
tally(name = "Número de casos", sort = TRUE) %>%
rename("Sitio primario" = 1) %>%
datatable(
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 = "casos_por_sitio_primario"
),
list(
extend = "excel",
filename = "casos_por_sitio_primario"
)
),
paging = FALSE,
scrollY = "400px",
scrollX = TRUE
)
)
return(data)
}
Loading

0 comments on commit d758e9c

Please sign in to comment.