<p>You are trying to "map" mutation data to your heatmap, however, there is no mutation data in your code as far as I can see! You specify sample names within a data frame called <code>anno</code> but this data frame has only one column, <code>Condition</code>. All you have to do is add another column, <code>mutation</code>, to the <code>anno</code> data frame. Moreover, you have to pay attention to the order of your data and your meta data. The rownames of the meta data (<code>anno</code> data frame in your case) should be the same as the colnames of your gene expression data frame.</p>

<p>I also see that you create a row annotation object <code>RowAnn</code>, which is not used in the <code>Heatmap()</code> call. Similarly, there is a <code>categories</code> data frame which is not used either. Your code would be easier to read without these unused variables.</p>

CC BY-SA 4.0
2019-09-10T09:50:45.140Z
i did figure it out after spending some time on complex heat-map documentation
kcm
CC BY-SA 4.0
2019-09-09T14:08:24.170Z
2019-09-09T14:08:24.170Z
haci
<p>I have mutation data of patients.How do i add that mutation info or annotate those as column with my annotation information <a href="https://drive.google.com/open?id=1T-zSJ4pOYf7rB5Hoe6-fHzj6c54t6d5h" rel="nofollow noreferrer">expression</a> and <a href="https://drive.google.com/open?id=1TE55ORXGg_QEdlLp5GSyY-6_jirtt4cj" rel="nofollow noreferrer">mutation</a></p>

<p>To help myself i did try this <a href="http://jokergoo.github.io/supplementary/ComplexHeatmap-supplementary1-4/supplS4_GBM_450K/supplS4_gbm_450K.html" rel="nofollow noreferrer">Zuguang Gu</a> but couldn;t able to do it, i would like similar to the one to show patient mutations .
any help or suggestion would be highly appreciated .</p>

<p>I wanted something like this , as here they annotated with batch ,type and cell clone. I would like to have something similar where i would like to see how mutation in patients affects expression profile .</p>

<p><a href="https://i.sstatic.net/bDJDn.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/bDJDn.jpg" alt="figure"></a></p>

<pre><code>df &lt;- read.csv("HSC_pHSC_LSC_data/heatma_cluster.txt",header = TRUE,sep = ",")
        head(df)
        tail(df)
        dim(df)
        heat &lt;- t(scale(t(df[,3:ncol(df)])))

        head(heat)

        rownames(heat) &lt;- df<span class="math-container">$Gene
        ColAnn &lt;- data.frame(colnames(heat))
        Sample = c(rep("HSC",4),rep("pHSC",12),rep("LSC",8))
        anno &lt;- as.data.frame(Sample)
        categories &lt;- data.frame(anno)
        colnames(anno) &lt;- c("Condition")
        ColAnn &lt;- HeatmapAnnotation(df=anno,which="col", col=list(Condition=c("HSC"="black","pHSC"="red","LSC"="dodgerblue4")))
        RowAnn &lt;- data.frame(df$</span>Family)
        colnames(RowAnn) &lt;- c("Gene family")
        colours &lt;- list("Gene family"=c("Cluster_one"="red","Cluster_two"="blue","Cluster_three"="brown","Cluster_four"="yellow",
                                       "Cluster_five"="green","Cluster_six"="maroon","Cluster_seven"="pink","Cluster_eight"="navyblue",
                                       "Cluster_nine"="darkgrey","Cluster_ten"="violet"))



        RowAnn &lt;- HeatmapAnnotation(df=RowAnn, col=colours, which="row")
        boxAnnCol &lt;- HeatmapAnnotation(boxplot=anno_boxplot(heat, border=TRUE, gp=gpar(fill="#CCCCCC"), 
                                                            pch=".", size=unit(2, "mm"), 
                                                            axis=TRUE,  axis_param = list(side = "left")), 
                                       annotation_width=unit(c(1, 6.5), "cm"))

        boxAnnRow &lt;- rowAnnotation(boxplot=row_anno_boxplot(heat, border=TRUE, gp=gpar(fill="#CCCCCC"),pch=".",
                                                            size=unit(3, "cm"), axis=TRUE, axis_param = list(side = "bottom")),
                                   annotation_width=unit(c(3), "cm"))
        pdf("ALL1_CLUSTER_DISEASE.pdf",width = 10, height = 20)
        #png("HSC_CMP_DIFF_HEATMAP.png", units="in", width=20, height=10, res=100)

        #dev.off()

        myCol &lt;- colorRampPalette(c("navyblue", "white", "red"))(100)
        myBreaks &lt;- seq(-2, 2, length.out=100)
        hmap &lt;- Heatmap(heat,
                        name="Z-score",
                        col=colorRamp2(myBreaks, myCol),
                        heatmap_legend_param=list(color_bar="continuous", 
                                                  legend_direction="vertical", legend_width=unit(5,"cm"),
                                                  title_position="topcenter", title_gp=gpar(fontsize=10, fontface="bold")),

                        #Split heatmap rows by gene family
                        split=df$Family,
                        #split = NULL,

                        #Row annotation configurations
                        cluster_rows=TRUE,
                        show_row_dend=FALSE,
                        row_dend_side = "left",
                        #row_title="Transcript", #overridden by 'split' it seems
                        row_title_side="left",
                        row_title_gp=gpar(fontsize=8,fontface="bold"),
                        row_names_gp = gpar(fontsize = 8),
                        show_row_names=TRUE,
                        row_names_side="right",
                        row_title_rot=0,

                        #Column annotation configuratiions
                        cluster_columns=TRUE,
                        show_column_dend=TRUE,
                        column_title="Samples",
                        column_title_side="top",
                        column_title_gp=gpar(fontsize=10, fontface="bold"),
                        column_title_rot=0,
                        column_names_gp = gpar(fontsize = 20, fontface="bold"),
                        show_column_names=TRUE,

                        #Dendrogram configurations: columns
                        clustering_distance_columns="euclidean",
                        clustering_method_columns="complete",
                        column_dend_height=unit(10,"mm"),

                        #Dendrogram configurations: rows
                        clustering_distance_rows="euclidean",
                        clustering_method_rows="complete",
                        row_dend_width=unit(15,"mm"),

                        #top_annotation_height=unit(0.5,"cm"),
                        top_annotation=ColAnn,

                        #bottom_annotation_height=unit(2, "cm"),
                        bottom_annotation=boxAnnCol)
        hmap + RowAnn

        dev.off()
