I am programming a heatmap in R based on a csv file. This contains the following information:
NAME,metformin,metformin,phenformin,phenyl biguanide,metformin,estradiol
Adenocarcinoma of lung,0,0,0,-1.834006462,1.715939688,0
Adenocarcinoma of lung,1.995916353,0,0,0,0,0
Thymic carcinoma,1.154056722,1.106488961,0,1.145126548,0,-1.14095315
alpha-1-Antitrypsin deficiency,0,0,0,0,-1.917025669,-1.974151858
So I want to create a heatmap in which in the name of the rows appears the labels: Adenocarcinoma of the lung, Adenocarcinoma… etc. I am doing this steps:
hm<-read.csv("heatmap1.csv",sep=",")
row.names(hm)<-hm$NAME
hm<-hm[,2:7]
hm_matrix<-data.matrix(hm)
heatM<-heatmap(hm_matrix, Rowv=NA, Colv=NA, col = cm.colors(256), scale="column", margins=c(5,10))
The problem I got is in the line that says:
row.names(hm)<-hm$NAME
Error in `row.names<-.data.frame`(`*tmp*`, value = c(1L, 1L, 3L, 2L)) :
duplicate 'row.names' are not allowed
I know that I have a duplicated name, but I really need that data appears in the heatmap because the measure levels (the quantities) are different even if they are from the same disease.
Thanks for the help
You can use
make.uniqueto make unique versions of the names