Question: heatmap.2 function from glpot issue
0
gravatar for krushnach80
2.8 years ago by
krushnach80830
krushnach80830 wrote:

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 • 2.4k views
ADD COMMENTlink modified 2.8 years ago by Kevin Blighe65k • written 2.8 years ago by krushnach80830
4
gravatar for Kevin Blighe
2.8 years ago by
Kevin Blighe65k
Kevin Blighe65k wrote:

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 COMMENTlink modified 15 months ago • written 2.8 years ago by Kevin Blighe65k

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 REPLYlink written 2.8 years ago by krushnach80830
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1113 users visited in the last hour