Commit cf86b586 authored by Kunst, Jonathan's avatar Kunst, Jonathan
Browse files

Added fileload function so both csv and rds can be imported. Mapply used for...

Added fileload function so both csv and rds can be imported. Mapply used for options where multiple files can be selected (linkage map).
ouputTable does not show yet though
parent edf580bc
......@@ -5,11 +5,12 @@
# Date updated: 27-09-2021
# Packages ----
library(DT)
library(readr)
library(shiny)
library(shinybusy)
library(polyqtlR)
library(DT)
library(data.table)
# UI ----
# Define page layout, fluidPage automatically adjusts to user border dimensions
......@@ -37,34 +38,28 @@ ui <- fluidPage(
hr(),
fileInput(inputId = 'i_dosage',
label = 'SNP dosage score file'),
hr(),
#IBD probability input
fileInput(inputId = 'i_IBD',
label = 'IBD probability file'),
label = 'SNP dosage score file')
),
mainPanel(
tabsetPanel(
tabPanel('Phenotype',
DT::dataTableOutput('table_phenotype')),
tabPanel('Linkage Map 1',
DT::dataTableOutput('table_link_map_1')),
tabPanel('Linkage Map 2',
DT::dataTableOutput('table_link_map_2')),
tabPanel('Phased Linkage Map',
selectInput(inputId = 'map_choice',
label = 'Linkage Groups',
choices = 'Input map first'),
DT::dataTableOutput('table_link_map'),
textOutput('text_link_map')),
tabPanel('SNP Dosage Score',
DT::dataTableOutput('table_dosage')),
tabPanel('IBD Probability',
DT::dataTableOutput('table_IBD'))
DT::dataTableOutput('table_dosage'))
)
)
)
),
navbarMenu(# IBD page ----
'IBD estimation',
'IBD', # change to IBD with import + compute
tabPanel('Heuristic',
sidebarLayout(
sidebarPanel(
......@@ -87,7 +82,8 @@ ui <- fluidPage(
)
)
),
tabPanel('HMM')
tabPanel('HMM'),
tabPanel('Import')
),
......@@ -109,51 +105,69 @@ ui <- fluidPage(
)
)
)
# Server functions ----
# input read function #TODO
load_file <- function(name, path){
extension <- tools::file_ext(name)
switch(extension,
csv = read_csv(path),
rds = read_rds(path),
validate('Invalid file type, please use .csv or .rds'))
}
# Server ----
server <- function(input, output) {
server <- function(input, output, session) {
# Read Data ----
# Phenotype
phenotype <- reactive({
req(input$i_phenotype)
read.csv(input$i_phenotype$datapath, row.names = 1)
load_file(name = input$i_phenotype$name, path = input$i_phenotype$datapath)
})
# Phased Linkage maps
link_map <- reactive({
req(input$i_link_map)
lapply(input$i_link_map$datapath, read.csv, row.names = 1)
mapply(load_file,
name = input$i_link_map$name,
path = input$i_link_map$datapath,
SIMPLIFY = FALSE)
})
# update maplist selection
observeEvent(input$i_link_map, {
file_list <- names(link_map())
updateSelectInput(session, 'map_choice', label = 'Linkage Groups', choices = file_list)
})
# SNP Dosage data
dosage <- reactive({
req(input$i_dosage)
as.matrix(read.csv(input$i_dosage$datapath, row.names = 1))
load_file(name = input$i_dosage$name, path = input$i_dosage$datapath)
})
# IBD
IBD <- reactive({
req(input$i_IBD)
read.csv(input$i_IBD$datapath, row.names = 1)})
# Data tables ----
# Show table for phenotype data
# table for phenotype
output$table_phenotype <- DT::renderDataTable(phenotype())
# Show table for linkage map 1 data
output$table_link_map_1 <- DT::renderDataTable(link_map()[[1]],
selection = list(target = 'row+column'))
# tables for linkage map
output$table_link_map <- eventReactive(input$map_choice,
{fname <- input$map_choice
DT::renderDataTable(link_map()[fname][[1]])
})
# Show table for linkage map 2 data
output$table_link_map_2 <- DT::renderDataTable(link_map()[[2]],
selection = list(target = 'row+column'))
# test text
output$text_link_map <- eventReactive(input$map_choice,
{fname <- input$map_choice
print(names(link_map()[fname][[1]]))
})
# Show table for SNP dosage data
# table for SNP dosage
output$table_dosage <- DT::renderDataTable(dosage())
# Show table for IBD probability data
# table for IBD probability
output$table_IBD <- DT::renderDataTable(IBD())
# IBD imputation ----
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment