Hi,
I have a data matrix mat
of 622 samples as columns and cell types as rows.
sample annotation:
Samples Group
Sample1 A
Sample2 A
Sample3 A
Sample4 A
Sample5 B
Sample6 B
Sample7 B
Sample8 B
Here I am showing a small example data which looks like below:
Sample1 Sample2 Sample3 Sample4 Sample5 Sample6 Sample7 Sample8
Adipocytes 0 0 0 0 0.003 2.00E-04 0 0
Astrocytes 0 0 0 0.1343 0.1011 0.0562 0.0791 0.0089
B-cells. 0.0095 0.0059 0.0378 0.0016 0 0.0673 0.0361 0.0468
Basophils 0.0091 0.0229 0 0.0864 0 0.069 0.026 0.0994
CD4+ T-cells 0 0 0 0 0 0 0 0
CD4+ Tcm 0 0 0.013 0.0401 0.0053 0 0.0362 0
CD4+ Tem 0 0.0382 0.0268 0.0372 0 0 0.0451 0.0729
CD4+ m T-cells 0.046 0.027 0.0229 0 0.0109 0.0278 0 0.0258
CD4+ n T-cells 0 0 0 0 0 0.0037 0.0196 0
CD8+ T-cells 0.0195 5.00E-04 0.0198 0 0 0.0297 0.0036 0.0646
CD8+ Tcm 0.0108 0 0 0 0 0.0475 0 0.0746
CD8+ Tem 0 0 0 0 0 0.0012 0.0038 0.0483
CD8+ n T-cells 0.0216 0.0027 0.0124 0 0.0055 0.014 0 0.0132
I am using complex heatmap
to generate heatmap showing signatures.
I tried like below, but I have an error:
ann <- data.frame(samples$Group)
colnames(ann) <- c("Type")
colours <- list("Type"=c("A"="orange","B"="darkgreen"))
colAnn <- HeatmapAnnotation(df=ann, which="col", col=colours, annotation_width=unit(c(1, 4), "cm"), gap=unit(1, "mm"))
myCol <- colorRampPalette(c("navyblue", "#002bff"))(100)
myBreaks <- seq(-1,1, length=100)
hmap <- Heatmap(mat, name = "xCell scores", col = colorRamp2(myBreaks, myCol),
width = unit(100, "mm"),show_row_names = TRUE, show_column_names = FALSE, cluster_rows = FALSE,
cluster_columns = FALSE, show_column_dend = FALSE, show_row_dend = FALSE,
row_dend_reorder = FALSE, column_dend_reorder = FALSE)
draw(hmap, heatmap_legend_side="left", annotation_legend_side="right")
The Error I got:
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
I want to plot to be looked like this which is from Figure 2a in this paper
Any help is appreciated. thanq
draw
specifies anannotation_legend_side
, but you don't have any annotations. What's going on there?cluster_rows=FALSE
andclustering_method_rows="ward.D2"
: Why do you have a clustering method when clustering is disabled?sorry that was a mistake. there is no
annotation_legend_side
I removed that in question.What are the output to
dim(mat)
andclass(mat)
? Can you also paste the output ofsessionInfo()
?Switch to github latest version of ComplexHeatmap:
devtools::install_github('jokergoo/ComplexHeatmap')
. If already installed through github, please usedevtools::update_packages()
and pick the number displayed against ComplexHeatmap. It's a rapidly evolving package and you are quite a few versions behind.sure I will. But may I know something about the error and how to make a plot like above please
Try updating and see if the error persists. If it does and the error is the same, we can work on figuring out what's happening.
Yes, I did that and I see the same error again.
Can you check your
sessionInfo()
to be sure you're using ComplexHeatmap v 2.1.0? Your matrix looks fine, you should not be seeing this error.If you're using the right version, try this:
Also, try modifying the
100
in thecolorRampPalette(c("navyblue", "#002bff"))(100)
to42000
.sorry, there is no change in the error. And in my question I also added the sample annotation now and will be using
annotation_legend_side
argument now.The error still says same.