Hello friends I want to make a heatmap for gene data in R. this is the code:
geneExp <- read.table("file.txt",
header=T, sep="\t")
head(geneExp)
# Extract just the numeric data into a matrix with named rows by gene
rownames(geneExp) <- geneExp$Gene_ID
geneExp_matrix <- as.matrix(geneExp[3:317])
head(geneExp_matrix)
library(ComplexHeatmap)
library(pheatmap)
dev.off()
heatmap(geneExp_matrix,
Rowv=NA, Colv=NA)
# Check if the RColorBrewer library is installed. If not, installs it, then loads it
if (!require("RColorBrewer")) {
install.packages("RColorBrewer", dependencies = TRUE)
library(RColorBrewer)
}
if (!require("gplots")) {
install.packages("gplots", dependencies = TRUE)
library(gplots)
}
dev.off()
if (!require("NMF")) {
install.packages("NMF", dependencies = TRUE)
library(NMF)
}
aheatmap(geneExp_matrix[,3:317], color = rev(brewer.pal(9,"RdBu")), scale="column", "row", annColors = "Set2", annRow=geneExp$type,Colv = NA,Rowv=NA)
I have this error: Error in geneExp_matrix[, 3:317] : subscript out of bounds
can anyone help me with this? Also, is the scaling correct?
rhasanvandj, can you provide some follow-up?