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