Entering edit mode
20 months ago
TJay
•
0
I have a dataset with following format.
X M1. M2. ... new_cell_type
cac1. 1.5 1 ... T
cac2. 1.4 1.4 ... M
cac3. 0.5 1.1 ... T
cac4. 0.1 1 ... N
I want to plot a heatmap based on the above data where rows of the heatmap as cells with cell grouping(with cell_type) and columns as M1,M2,M3... I tried to split the cells with cell type pass that as a matrix to plot heatmap using ComplexHeatmap. But it doesn't work. Any suggestions for this?
data_c <- read.csv('./output/a.csv')
cell_type <- read.csv(file = 'b.csv')
merged_data <- merge(data_c, cell_type,by = "X")
df_list <- split(merged_data, merged_data$new_cell_type)
df_list <- as.matrix(df_list)
heat_col <- colorRamp2(c(0, 0.5, 1), c("blue", "white", "red"))
hm <- Heatmap( df_list,
col = heat_col,
row_split = merged_data$new_cell_type,
show_row_names = TRUE,
cluster_rows = TRUE,
cluster_columns = TRUE,
)
draw(hm)
I'm expecting this kind of heatmap where rows should be cells and left bar is representing celltype. columns should be M1,M2,M3, etc.
Instead of splitting your dataset you want to make an annotation object via
rowAnnotation
and then pass it to theleft_annotation
argument.Any guidance to make annotation object?
This is all detailed in the vignettes for ComplexHeatmap. You should read through them first and come back with any specific questions you may still have afterwards.
Yes. I went through that and changed my code as following. Still it's not giving the correct output.
First, set
show_row_names = FALSE
. You might want to play around with thecol = col_fun
portion of the vignette to change your scale to be something that more closely represents your data.