# knitr::opts_chunk$set(echo = TRUE, cache = TRUE)
knitr::opts_chunk$set(
   # cache = TRUE,
   dpi = 60,
  comment = '#>',
  tidy = FALSE)
library(heatmaply)
library(dendextend)

Tissue- and time-dependent transcription in Ixodes ricinus salivary glands and midguts when blood feeding on the vertebrate host

Here we wish to reproduce figure 3: "Figure 3: Heat map of normalized RPKM data from the salivary glands (SG) and midguts (MG) of nymphal and adult Ixodes ricinus fed for different periods of time.".

The Z score represents the deviation from the mean by standard deviation units. For other details, please see the Figure 2 legend.

Figure 2 legend: A box plot was constructed using normalized reads per kilobase per million (RPKM) values for CDS with a total RPKM (considering the reads of all ten libraries) of 50 or larger to avoid inclusion of poorly expressed contigs. The normalized RPKM values (maximum 100) for ten different libraries from Ixodes ricinus are as follows: the first two numbers indicate the time point of organ collection from 0–12h (12), 12–24h (24), or 24–36h (36). Organs were either salivary glands (SG) or midguts (MG) and developmental stage was either nymphs (N) or adults (A). For more details, please consult the methods.

heatmap.2 of the figure

The data and code for this plot was shared by Ribeiro, Jose (NIH/NIAID) [E]

# rpkm50 <- read.delim("rpkm-50.txt",sep="\t",header=TRUE,dec=".",stringsAsFactors = FALSE,strip.white = TRUE)
### saveRDS(rpkm50, "data\\rpkm50.rda")
# http://r-pkgs.had.co.nz/data.html#data-data
# devtools::use_data(rpkm50)


library(heatmaplyExamples)
data(rpkm50)
head(rpkm50)

x <- as.matrix(rpkm50)
rc <- rainbow(nrow(x), start=0, end=.3)
cc <- rainbow(ncol(x), start=0, end=.3)

# pdf(file='heatmap-spearman.pdf')
hr <- hclust(as.dist(1-cor(t(x), method="spearman")), method="complete")# spearman clustering
hc <- hclust(as.dist(1-cor(x, method="spearman")), method="complete")# spearman clustering
library(gplots)
heatmap.2(x, col=bluered(75), Colv=as.dendrogram(hc), Rowv=as.dendrogram(hr), scale="row", key=T, keysize=1.5,density.info="none", trace="none",cexCol=0.9, cexRow=0.9,labRow=NA, dendrogram="both") # Z scores
# dev.off()

heatmaply

We can now just take the last line, and replace heatmap.2 with heatmaply (the only missing part would be to have the dendrogram to the left instead of the right)

library(heatmaply)
heatmaply(x, col=bluered(75), Colv=as.dendrogram(hc), Rowv=as.dendrogram(hr), scale="row",
          key=T, keysize=1.5,density.info="none", trace="none",
          cexCol=0.9, cexRow=0.9 ,
          labRow=NA, dendrogram="both"
          ) # Z scores

# heatmaply(x[1:100,])
# heatmaply(x[1:100,], labRow=NA)
# heatmaply(x[1:100,], # col=bluered(75), scale="row",
#           # key=T, keysize=1.5,density.info="none", trace="none",
#           cexCol=0.9,
#           # fontsize_row=.9,
#           # cexRow=0.9 ,
#           # labRow=NA,
#           dendrogram="both"
#           )

sessionInfo

sessionInfo()


talgalili/heatmaplyExamples documentation built on May 23, 2019, 7:36 a.m.