Bioconductor / VariantAnnotation

Annotation of Genetic Variants
https://bioconductor.org/packages/VariantAnnotation
24 stars 20 forks source link

readVcf(), VariantAnnotation and shiny compatibility #77

Open FunGeST opened 10 months ago

FunGeST commented 10 months ago

Hi,

We are working on incorporating the readVcf function into our Shiny app, but it appears that Shiny is having trouble recognizing the object format.

After completing the upload, we received an error stating that 'data' must be either a matrix or a data frame and cannot be in the CollapsedVCF format. To address this issue, you may need to coerce the data to a matrix or data frame. Is there any way to collapse the vcf to table that is compatible with shiny?

The same is when trying to use the function predictCoding() Warning: Error in : unable to find an inherited method for function ‘predictCoding’ for signature ‘"CollapsedVCF", "BSgenome", "BSgenome", "missing"’

Many thanks Sandrine

example .. but just for information....

library(shiny) library(dplyr) library(DT) library(VariantAnnotation) library(BSgenome.Hsapiens.UCSC.hg38) txdb <- BSgenome.Hsapiens.UCSC.hg38

ui <- fluidPage( titlePanel("VCF XPLORR"), fileInput("fileInput", "Choose a VCF file", accept = c(".vcf", ".vcf.gz", ".maf"), multiple = FALSE) DTOutput("table") )

server<-function(session, input,output){ options(shiny.maxRequestSize=40*1024^2)

data1 <- reactive({ validate(need(input$fileInput,"")) if (is.null(input$fileInput)) { return(NULL) } else { raw_vcf_data <- readVcf(input$fileInput$datapath, 'hg38')

Perform filtering based on the FILTER column

filtered_vcf_data <- subset(raw_vcf_data, FILTER == "PASS") coding <- predictCoding(filtered_vcf_data, txdb, seqSource=Hsapiens) %>% as.data.frame()

return(coding)

})

output$table <-reactive({ renderDT({ if (!is.null(data1())) { datatable(head(data1(), 5)) } }}) } shinyApp(ui = ui, server = server)

vjcitn commented 10 months ago

Nice exercise. There is nothing problematic with shiny here, as far as I can tell.

https://gist.github.com/vjcitn/da11ea5228124fd06c5e59239a54cb9d

has edits to your demo code that will run. There are various issues to be addressed -- you don't set the server arguments properly, and you don't call predictCoding with correct arguments.

Keep us posted if you can't make progress on this.

On Fri, Dec 8, 2023 at 2:11 PM FunGeST @.***> wrote:

Hi,

We are working on incorporating the readVcf function into our Shiny app, but it appears that Shiny is having trouble recognizing the object format.

After completing the upload, we received an error stating that 'data' must be either a matrix or a data frame and cannot be in the CollapsedVCF format. To address this issue, you may need to coerce the data to a matrix or data frame. Is there any way to collapse the vcf to table that is compatible with shiny?

The same is when trying to use the function predictCoding() Warning: Error in : unable to find an inherited method for function ‘predictCoding’ for signature ‘"CollapsedVCF", "BSgenome", "BSgenome", "missing"’

Many thanks Sandrine example .. but just for information....

library(shiny) library(dplyr) library(DT) library(VariantAnnotation) library(BSgenome.Hsapiens.UCSC.hg38) txdb <- BSgenome.Hsapiens.UCSC.hg38

ui <- fluidPage( titlePanel("VCF XPLORR"), fileInput("fileInput", "Choose a VCF file", accept = c(".vcf", ".vcf.gz", ".maf"), multiple = FALSE) DTOutput("table") )

server<-function(session, input,output){ options(shiny.maxRequestSize=40*1024^2)

data1 <- reactive({ validate(need(input$fileInput,"")) if (is.null(input$fileInput)) { return(NULL) } else { raw_vcf_data <- readVcf(input$fileInput$datapath, 'hg38') Perform filtering based on the FILTER column

filtered_vcf_data <- subset(raw_vcf_data, FILTER == "PASS") coding <- predictCoding(filtered_vcf_data, txdb, seqSource=Hsapiens) %>% as.data.frame()

return(coding)

})

output$table <-reactive({ renderDT({ if (!is.null(data1())) { datatable(head(data1(), 5)) } }}) } shinyApp(ui = ui, server = server)

— Reply to this email directly, view it on GitHub https://github.com/Bioconductor/VariantAnnotation/issues/77, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDI5QTWDEYTRMH4O2ODS3LYINQ6XAVCNFSM6AAAAABANCOW6GVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAZTGMJYGA2DCMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance  HelpLine at http://www.partners.org/complianceline http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail.