labels_mat error in ComplexHeatmap
1
0
Entering edit mode
4.6 years ago

Hi everyone,

I am having an issue with an R script that was given to me and I was wondering if anyone can tell me how to fix this? Let me know if you need any other ouput to help figure this out.

 > library(ComplexHeatmap)

Loading required package: grid
========================================
ComplexHeatmap version 2.2.0
Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/
Github page: https://github.com/jokergoo/ComplexHeatmap
Documentation: http://jokergoo.github.io/ComplexHeatmap-reference

If you use it in published research, please cite:
Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
  genomic data. Bioinformatics 2016.
========================================l 

> library(circlize)
========================================
circlize version 0.4.8
CRAN page: https://cran.r-project.org/package=circlize
Github page: https://github.com/jokergoo/circlize
Documentation: http://jokergoo.github.io/circlize_book/book/

If you use it in published research, please cite:
Gu, Z. circlize implements and enhances circular visualization 
  in R. Bioinformatics 2014.
========================================

> pal_atac <- colorRampPalette(c('#3361A5',
+                                '#248AF3',
+                                '#14B3FF',
+                                '#88CEEF',
+                                '#C1D5DC',
+                                '#EAD397',
+                                '#FDB31A',
+                                '#E42A2A',
+                                '#A31D1D'))(100)
> ha = HeatmapAnnotation(df = data.frame("Group" = esca.rse$primary_diagnosis, 
+                                        "Replicate" = stringr::str_match(colnames(esca.rse),"rep[0-9]?")),
+                        show_annotation_name = T,
+                        col = list(Group = c("Squamous cell carcinoma, NOS" =  "red", 
+                                             "Adenocarcinoma, NOS" = "blue")),
+                        show_legend = T,
+                        annotation_name_side = "left",
+                        annotation_name_gp = gpar(fontsize = 6))
> 
> plot.atac <- assay(esca.rse)[result$FDR < fdr.cut.off & abs(result$ESCC_minus_ESAD) > diff.cut.off,]
> col <- colorRamp2(seq(min(plot.atac), max(plot.atac), 
+                       by = (max(plot.atac) - min(plot.atac))/99), pal_atac)
> rows.annot <- rowAnnotation(foo = anno_mark(at = c(1,18), labels = rownames(plot.atac)[c(1,18)]))
> ht_list <- 
+     Heatmap(plot.atac,
+             name = "ATAC-seq log2(counts)", 
+             col = col,
+             column_names_gp = gpar(fontsize = 8),
+             show_column_names = F,
+             heatmap_legend_param = list(legend_direction = "horizontal",
+                                         labels_gp = gpar(fontsize = 12), 
+                                         title_gp = gpar(fontsize = 12)),
+             show_row_names = FALSE,
+             cluster_columns = TRUE,
+             use_raster = TRUE,
+             raster_device = c("png"),
+             raster_quality = 2,
+             cluster_rows = T,
+             right_annotation = rows.annot,
+             row_title = paste0(sum(result$FDR < fdr.cut.off & 
+                                        abs(result$ESCC_minus_ESAD) > diff.cut.off),
+                                " ATAC-seq peaks"),
+             row_names_gp = gpar(fontsize = 4),
+             top_annotation = ha,
+             column_title_gp = gpar(fontsize = 12), 
+             row_title_gp = gpar(fontsize = 12)) 
> 
> options(repr.plot.width = 15, repr.plot.height=8)

> draw(ht_list,newpage = TRUE, 
+      column_title = paste0("ATAC-seq ESCC vs ESAD (FDR < ", fdr.cut.off,
+                            ",  Diff mean log2 Count > ",diff.cut.off,")"),
+      column_title_gp = gpar(fontsize = 12, fontface = "bold"),
+      heatmap_legend_side = "bottom",
+      annotation_legend_side = "right")

Produced the following error:

Error in labels_mat[, i] : subscript out of bounds
In addition: Warning message:
In matrix(1:(nrow * ncol), nrow = nrow, ncol = ncol, byrow = by_row) :
  data length exceeds size of matrix

Thanks in advance for any help!

Best,

EtBr

R ComplexHeatmap • 4.1k views
ADD COMMENT
2
Entering edit mode
4.6 years ago

I think that it basically means that your annotation is out of sync with your input data matrix. So, you need to follow up on that.

ADD COMMENT
0
Entering edit mode

Sorry for the late response. Any suggestions on how to going about doing this? Sorry, new to R and I can't get a response from the authour of the script.

ADD REPLY
1
Entering edit mode

Hello again, essentially, the first place to look would be to ensure that the rows of df (created in HeatmapAnnotation()) match the columns of the plot.atac data matrix in both order order and length.

ADD REPLY

Login before adding your answer.

Traffic: 1891 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