heatmap.2 function from glpot issue
1
0
Entering edit mode
6.4 years ago
1769mkc ★ 1.2k

my heatmap with gplot I have been trying heatmap with gplot as i wanted to get a zscore in my plot, i use pheatmap but since it doesn't give that zscore thing ,I'm trying to use glpot library ,here is my code i can't get the dimension right either the sample names are missed or the gene ID

library(gplots)
file1<- read.csv('new_dev.txt',header = T)
class(file1)
dat <- data.frame(file1)
dim(dat)
names(dat)
head(dat)
rownames(dat) <-dat$gene
head(dat)
dim(dat)
head(dat)
dat.tdy <- dat[,2:6]
dat.n <- scale(t(dat.tdy))
dat.tn <- t(dat.n)
round(colMeans(dat.n),1)
apply(dat.n,2,sd)
d1 <- dist(dat.n,method = "euclidean", diag = FALSE, upper = FALSE)
d2 <- distdat.tn,method = "euclidean", diag = FALSE, upper = TRUE)
c1 <- hclust(d1, method = "ward.D2", members = NULL)
# Clustering distance between proteins using Ward linkage
c2 <- hclust(d2, method = "ward.D2", members = NULL)

macolor = colorRampPalette(c("navyblue", "white", "red"))(100)


row_names <- rownamesdat.tn)

heatmap.2dat.tn, Rowv=as.dendrogram(c2),col =macolor 
          ,scale="row", margin=c(3.1, 5),trace='none',labRow = row_names,
          symkey=FALSE,symbreaks=FALSE,dendrogram="both",  
          density.info='density', denscol="red",lhei=c(1,2),
          lwid=c(1,1), keysize=0.1, key.par = list(cex=0.5))

dev.off()

Any suggestion or improvement would be highly appreciated.

heatmap with gplot

R • 4.3k views
ADD COMMENT
5
Entering edit mode
6.4 years ago

Have you looked through my innumerous postings on heatmap.2, pheatmap, and Heatmap (from ComplexHeatmap)?

I would recommend scaling your data outside the heatmap.2 function, setting breaks, and specifying a reordering function:

heatZ <- t( scaletdat.tn)) )
myBreaks <- seq(-3, 3, length.out=101)
heatmap.2(
  data.matrix(heatZ),
  ...,
  breaks=myBreaks,
  scale="none",
  reorderfun=function(d,w) reorder(d, w, agglo.FUN=mean), ...)

You can also play around with different distance and linkage methods:

#Re-order rows/columns by mean, use 1-Pearson's correlation distance, and complete linkage
heatmap.2(
  ...,
  reorderfun=function(d,w) reorder(d, w, agglo.FUN=mean),
  distfun=function(x) as.dist(1-cor(t(x))),
  hclustfun=function(x) hclust(x, method="complete"))

#Re-order rows/columns by mean, use Euclidean distance, and Ward's linkage
heatmap.2(
  ...,
  reorderfun=function(d,w) reorder(d, w, agglo.FUN=mean),
  distfun=function(x) dist(x, method="euclidean"),
  hclustfun=function(x) hclust(x, method="ward.D2"))

See these threads:

heatmap.2

pheatmap

ComplexHeatmap

ADD COMMENT
0
Entering edit mode

so the graphics issue is due to the scaling promlem because i tweaked margin the lhei ,lwid etc okay i will go through it

ADD REPLY

Login before adding your answer.

Traffic: 1795 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