0
$\begingroup$

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 .

figure

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 heatmap

$\endgroup$
  • $\begingroup$ 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 $\endgroup$ – llrs Feb 25 at 10:04
  • 1
    $\begingroup$ okay will do it $\endgroup$ – krushnach Chandra Feb 25 at 16:35
  • $\begingroup$ What exactly are you trying to do? Still don't understand.. $\endgroup$ – h3ab74 Mar 1 at 15:27
  • $\begingroup$ i have expression data and mutation data , i wanted to add the mutaation annotation to for each patient in heatmap as well .. $\endgroup$ – krushnach Chandra Mar 2 at 6:31
  • $\begingroup$ edited the question..i hope now it's bit more clear $\endgroup$ – krushnach Chandra Mar 5 at 6:43
1
$\begingroup$

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.

$\endgroup$
  • 1
    $\begingroup$ i did figure it out after spending some time on complex heat-map documentation $\endgroup$ – krushnach Chandra Sep 10 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.