Hi all,
I have created a shiny app to display RNA seq analysis data. The user must enter a gene name in a specific format (e.g. Adh4, not ADH4). If they don't use the correct format, my server crashes. :(
The simplest fix conceptually is to check if the user input exists in my set of gene names --> then if it doesn't i just returns a message telling them to re input in the correct format or choose a different gene.
First: I ruled out using selectInput - it only allows 1000 entries to choose from (I have 20000 genes)
Second: Ive looked into validate/need but Im finding it confusing so Im not really sure how to use it.
MY CODE:
1) The user is asked for input in the form of a gene name via the UI with the following command:
textInput(inputId = "gene_id", label = "Enter gene name (capitalise first letter only) or XLOC number", value = "", placeholder = "Adh4 or XLOC_009602"),
2) The input is then used to create an object called "my_gene" containing all info about the gene name entered using the following server reactive command: (I think this is where validate/need goes)
my_gene <- reactive({getGenes(cuff,geneIdList = input$gene_id)})
3) The object is then parsed to retrieve the gene name only using the following server render command
output$gsn <- renderText({if (input$gene_id != "") {paste("Gene short name: ", as.character(featureNames(my_gene())$gene_short_name))}})
4) The gene name is passed to the user as output with the following UI command
textOutput("gsn")
Thanks in advance, Kenneth
Yes....but this is very confusing...I really dont know how to form the command. I know that it is inserted into:
but I dont know how.
You could do something like
You should maybe also consider making your code more tolerant of gene symbol capitalization. What I usually do from the start to avoid such issue is uppercase or lowercase every string that's used as some sort of ID or key.
I'm trying your code....but it appears to not close the validate bracket .....2 open, 1 close.
Here is what I tried: I've literally copied and pasted your code inside mine.
my_gene <- reactive( validate( need( input$gene_id %in% gene_list, 'Gene name not found. Make sure only the first letter is capitalized!') ) {getGenes(cuff,geneIdList = input$gene_id,sampleIdList = input$sns)})
I get 2 errors:
1) unmatched opening bracket @ reactive(
2) unexpected token '{' unexpected closing bracket '}' unexpected closing bracket ')'
Adding a comma ',' after your code @ "capitalized!'))," removes the errors but the app then won't run.
I know this is probably a syntax thing.
Kenneth.
PS: As regards making all IDs lowercase (which would be great), Id rather not mess with the output of cuffdiff....just to make it fit into my shiny app. Id rather fix the app to handle the output.
The syntax for reactive() should be
So I have taken your advice and added your code but found the error: cannot finde "gene_list" object. So I attempted to create a gene list as soon as I create the CuffSet (however this slows down the start up of the app dramatically:
Now when I enter a gene name correctly (e.g. Adh4) the code gives me the error message: Gene name not found. Capitalize first letter only.
Close ... but no trophy however t least it appears the server isn't breaking.
Suggestions?
Thanks again for your input.
Kenneth
Unless there's something I am missing, this would mean that 'Adh4' is not present in gene_list as entered. Check that both the input and gene_list contain what you expect. For example, there could be extra whitespace characters before or after some gene names.
Thank you...I will try that.
I also tried your suggestion of making all letters lowercase with the script below but this returns an error in the app (so the app doesnt load) and the database created is much smaller than it should be. I think there is some dependency on uppercase somewhere.