Thank you very much. It indeed removed the trailing numbers:
> head(row.names(res))
[1] "ENSMUSG000000519515" "ENSMUSG000001028511" "ENSMUSG000001033771" "ENSMUSG000001031471" "ENSMUSG000001023311"
[6] "ENSMUSG000001023481"
But when I typed:
> res$symbol <- mapIds(org.Mm.eg.db, keys = row.names(res), column = "SYMBOL", keytype = "ENSEMBL", multiVals = "first")
I got
Error in .testForValidKeys(x, keys, keytype, fks) :
None of the keys entered are valid keys for 'ENSEMBL'. Please use the keys method to see a listing of valid arguments.
The second question is on the gsub command:
in my early command, I have used it in this way:
head(colnames(countdata))
[1] "DIV0.1.bam" "DIV0.2.bam" "DIV0.3.bam" "DIV7.1.bam" "DIV7.2.bam" "DIV7.3.bam"
colnames(countdata) <- gsub(".bam" , "", colnames(countdata))
head(colnames(countdata))
[1] "DIV0.1" "DIV0.2" "DIV0.3" "DIV7.1" "DIV7.2" "DIV7.3"
It worked well. These differences got me a little bit confused.
Thanks you very much
I got an answer from a previous post by others (https://www.biostars.org/p/301116/#496172).
But when I tried to ger rid of trail numbers using:
it turns out everything was replaced with "".