Question: error while making a DegList object on R using edgeR package (Error in colSums(counts) : 'x' must be numeric)
gravatar for deeksha3696
8 weeks ago by
deeksha369610 wrote:

hey, I am doing an RNAseq analysis (using edgeR) I am loading my data for differential analysis, my data is of read counts. I am now just trying to make DEGList object but, it is showing "Error in colSums(counts): 'x' must be numeric. Please suggest what should I do. thank you!! command used:

rawCountTable <- read.table(file.choose(),header=TRUE)
sampleInfo <- read.table(file.choose(), header=TRUE)
dgeFull <- DGEList(rawCountTable, group=sampleInfo$condition)

Error in colSums(counts) : 'x' must be numeric

rna-seq R • 203 views
ADD COMMENTlink modified 21 days ago by Gordon Smyth750 • written 8 weeks ago by deeksha369610
gravatar for Gordon Smyth
21 days ago by
Gordon Smyth750
Gordon Smyth750 wrote:

This is frequently asked question that arises because many R users don't appreciate the difference between a matrix and a data.frame in R.

I assume that you have a tab-delimited file of read counts. The first field of your file probably contains the Gene Ids and the other columns probably contain read counts. When you read the rawCountTable using read.table you get a data.frame where the first column is a factor with the Gene Ids as levels and the other columns contain integers.

However DGEList is expecting to get a matrix rather than a data.frame. DGEList tries to convert the data.frame to a matrix but finds that the first column of rowCountTable is not numeric and hence issues an error message.

Assuming that your file counts only one column of Gene Ids, then you can fix the problem by

rawCountTable <- read.delim(file.choose(), row.names=1)

This will ensure that the Gene Ids are stored as row.names instead of as a column.

ADD COMMENTlink modified 21 days ago • written 21 days ago by Gordon Smyth750
gravatar for h.mon
8 weeks ago by
h.mon24k wrote:

Please show the result of:

head( rawCountTable )

rawCountTable is probably a data frame with a non-numeric column corresponding to gene names. You want to make this column into the row names of rawCountTable, then remove this column, to keep only numeric values.

ADD COMMENTlink written 8 weeks ago by h.mon24k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1358 users visited in the last hour