Created
December 9, 2023 14:52
-
-
Save vjcitn/da11ea5228124fd06c5e59239a54cb9d to your computer and use it in GitHub Desktop.
using shiny with readVcf, predictCoding, ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) # works with the chr22.vcf.gz in the VariantAnnotation extdata | |
library(dplyr) | |
library(DT) | |
library(VariantAnnotation) | |
library(BSgenome.Hsapiens.UCSC.hg19) | |
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene | |
ui <- fluidPage( | |
titlePanel("VCF XPLORR"), | |
numericInput("numvar", "num2chk", value = 50, min = 50, max = 500, step = 10), | |
fileInput("fileInput", "Choose a VCF file", | |
accept = c(".vcf", ".vcf.gz", ".maf"), | |
multiple = FALSE | |
), | |
DTOutput("table") | |
) | |
server <- function(input, output, session) { | |
options(shiny.maxRequestSize = 40 * 1024^2) | |
output$table <- renderDataTable({ | |
validate(need(!is.null(input$fileInput$datapath), "please pick file")) | |
raw_vcf_data <- readVcf(input$fileInput$datapath, "hg19") | |
# Perform filtering based on the FILTER column | |
# filtered_vcf_data <- subset(raw_vcf_data, FILTER == "PASS") | |
myv <- as(raw_vcf_data, "VRanges")[seq_len(input$numvar)] | |
# seqlevelsStyle(myv) = "UCSC" # FIXME! | |
seqlevels(myv) <- paste0("chr", seqlevels(myv)) | |
coding <- predictCoding(myv, txdb, seqSource = Hsapiens, DNAStringSet(alt(myv))) | |
as.data.frame(coding) | |
}) | |
} | |
shinyApp(ui = ui, server = server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment