[R] Heat map in R

Juliet Hannah juliet.hannah at gmail.com
Sun Jan 9 16:10:49 CET 2011


Make sure your data is a matrix. There are many examples of expression heatmaps
available on the bioconductor list. After checking out these examples, I would
post to the bioconductor list if you are still having problems. Also
consider a small
example to get you a working heatpmap. You have to install two
bioconductor packages for this by using:

source("http://bioconductor.org/biocLite.R")
biocLite(c("ALL","genefilter"))

This will also install other bioconductor packages  that are needed.

#Then try:

library(ALL)
library(genefilter)
data(ALL)

#  just creating create data

 bcell <- grep("^B", as.character(ALL$BT))
 types <- c("NEG", "BCR/ABL")
 mysub <- which(as.character(ALL$mol.biol) %in% types)
 bc  <- ALL[, intersect(bcell, mysub)]
 bc$BT <- factor(bc$BT)
 bc$mol.biol <- factor(bc$mol.biol)
filter_bc  <- nsFilter(bc,var.cutoff=0.9)
 myfilt  <- filter_bc$eset
e <- exprs(myfilt)
# end of data creation

dim(e)
#[1] 880  79

class(e)
# [1] "matrix"

heatmap(e)





On Wed, Jan 5, 2011 at 4:33 PM, lraeburn at sfu.ca <lraeburn at sfu.ca> wrote:
>
> Hello,
> I am trying to make a heatmap in R and am having some trouble. I am very new
> to the world of R, but have been told that what I am trying to do should be
> possible.  I want to make a heat map that looks like  a gene expression
> heatmap (see http://en.wikipedia.org/wiki/Heat_map).
>
> I have 43 samples and 900 genes (yes I know this will be a huge map). I also
> have copy numbers associated with each gene/sample and need these to be
> represented as the colour intensities on the heat map.  There are multiple
> genes per sample with different copy numbers. I think my trouble may be how
> I am setting up my data frame.
>
> My data frame was created in excel as a tab deliminated text file:
>
> Gene   Copy Number   Sample ID
> A       1935              01
> B       2057              01
> C       2184              02
> D       1498              03
> E       2294              03
> F       2485              03
> G       1560              04
> H       3759              04
> I       2792              05
> J       7081              05
> K       1922              06
> .        .                .
> .        .                .
> .        .                .
> ZZZ     1354              43
>
>
> My code in R is something like this:
>
> data<-read.table("/Users/jsmt/desktop/test.txt",header=T)
>
> data_matrix<-data.matrix(data)
>
> data_heatmap <- heatmap(data_matrix, Rowv=NA, Colv=NA, col = cm.colors(256),
> scale="column", margins=c(5,10))
>
> I end up getting a heat map split into 3 columns: sample, depth, gene and
> the colours are just in big blocks that don't mean anything.
>
> Can anyone help me with my dataframe or my R code?  Again, I am fairly new
> to R, so if you can help, please give me very detailed help :)
>
> Thanks in advance!
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Heat-map-in-R-tp3176478p3176478.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list