heatmap R

 

> library(gplots)

Attaching package: ‘gplots’

The following object is masked from ‘package:stats’:

lowess

>
> setwd(“/home/zyshen/work/QM_nanjing”)
> data2<-read.csv(“combined_example.level_5.csv”, header=T, sep=”,”)
> data2plot<-data.matrix(data2[2:3])
> row.names(data2plot)<-data2[,1]
> heatmap.2(data2plot,trace=”none”,cexCol  = 2,col=greenred(50), margins = c(5, 40), sepwidth=c(0.05,0.05))Rplot

 

 

 

if (!require(“gplots”)) {
install.packages(“gplots”, dependencies = TRUE)
library(gplots)
}
if (!require(“RColorBrewer”)) {
install.packages(“RColorBrewer”, dependencies = TRUE)
library(RColorBrewer)
}
#########################################################
### B) Reading in data and transform it into matrix format
#########################################################
setwd(“/home/zyshen/Downloads/酵母代谢”)
data <- read.csv(“W29-knockout-0.1-SD-10X-internal.val.filter.csv”, comment.char=”#”, header=T)
rnames <- data[,1] # assign labels in column 1 to “rnames”
mat_data <- data.matrix(data[,2:ncol(data)]) # transform column 2-5 into a matrix
rownames(mat_data) <- rnames # assign row names
my_palette <- colorRampPalette(c(“red”, “yellow”, “green”))(n = 299)

# (optional) defines the color breaks manually for a “skewed” color transition
col_breaks = c(seq(-50,0,length=100), # for red
seq(0.1,20,length=100), # for yellow
seq(21,100,length=100)) # for green

heatmap.2(mat_data,
cellnote = mat_data, # same data set for cell labels
main = “Correlation”, # heat map title
notecol=”black”, # change font color of cell labels to black
density.info=”none”, # turns off density plot inside color legend
trace=”none”, # turns off trace lines inside the heat map
margins =c(8,20), # widens margins around plot
col=my_palette, # use on color palette defined earlier
breaks=col_breaks, # enable color transition at specified limits
dendrogram=”row”, # only draw a row dendrogram
Colv=”NA”)

RplotW29

 

 

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>