0
votes

I'm trying to display some data on heatmap in R comparing expression levels across cyclin types & body parts. If you look at the data below you can see that the expression of cyclin A1 in the brain is the same as cyclin A2 in the brain. enter image description here However, when we look at the heatmap they are displayed as different colours. enter image description hereI've tried normalising the data using the scale argument by column (default seems to be row) but that just results in any data without a difference in variance coming out as blank (e.g. brain cyclin A1 & A2 would be displayed as white despite their being expression).

I've attached my code below for a different organism (but the same code was used)- how is it best to fix this?

 #Anolis carelinensis Cyclin A
    #importing data- Anolis carelinensis
    AnolisA<-read.csv(file.choose(),header=TRUE)
    #all data in the matrix must be numerical 
    #therefore I need to remove the left column
    AnolisA2<-AnolisA[-grep('X', colnames(AnolisA))]
    #converting dataframe to a matrix
    AnolisA3<-as.matrix(AnolisA2)
    #builting the heatmap
    heatmap(AnolisA3)
    #remove dendogram and reordering of columns/rows
    #no scale argument applied because we are interested in the variation 
    #between both organs and cyclin types
    heatmap(AnolisA3, Colv=NA, Rowv=NA)
    #adding axis labels
    heatmap(AnolisA3, Colv=NA, Rowv=NA, xlab="Organ", ylab="Cyclin")
    #creating a vector for column names
    rowname<-c("A1","A2")
    #altering labels
    #labRow- change row names
    rownames(AnolisA3)<-rowname
    #cexCol- alters column text size
    heatmap(AnolisA3, Colv=NA, Rowv=NA, xlab="Organ", ylab="Cyclin",cexCol=1,cexRow=1.5,margins=c(11,4))
1

1 Answers

1
votes

You were on the right track with the scale= argument. I think this is what you're looking for with scale="none".

library(tidyverse)
df <- tribble(
  ~brain, ~heart, ~kidney, ~liver, ~skeletal,
  1, 0, 0, 0, 0,
  1, 1, 1, 0, 0
)
mat <- as.matrix(df, nrow = 2, ncol = 5)
rownames(mat) <- c("A1", "A2")
heatmap(mat, Colv=NA, Rowv=NA, xlab="Organ", ylab="Cyclin",
        scale = "none", cexCol=1,cexRow=1.5,margins=c(11,4))

Created on 2019-11-23 by the reprex package (v0.3.0)