Hi all!
I want to create a shiny app for DESeq2 analysis. My main thought is to upload count matrix, extract colnames/experiments and provide an editable table to user in order to assign conditions to respective experiment (-> colData). After adjustment, user has to click a button in order to start DESeq2. However, when I click the button, I get following error:
Warning: Error in DESeqDataSet: the design formula contains an ordered factor. The internal steps do not work on ordered factors as a formula. Instead you should provide a matrix to the 'design' slot or to the 'full' argument of DESeq(), constructed using model.matrix.
I also checked whether values$new was transformed into a dataframe using hot _ to _ r(), and indeed it was. I can also present it as a dataframe in shiny using renderTable() (not shown in code), suggesting that transformation to dataframe from rhandsontable object worked
Does someone see why especially the design-part does not work or how I could solve this? Thanks in advance!
# server part
server <- function(input, output) {
values <- reactiveValues(df_data = NULL)
# general data input
observeEvent(input$file, {
if (is.null(input$file$datapath))
return(NULL)
values$count <- read.csv(input$file$datapath, row.names = 1)
values$df_data <- data.frame(experiment_name = colnames(values$count),
condition = rep(" information",length(colnames(values$count))))
})
#render table
output$x1 <- renderRHandsontable({
if(is.null(values$df_data))
return(NULL)
rhandsontable(values$df_data) %>%
hot_col(col = c("experiment_name","condition"), allowInvalid = TRUE, strict=FALSE)
})
#save edits/update (button click)!
observeEvent(input$saveBtn,{
values$new <- as.data.frame(hot_to_r(input$x1))
values$de <- DESeqDataSetFromMatrix(countData = values$count,
colData = values$new,
design = ~condition)
})
}
Hi Michael!
I checked for condition column before (values$df_data) and after (values$new) user edit if it is a factor and used renderText() to get output (corresponding ui-part not shown):
For both, the result is 'TRUE', but I don't know why. The following just shows me the factor vector with numbers (if i only have one condition, I get n times 1 and so on):
I actually did not expect it be a factor when I created the data frame at the top of 'server' function. Even if I use as.character() as wrapper around 'experiment_name' and/or 'condition', I still get a factor:
Can you print out
colData(dds)$condition
?Assuming you mean DESeqDataSetFromMatrix(...) with 'dds', I printed it out using renderText():
resulting in the same error:
Oops, I mean, can you print out
values$new
?renderTable() (renderText() won't work because it cannot concat table to string):
OR
OR
will print out the correctly edited table in the shiny app. So in general data storage and editing seems to work, but can - for some reason - not be accessed using '~condition'.
Hmm, I can't help much more I guess on this one, because for debugging, you would want to know what the input you are providing to DESeq2.