Initial commit

This commit is contained in:
Elias Projahn 2022-05-07 17:54:23 +02:00
commit be1a4ef2fd
12 changed files with 825 additions and 0 deletions

8
R/app.R Normal file
View file

@ -0,0 +1,8 @@
#' Run the application server.
#'
#' @param port The port to serve the application on.
#'
#' @export
run_app <- function(port = 3464) {
runApp(shinyApp(ui, server), port = port)
}

2
R/data.R Normal file
View file

@ -0,0 +1,2 @@
#' A `data.table` containig data on genes and their expression behavior.
"genes"

41
R/server.R Normal file
View file

@ -0,0 +1,41 @@
#' Server implementing the main user interface.
#' @noRd
server <- function(input, output) {
output$all_data <- DT::renderDataTable({
data <- ubigen::genes[, .(
"Gene" = glue::glue_data(
ubigen::genes,
"<a href=\"https://www.ensembl.org/Homo_sapiens/Gene/Summary",
"?db=core;g={gene}\" target=\"_blank\">{hgnc_name}</a>"
),
"Rank" = rank,
"Score" = score,
"Median" = median_expression,
"Mean" = mean_expression,
"Standard deviation" = sd_expression,
"Expressed" = above_zero,
"Above 50 TPM" = above_threshold,
"Above median" = above_median,
"Above 95%" = above_95
)]
DT::datatable(
data,
options = list(pageLength = 100),
rownames = FALSE,
escape = FALSE
) |>
DT::formatPercentage(c(
"Score",
"Expressed",
"Above 50 TPM",
"Above median",
"Above 95%"
)) |>
DT::formatRound(c(
"Median",
"Mean",
"Standard deviation"
))
})
}

30
R/ui.R Normal file
View file

@ -0,0 +1,30 @@
#' Function for creating the main user interface.
#' @noRd
ui <- function() {
navbarPage(
theme = bslib::bs_theme(
version = 5,
bootswatch = "united",
primary = "#7d19bf"
),
title = "Ubigen",
tabPanel(
"Explore",
sidebarLayout(
sidebarPanel(
width = 3,
),
mainPanel(
width = 9,
)
)
),
tabPanel(
title = "Data",
DT::dataTableOutput("all_data")
),
tabPanel(
title = "Publication"
)
)
}

14
R/utils.R Normal file
View file

@ -0,0 +1,14 @@
#' Various things that should be imported into the package namespace.
#'
#' @importFrom data.table :=
#' @importFrom data.table .BY
#' @importFrom data.table .EACHI
#' @importFrom data.table .GRP
#' @importFrom data.table .I
#' @importFrom data.table .N
#' @importFrom data.table .NGRP
#' @importFrom data.table .SD
#' @importFrom data.table data.table
#'
#' @import shiny
NULL