Help with Creating heatmaps in heatmap.2
2
0
Entering edit mode
7.9 years ago
nayeli0126 • 0

Hello,

I am fairly new to using R so I apologize if this question has been answered before but I have tried finding an answer for the past 2 weeks with no luck.

I have microarray data which has been grouped into WT (uninfected), WT(infected), Knockout(uninfected) and Knockout (infected)

the samples were grouped depending on the number of samples per group and then contrasts were made to determine dfiierential gene expression. I want to create a heatmap of these differentially expressed genes however I cannot get a heatmap to generate to show differential expression at the sample level. My heatmap will only show the differential expression of the groups. Here is my code that I have been using:

if (require(limma)) 
{
  ##  compare <e.g., 'WT_25u_v_WT_25i' and 'MyD88_25u_v_MyD88_25i'>
  design <- model.matrix(~ 0+factor= c(1,1,2,2,2,2,3,3,4,4,4,5,5,6,6,6,6,7,7,8,8,8,8))
  colnames(design) <- c('MyD88_25u', 'MyD88_25i', 'WT_25u', 'WT_25i', 'MyD88_47u', 'MyD88_47i', 'WT_47u', 'WT_47i')

  fit<-lmFit(selDataMatrix, design)
  # create you comparisons of interest 

  contrast.matrix <- makeContrasts(MyD88_25i-WT_25u,MyD88_25i-MyD88_25u,MyD88_25u-WT_25u, WT_25i-WT_25u,  levels=design)

  fit2u <- contrasts.fit(fit, contrast.matrix)
  fit2u <- eBayes(fit2u)
  # fit2 now contains all your comparisons
  head(fit2$coef)
  ## Add gene symbols to gene properties
  if (require(lumiHumanAll.db) & require(annotate)) 
  {
    geneSymbol <- getSYMBOL(probeList, 'lumiMouseAll.db')
    geneName <- sapply(lookUp(probeList, 'lumiMouseAll.db', 'GENENAME'), function(x) x[1])
    fit2u$genes <- data.frame(ID= probeList, geneSymbol=geneSymbol, geneName=geneName, stringsAsFactors=FALSE)
  }
  print(topTable(fit2u, number = 100, p.value < 0.05))
  mat_data_25 <- data.matrix(fit2u[,2: ncol (fit2u)])
  my_palette <- colorRampPalette(greenred(n=299))
  col_breaks= c(seq(-2,0, length =100),
            seq(0.01,2, length=100))
  heatmap.2(mat_data_25,
            main= "Significant genes at 25 weeks",
            trace= "none",
            dendrogram = "row",
            margins= c(12,9),
            col = my_palette,
            breaks = col_breaks)

Any help would be most appreciated,

Ivonne

R • 2.4k views
ADD COMMENT
0
Entering edit mode
7.9 years ago
TriS ★ 4.7k

how big are the FC for your DEGs?

how does the heatmap look so far?

try hist(mat_data_25) and see how data are distributed, from your breaks it seems that data are centered on 0, if skewed you need to scale them for visualization purposes.

also, if your initial data are in selDataMatrix...I think you should use that for the heatmap

if you are new to R I would suggest to start with a plain simple heatmap.2(myData) and then add all the various colorRampPalette and breaks attributes.

ADD COMMENT
0
Entering edit mode
7.9 years ago
nayeli0126 • 0

My heat map so far

ADD COMMENT
0
Entering edit mode

your breaks are way too wide for being able to see a difference. like try from -1 to +1 also, what are the fold changes of your DEGs, they don't look that different from the heatmap. also #2, use a the "Add comment" to reply to the messages unless you are posting a solution to the initial question :)

ADD REPLY

Login before adding your answer.

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