Skip to content

Instantly share code, notes, and snippets.

@juliangehring
Last active August 29, 2015 14:11
Show Gist options
  • Save juliangehring/978ff86691bd87e95daf to your computer and use it in GitHub Desktop.
Save juliangehring/978ff86691bd87e95daf to your computer and use it in GitHub Desktop.
Interactive construction of a ScanVcfParam object
scanVcfParamInteractive <- function(file) {
asdf <- function(x) {
df = data.frame(Field = rownames(x), Description = x$Description, Type = x$Type)
}
charIfNull <- function(x) {
if(is.null(x)) {
return(character())
}
x
}
x = scanVcfHeader(file)
ui = pageWithSidebar(
headerPanel("VCF header"),
sidebarPanel(
selectInput("info", "info", rownames(info(x)), multiple = TRUE),
selectInput("fixed", "fixed", rownames(fixed(x)), multiple = TRUE),
selectInput("geno", "geno", rownames(geno(x)), multiple = TRUE),
selectInput("samples", "samples", samples(x), multiple = TRUE),
actionButton("close_app", "Return")
),
mainPanel(
tabsetPanel(
tabPanel("info_table", dataTableOutput("info_table")),
tabPanel("fixed_table", dataTableOutput("fixed_table")),
tabPanel("geno_table", dataTableOutput("geno_table"))
)
)
)
server = function(input, output) {
observe({
if(input$close_app == 0)
return()
res = ScanVcfParam(
fixed = charIfNull(input$fixed),
info = charIfNull(input$info),
geno = charIfNull(input$geno),
samples = charIfNull(input$samples))
stopApp(res)
})
output$info_table = renderDataTable({
asdf(info(x))
})
output$fixed_table = renderDataTable({
asdf(fixed(x))
})
output$geno_table = renderDataTable({
asdf(geno(x))
})
}
runApp(list(ui = ui, server = server))
}
library(VariantAnnotation)
library(shiny)
fl = system.file("extdata", "chr22.vcf.gz", package = "VariantAnnotation")
res = scanVcfParamInteractive(fl) ## input: VCF file, output: ScanVcfParam object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment