text: user285: 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 
  
  
  user3541: 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.
  
original_text: 285: <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.stack.imgur.com/bDJDn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/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.stack.imgur.com/L55LN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L55LN.jpg" alt="heatmap"></a></p>
   3541: <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>
  