Hello,
I relatively new to programming with R and I was wondering if someone could help me in providing suggestions on annotating proteins in a heatmap. Here I have tried the following code, but the heatmap generated is not color coded correctly. I am also unsure how to add multiple annotations to a single protein. E.g. if I wanted to annotate Protein 4 with all 3 paths or with 2 specific paths how could I do this? Any help would be greatly appreciated.
# Read the CSV file
cultureconditions <- read.csv("Sample proteomic data3.csv", row.names = 1)
# These are the names of the columns
new_column_names <- c("condition1", "condition2", "condition3", "condition4")
colnames(cultureconditions) <- new_column_names
#Generate annotation for rows
annotation_row = data.frame(
GenePaths = factor(rep(c("Path1", "Path2", "Path3"), c(17, 5, 18)))
)
#Color code annotations
ann_colors = list(GenePaths = c(Path1 = "#7570B3", Path2 = "#E7298A", Path3 = "#66A61E")
)
# Create the heatmap
# scale=row allows for normalization with z scores
#cluster_cols prevents the columns from clustering
heatmap <- pheatmap(cultureconditions, scale = "row", cluster_row = FALSE, cluster_cols = FALSE, annotation_row = annotation_row,
annotation_colors = ann_colors, angle_col = 45, fontsize = 16)
This is the result I get:
When I run your code with a dummy dataset, it produces a figure as expected with Genepaths colored. There's something with your dataset. Could you post the first 20 rows of your dataset? An easy way to do this is to
deput
like this:dput(cultureconditions[1:20,])
. If you can not post your dataset, then create a dummy one (see pheatmap docs for an example)Thank you for your response! I have attached the code results from the code below.
Appreciate your time in effort in helping me with this!
Thanks for posting the data. See my answer.