Question: Heatmap trouble in R
0
gravatar for Jack
3.0 years ago by
Jack110
Jack110 wrote:

I have a dataset in this format:

id              drug_stat locus   location
5               0          4      755
37133           0         13      755
24086           0          4       41
7               1          4      243
27057           0         13      243
20              1          4      580
21022           1          4      1650

And I want to generate a heat map from it. value1 and value2 are actually the gene's locus type and value2 is location.

my R code for this is the following:

# install libraries
install.packages("gplots")
library(gplots)

# load the dataframe
df <- read.table("data.csv", header = TRUE, sep='\t')
df[df=="n/a"] = NA
df$drug_binary <- ifelse(df$drug_stat == "druggable", 1, 0)
#df[order(df$id_numeric), ]
df_final <- df[c("id_numeric", "drug_binary", "locus_type", "location")]


# change strings to ints for faster read.
df_final$locus_type <- as.numeric(factor(df_final$locus_type))
df_final$location <- as.numeric(factor(df_final$location))

# Plot Heatmap
png(file="plot.png", bg = "transparent")
heat<-heatmap.2(data.matrix(), 
                main = "Sample Heatmap", 
                trace = "none", 
                margin = c(12,30), 
                col = colorRampPalette(c("blue", "yellow", "green")),
                Rowv = NA,
                Colv = NA)

plot(heat)
dev.off()

Question1: Why the binary column is entirely BLUE? It should at least have some GREEN spots in it. Same with the locus.

Question2: Why my plot is not exported as a PNG?

heatmap R • 1.2k views
ADD COMMENTlink modified 3.0 years ago by ssv.bio180 • written 3.0 years ago by Jack110
0
gravatar for Irsan
3.0 years ago by
Irsan7.0k
Amsterdam
Irsan7.0k wrote:

Because it scales the data. Use the scale="none" option

ADD COMMENTlink written 3.0 years ago by Irsan7.0k
0
gravatar for ssv.bio
3.0 years ago by
ssv.bio180
ssv.bio180 wrote:

Q2:Try adding type="cairo", after file name.

ADD COMMENTlink modified 3.0 years ago • written 3.0 years ago by ssv.bio180
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1890 users visited in the last hour