Hello everyone,
I am developing a simple Shiny app where users can upload a counts file (here called 'counts') and this can be analyzed later on using edgeR and Limma. This is a reactive object and I've used a reactive container called 'reactives'.
After reading the csv file as a dataframe, I tried to convert it to a numeric matrix using data.matrix. I've also made the gene ID's as the rownames and sample names as the colnames. I've also confirmed that the object was a matrix using class(reactives$counts) and this outputs as [1] "matrix" "array". The gene ID's are in the first column.
rownames(reactives$counts) <- reactives$counts[, c(1)]
reactives$counts <- reactives$counts[, -c(1)]
reactives$counts <- data.matrix(reactives$counts)
However, when I input this matrix into DGEList, I'm given the error: Warning: Error in $: $ operator is invalid for atomic vectors
. I've also tried to change the class of the matrix to numeric using:
class(reactives$counts) <- "numeric"
DGEList(counts=reactives$counts)
Could someone help me understand why I'm receiving this error? The matrix is not empty as I outputted it as a table successfully and it appeared normal. Please advise!
Thank you Gordon Smyth , I found out that defining gene, count, and group (i.e. DGEList(count=..., gene=..., group=...) resolved this issue.