ComplexHeatmap
ComplexHeatmap copied to clipboard
error in rowAnnotation()
Hi: I use this rowAnnotation and got error. not sure how to resolve.
left_annotation3 = rowAnnotation( cell_types=rep(c('Neu', 'Mac','Mono','CMP','DC','B_cell','T','NK'),each = 10),
cell_types_gp=gpar(col = list(cell_type = setNames(brewer.pal(8, "Paired"), unique(colnames(exp_mat))))))
Error: cell_types_gp: annotations should be vector/data frame (only
df
)/matrix/functions.
There is no argument called cell_types_gp
. I guess you want to set colors for cell_type
. Simply use:
left_annotation3 = rowAnnotation( cell_types=rep(c('Neu', 'Mac','Mono','CMP','DC','B_cell','T','NK'),each = 10),
col = list(cell_type = setNames(brewer.pal(8, "Paired"), unique(colnames(exp_mat)))))
left_annotation3 = rowAnnotation( cell_types=rep(c('Neu', 'Mac','Mono','CMP','DC','B_cell','T','NK'),each = 10), col = list(cell_type = setNames(brewer.pal(8, "Paired"), unique(colnames(exp_mat)))))
Hi Zuguang,
Why the Heatmap still plot the rows of my matrix alphabetical order when using the rowAnnotation function? My matrix was already sorted. So, I just want to plot the rows as it is already, but the Heatmap function always alphabetically ordered my rows when plotting.
group1 = rep(c("Bacteroidota", .........), c(67,47,32,25,24,18,14,10,10,9,8,7,7,5,4,3,3,3,3,3,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1))
col_list = list(F = c("Bacteroidota"="#03045e"......))
ha2 = rowAnnotation(F = group1, simple_anno_size = unit(0.3, "cm"), col=col_list)
Best,
Bing
My matrix was already sorted
You don't need to pre-sort your matrix, just keep the matrix and the annotation in the original order. The reordering is applied automatically for both.
So if you do like this:
Heatmap(mat) + rowAnnotation(foo = group1)
this means the first row in mat
corresponds to the first element in group1
. Hierarchical clustering might be applied to the heatmap, and the heatmap and the annotation are reordered automatically and simultaneously (so they might be the third row, but the pairwise relation between the matrix and the annotation are always kept unchanged).