Hi,
I have a raw counts file extracted by featurecounts tool and also a gene length matrix. I was going to count rpkm for my 76 samples then I did like below
rawcounts <- read.table("rawcounts.txt", header = T, sep = "\t")
head(rawcounts[,1:4])
Geneid SRR018347 SSR019035 SRR074122
1 AT1G01010 31 37 4
2 AT1G01020 153 211 19
3 AT1G01030 10 13 0
4 AT1G01040 88 106 3
5 AT1G01046 0 0 0
6 AT1G01050 228 272 195
dim(rawcounts)
[1] 33602 77
gene-length <- read.table("gene-length.txt")
head(gene-length[,1:4])
V1 V2 V3 V4
V1 Length 1688 1774 1905
dim(gene-length )
[1] 1 33603
d <- DGEList(counts=rawcounts)
cpm(d)
cpm(d,log=TRUE)
d$genes$Length <- gene-length
rpkm(d)
Warning message:
In Ops.factor(left, right) : '/' not meaningful for factors
Even I tried with transposed gene length matrix but again I got error
What is my fault please?
The "not meaningful for factors" and the output of
head(gene-length[,1:4])
show you what the problem is.In addition, pay attention to
dim(rawcounts)
vsdim(gene-length)
.Thank you,
I tried many corrections for example I added a column as genes length to my raw counts file the header became like below
Then I tried
I tried with or with adding gene-length column. Then I tried like below
But I read the gene-length already even I tried by adding the length as an additional column to raw counts. Actually I can't figure out what is my fault. For example in
d$genes$Length <- c(1000,2000,500,1500,3000)
, what isgenes
?Please help me because this time really it is not a lazy post. I promise I am trying for many hours, I have gene length, I have raw counts but I cant figure out what to do
Suppose you start with:
Note that V1 is "Length", that likely made the whole dataframe a factor rather than numeric. So:
or something along those lines.
thanks a lot Devon,
your tip worked well
I just noticed: your variable name
gene-length
is invalid, and if you did not get an error means you are posting untested code, different from the one you are having real problems. This may result in a wild goose chase.but gene-length variable only was a name to ask my question clearly, if not what I posted below is the code I did finally in which I named length of gene as
mycounts1
. if you mean the samemycounts1
??