Plot heatmap using pheatmap library
2
0
Entering edit mode
7.3 years ago
1769mkc ★ 1.2k

I want to plot heatmap in pheatmap , i can make the plot but I have issues showing the names in the plot the gene ID or annotation , i read the manual but its confusing can anyone show me how to overcome this problem

GENE               Value1                   Value 2
DDX11L1        3.87765e-02          4.07321e-02
AL627309.2`   3.06198e-02     0.00000e+00
RP11-34P13.9 0.00000e+00  2.12375e-03
OR4F29          0.00000e+004         .84229e-05

This is my data ,small data set how i want to put the names of gene in my heatmap ....any help would be appreciated

R • 3.1k views
ADD COMMENT
0
Entering edit mode

Can you post your code for plotting heatmap? So that people here can check what is missing.

ADD REPLY
0
Entering edit mode

Well I just used it to plot the heatmap only containing the values column

"pheatmap(data.matrix(p1.matrix), cluster_rows=T,cluster_cols=T, scale="column", col=colors)"

this is my basic sample code its just i converted my data frame into data matrix excluding the gene name ..

ADD REPLY
3
Entering edit mode
7.3 years ago
bruce.moran ▴ 960

This works for me, including annotating names:

mat<-matrix(ncol=2,nrow=4)
mat[,1]<-c(0.0387765,0.0306198,0,0)
mat[,2]<-c(0.0407321,0,0.00212375,0.0000484229)
colnames(mat)<-c("Value1","Value2")
rownames(mat)<-c("DDX11L1","AL627309.2","RP11-34P13.9","OR4F29")
pheatmap(mat)

pheatmap uses row names to annotate, so I think the issue is your GENE column not being the row names. You could use this to make it row names and remove GENE column:

mat1<-mat
rownames(mat1)<-mat1[,1]
mat1<-mat1[,-1]

Good luck.

ADD COMMENT
0
Entering edit mode

Thanks for the fast response I read the manual but it quite confusing .I will give it a try with my whole data set.

ADD REPLY
1
Entering edit mode
7.3 years ago
sysbiocoder ▴ 180

To add annotation, try the following code

If your columns can be made into two groups G1 and G2, ncol(G1)) is no of columns in Group1, ncol(G2)) is no of columns in Group2

annotation <- data.frame(type = factor(c(rep("GI",ncol(G1)),rep("G2",ncol(G2)))))

rownames(annotation) <- colnames(mat1)

cols <- c("red", "darkgreen")

names(cols) <- c("Group1", "Group2")

pheatmap(mat1,col=bluered(200), annotation = annotation, scale="none", border_color = "white", cluster_rows=TRUE, cluster_cols=TRUE,show_rownames = TRUE ,show_colnames = TRUE, fontsize_row=4)

ADD COMMENT
0
Entering edit mode

so can you show me how i do it with my data set which I have given above ..since Im quite new to R and Im learning I have liitle idea about the factor function I read it what it does but I fail to apply it my data set ...show me how I do use you code in my data frame.Help would be greatly appreciated ..

ADD REPLY

Login before adding your answer.

Traffic: 2512 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6