Issues marking genes in ComplexHeatmap
1
0
Entering edit mode
13 months ago

Hi,

I was working on marking genes of interest on the heatmap via ComplexHeatmap R package. Instead of specifying row numbers in anno_mark function, I specified a vector of genes to mark on the heatmap (see below) and used a combination of which() and %in% to isolate the row indices that match the gene character vector. It seems like the order of line marking differs compared to row labels (example screenshot below). Please assist how to resolve this issue? Why does the order differ. I am working with 500 diff.exp genes, hence I need to mark atleast 30 genes.

Thank you,

Toufiq

Genes to be marked

genes_to_show <- c("C4orf54", "CCN1", "ADAMTS4", "ARX", "CORO1A", "CMC4", "CDH11", "CCDC102B", "CRYAB", "CCN2")
mark_at = which(rownames(matrix) %in% genes_to_show)
ha = rowAnnotation(foo = anno_mark(at = mark_at, labels = genes_to_show))

Plot

library(ComplexHeatmap)
pdf("Heatmap.pdf",height = 10, width = 7)
Heatmap(matrix, 
        name = "Z-score - log2CPM", 
        col = circlize::colorRamp2(c(-2, 0, 2), c("cyan", "black", "yellow")),
        na_col = "grey",
        cluster_rows = T,
        cluster_columns = F,
        top_annotation = column_ha,
        right_annotation = ha,
        column_split = Sample_metadata$Category,
        row_names_max_width = unit(10,"in"),
        row_title_gp = gpar(fontsize = 15),
        column_title_gp = gpar(fontsize = 20),
        column_names_gp = gpar(fontsize =10),
        row_names_gp = gpar(fontsize =3),
        show_column_names = T)
dev.off()

pheatmap complexheatmap heatmap ggplot2 R • 1.7k views
ADD COMMENT
0
Entering edit mode

I think the issue is that the row clustering is changing the order of the row names from what was defined in your row annotation. Yes, row annotation should change accordingly, but maybe there is some disconnect? That's my best guess any way...

ADD REPLY
0
Entering edit mode

jv thank you for the reply. I did try without row clustering too but the same issue happens. I uncommented column split too, same issue. Not resolved.

ADD REPLY
2
Entering edit mode
13 months ago

I modified rowAnnotation as below, this was resolved.

ha = rowAnnotation(foo = anno_mark(at = which(rownames(my_matrix) %in% genes_to_show),
                                    labels = rownames(my_matrix)[rownames(my_matrix)%in%genes_to_show]))
ADD COMMENT

Login before adding your answer.

Traffic: 2378 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6