</code></pre>

<p>The image i get after running the code is something like this sample numbers vary, as i have only HSC ,pHSC and LSC samples 
<a href="https://i.sstatic.net/L55LN.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/L55LN.jpg" alt="heatmap"></a></p>

CC BY-SA 4.0
2019-02-25T10:04:50.643Z
Hi, could you please [edit] the question to fix the punctuation (commas before space, n't instead of n;t and move i to I) and the code indentation? It will be easier to read. Also could you please add the final image and a description of what do you want to change? Without seeing it and having your data is hard to guess how we can help
llrs
CC BY-SA 4.0
2019-02-25T16:35:48.430Z
okay will do it
kcm
CC BY-SA 4.0
2019-03-01T15:27:22.483Z
What exactly are you trying to do? Still don't understand..
h3ab74
CC BY-SA 4.0
2019-03-02T06:31:29.963Z
i have expression data and mutation data , i wanted to add the mutaation annotation to for each patient in heatmap as well ..
kcm
CC BY-SA 4.0
2019-03-05T06:43:56.577Z
edited the question..i hope now it's bit more clear
kcm
CC BY-SA 4.0
2019-03-05T08:33:20.850Z
Could you please add the image you get after all this code?
llrs
CC BY-SA 4.0
2019-03-05T09:37:14.917Z
okay...i will .its a normal heatmap using complex heatmap what i get..i will be posting it..
kcm
CC BY-SA 4.0
2019-03-06T10:32:02.420Z
I assume that the x-axis is patient and the Y-axis is the gene?  The results sort of look clear, but threading together patients and "batch type cell clone" as well as "HSC ,pHSC and LSC" is a mystery to me.  I assume someone here understands this.
M__
CC BY-SA 4.0
2019-03-07T05:11:44.067Z
no i don;t have batch type cell close, instead i have mutation data ..yes x and y axis are patient and gene . HSC is stem cell ,pHSC is patient stem cell and LSC is leukemic stem cell.
kcm
<r><visualization>
Mutation annotation to the heatmap
# Mutation annotation to the heatmap

(Asked by: username_0 on 2019-02-24)

I have mutation data of patients.How do i add that mutation info or annotate those as column with my annotation information expression and mutation
To help myself i did try this Zuguang Gu but couldn;t able to do it, i would like similar to the one to show patient mutations .
any help or suggestion would be highly appreciated .
I wanted something like this , as here they annotated with batch ,type and cell clone. I would like to have something similar where i would like to see how mutation in patients affects expression profile .

df <- read.csv("HSC_pHSC_LSC_data/heatma_cluster.txt",header = TRUE,sep = ",")
        head(df)
        tail(df)
        dim(df)
        heat <- t(scale(t(df[,3:ncol(df)])))

        head(heat)

        rownames(heat) <- df$Gene
        ColAnn <- data.frame(colnames(heat))
        Sample = c(rep("HSC",4),rep("pHSC",12),rep("LSC",8))
        anno <- as.data.frame(Sample)
        categories <- data.frame(anno)
        colnames(anno) <- c("Condition")
        ColAnn <- HeatmapAnnotation(df=anno,which="col", col=list(Condition=c("HSC"="black","pHSC"="red","LSC"="dodgerblue4")))
        RowAnn <- data.frame(df$Family)
        colnames(RowAnn) <- c("Gene family")
        colours <- list("Gene family"=c("Cluster_one"="red","Cluster_two"="blue","Cluster_three"="brown","Cluster_four"="yellow",
                                       "Cluster_five"="green","Cluster_six"="maroon","Cluster_seven"="pink","Cluster_eight"="navyblue",
                                       "Cluster_nine"="darkgrey","Cluster_ten"="violet"))



        RowAnn <- HeatmapAnnotation(df=RowAnn, col=colours, which="row")
        boxAnnCol <- HeatmapAnnotation(boxplot=anno_boxplot(heat, border=TRUE, gp=gpar(fill="#CCCCCC"), 
                                                            pch=".", size=unit(2, "mm"), 
                                                            axis=TRUE,  axis_param = list(side = "left")), 
                                       annotation_width=unit(c(1, 6.5), "cm"))

        boxAnnRow <- rowAnnotation(boxplot=row_anno_boxplot(heat, border=TRUE, gp=gpar(fill="#CCCCCC"),pch=".",
                                                            size=unit(3, "cm"), axis=TRUE, axis_param = list(side = "bottom")),
                                   annotation_width=unit(c(3), "cm"))
        pdf("ALL1_CLUSTER_DISEASE.pdf",width = 10, height = 20)
        #png("HSC_CMP_DIFF_HEATMAP.png", units="in", width=20, height=10, res=100)

        #dev.off()

        myCol <- colorRampPalette(c("navyblue", "white", "red"))(100)
        myBreaks <- seq(-2, 2, length.out=100)
        hmap <- Heatmap(heat,
                        name="Z-score",
                        col=colorRamp2(myBreaks, myCol),
                        heatmap_legend_param=list(color_bar="continuous", 
                                                  legend_direction="vertical", legend_width=unit(5,"cm"),
                                                  title_position="topcenter", title_gp=gpar(fontsize=10, fontface="bold")),

                        #Split heatmap rows by gene family
                        split=df$Family,
                        #split = NULL,

                        #Row annotation configurations
                        cluster_rows=TRUE,
                        show_row_dend=FALSE,
                        row_dend_side = "left",
                        #row_title="Transcript", #overridden by 'split' it seems
                        row_title_side="left",
                        row_title_gp=gpar(fontsize=8,fontface="bold"),
                        row_names_gp = gpar(fontsize = 8),
                        show_row_names=TRUE,
                        row_names_side="right",
                        row_title_rot=0,

                        #Column annotation configuratiions
                        cluster_columns=TRUE,
                        show_column_dend=TRUE,
                        column_title="Samples",
                        column_title_side="top",
                        column_title_gp=gpar(fontsize=10, fontface="bold"),
                        column_title_rot=0,
                        column_names_gp = gpar(fontsize = 20, fontface="bold"),
                        show_column_names=TRUE,

                        #Dendrogram configurations: columns
                        clustering_distance_columns="euclidean",
                        clustering_method_columns="complete",
                        column_dend_height=unit(10,"mm"),

                        #Dendrogram configurations: rows
                        clustering_distance_rows="euclidean",
                        clustering_method_rows="complete",
                        row_dend_width=unit(15,"mm"),

                        #top_annotation_height=unit(0.5,"cm"),
                        top_annotation=ColAnn,

                        #bottom_annotation_height=unit(2, "cm"),
                        bottom_annotation=boxAnnCol)
        hmap + RowAnn

        dev.off()

The image i get after running the code is something like this sample numbers vary, as i have only HSC ,pHSC and LSC samples

**Tags:** r, visualization
> **Comments:**
> **username_1**: Hi, could you please [edit] the question to fix the punctuation (commas before space, n't instead of n;t and move i to I) and the code indentation? It will be easier to read. Also could you please add the final image and a description of what do you want to change? Without seeing it and having your data is hard to guess how we can help  
> **username_0**: okay will do it  
> **username_2**: What exactly are you trying to do? Still don't understand..  
> **username_0**: i have expression data and mutation data , i wanted to add the mutaation annotation to for each patient in heatmap as well ..  
> **username_0**: edited the question..i hope now it's bit more clear  
> **username_1**: Could you please add the image you get after all this code?  
> **username_0**: okay...i will .its a normal heatmap using complex heatmap what i get..i will be posting it..  
> **username_3**: I assume that the x-axis is patient and the Y-axis is the gene?  The results sort of look clear, but threading together patients and "batch type cell clone" as well as "HSC ,pHSC and LSC" is a mystery to me.  I assume someone here understands this.  
> **username_0**: no i don;t have batch type cell close, instead i have mutation data ..yes x and y axis are patient and gene . HSC is stem cell ,pHSC is patient stem cell and LSC is leukemic stem cell.  

---

## 1 answers

### Answer by username_4 on 2019-09-09. Score: 1 | Accepted answer

You are trying to "map" mutation data to your heatmap, however, there is no mutation data in your code as far as I can see! You specify sample names within a data frame called `anno` but this data frame has only one column, `Condition`. All you have to do is add another column, `mutation`, to the `anno` data frame. Moreover, you have to pay attention to the order of your data and your meta data. The rownames of the meta data (`anno` data frame in your case) should be the same as the colnames of your gene expression data frame.

I also see that you create a row annotation object `RowAnn`, which is not used in the `Heatmap()` call. Similarly, there is a `categories` data frame which is not used either. Your code would be easier to read without these unused variables.

> **Comments:**
> **username_0**: i did figure it out after spending some time on complex heat-map documentation  

---

