Fix dataframe retrieval from loaded_variables
Fix dataframe retrieval from loaded_variables

thehyve/heim-SmartR,thehyve/naa-SmartR,thehyve/naa-SmartR,agapow/smartr,agapow/smartr,thehyve/heim-SmartR,thehyve/heim-SmartR,thehyve/naa-SmartR,agapow/smartr
library(gplots)

dataset <- loaded_variables[[1]] #dataframe with columns: Row.Label, Bio.marker, ASSAY_0001 ASSAY_0002 ...

measurements  <- subset(dataset,select=-c(Row.Label,Bio.marker)) # this will select all columns other than Probe and Biomarker columns
measurements  <- data.matrix(measurements)

measurements <- log(measurements,2)

rownames(measurements) <- df$Row.Label



png(filename="heatmap.png",width = 800,height=800)
heatmap.2(measurements,
          scale = "none",
          dendrogram = "none",
          Rowv = NA,
          Colv = NA,
          density.info = "none", # histogram", # density.info=c("histogram","density","none")
          trace = "none",
          col=redgreen(75),
          margins=c(12,12)
          #ColSideColors= as.character(groups)
          #adjCol=c("left","top")
)
dev.off()

#global_register <-list(rowNames = c("a","b"),
#                       columnNames = c("1","2"),
#                       origin = c(1,2),
#                       data = matrix(c(35,700),nrow=2,ncol=2)
#                       )

library(gplots)
# This script expects global_register to be populated before execution
# see lines above for an example
data.row.names <- global_register["rowNames"][[1]]
data.col.names <- global_register["columnNames"][[1]]
data.origin <- global_register["origin"][[1]]
data.matrix <- global_register["data"][[1]]

rownames(data.matrix) <- unlist(data.row.names)
colnames(data.matrix) <- unlist(data.col.names)

#For now we assume only 2 groups. 1 and 2
color.groups <- function(x){
  if(x == 1){
    return("coral3") # R color
  }else{
    return("chartreuse3")
  }
}

groups <- lapply(data.origin, color.groups)
groups <- unlist(groups)

png(filename="heatmap.png",width = 800,height=800)
heatmap.2(data.matrix,
          scale = "none",
          dendrogram = "none",
          Rowv = NA,
          Colv = NA,
          density.info = "none", # histogram", # density.info=c("histogram","density","none")
          trace = "none",
          col=redgreen(75),
          margins=c(12,12),
          ColSideColors= as.character(groups)
          #adjCol=c("left","top")
)
dev.off()
