Entering edit mode
8.2 years ago
Jack
▴
120
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?