2
$\begingroup$

After i updated my complexheatmap library i can;t use my old annotation to label sample this is the image how i used to get something like this with family and sample annotation

Code for the below image

require(ComplexHeatmap)
require(circlize)
require(cluster)
df <- read.csv("heatmap_folder/NORMAL_EPI_TF1.txt",header = TRUE,sep = "\t")

head(df)
tail(df)
dim(df)
heat <- t(scale(t(df[,3:ncol(df)])))
head(heat)

rownames(heat) <- df$Gene
Sample = c(rep("HSC",4),rep("CMP",4),rep("GMP",4),rep("Mono",4))

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","CMP"="brown",
                                                                       "GMP"="maroon1","Mono" = "darkgreen")))
RowAnn <- data.frame(df$Family)
colnames(RowAnn) <- c("Gene family")
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_side=NULL, axis_gp=gpar(fontsize=10)), 
                               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_side="top", axis_gp=gpar(fontsize=12)),
                           annotation_width=unit(c(3), "cm"))



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=FALSE,
                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

The code remains the except the data

Now not sure may be im messing up the annotation so that i can;t see sample label and the family annotation

Since this was the error

"Error: axis_gp is removed from the arguments. Use axis_param = list(gp = ...) instead." which i modified a bit

Then i modified my code to this

RowAnn <- data.frame(df$Family)
colnames(RowAnn) <- c("Gene family")
RowAnn <- HeatmapAnnotation(df=RowAnn, col=colours, which="row")

ColAnn <- HeatmapAnnotation(df=anno, which="col", col=list(Condition=c("HSC"="black","CMP"="brown",
                                                                       "GMP"="maroon1","Mono" = "darkgreen")))

boxplotCol <- 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, 5.0), "cm"), which="col")
)

hmap <- Heatmap(heat, name = "expression",col=colorRamp2(myBreaks, myCol),
                split=df$Family,
                #split = NULL,

                show_row_names = TRUE, show_column_names = TRUE, cluster_rows = TRUE,
                cluster_columns = TRUE, show_column_dend = TRUE, show_row_dend = TRUE,
                row_dend_reorder = TRUE, column_dend_reorder = TRUE, clustering_method_rows = "ward.D2",
                clustering_method_columns = "ward.D2", width = unit(100, "mm"),

                #top_annotation_height=unit(1.0,"cm"), top_annotation=colAnn,

                bottom_annotation=boxplotCol)

draw(hmap+RowAnn, heatmap_legend_side="left", annotation_legend_side="right")

my fignew

I would be glad to know what im doing wrong as i can;t she condition getting annotated

my data

dput(df)
structure(list(Family = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("EPI", 
"TF"), class = "factor"), Gene = structure(c(31L, 23L, 32L, 40L, 
26L, 34L, 14L, 17L, 39L, 21L, 15L, 30L, 9L, 1L, 33L, 2L, 5L, 
11L, 18L, 16L, 7L, 27L, 8L, 19L, 22L, 12L, 24L, 36L, 6L, 20L, 
28L, 41L, 43L, 44L, 45L, 47L, 48L, 49L, 50L, 13L, 17L, 38L, 42L, 
21L, 25L, 35L, 37L, 10L, 11L, 4L, 46L, 3L, 29L), .Label = c("BABAM1", 
"BAP1", "BRF2", "CASZ1", "CBX8", "CCDC17", "CEBPA", "CUX2", "DAPK3", 
"DEAF1", "DOT1L", "EBF1", "ERF", "HCFC1", "HDAC7", "HES6", "HMG20B", 
"INO80E", "IRF8", "KLF16", "MBD3", "MEF2D", "MTA3", "MXD4", "PIN1", 
"PIWIL4", "PREB", "REPIN1", "RFX2", "SETD1A", "SFMBT1", "SFMBT2", 
"SMARCA4", "SMYD2", "SNAPC4", "SREBF2", "TCF20", "TCF7", "TFPT", 
"UBE2A", "ZBTB17", "ZFHX2", "ZNF142", "ZNF319", "ZNF414", "ZNF446", 
"ZNF469", "ZNF581", "ZNF646", "ZNF76"), class = "factor"), HSC1 = c(1.38256100990102, 
6.03508433561645, 8.53718694596963, 9.7579, 4.9089643439748, 
6.08652168925513, 10.85362, 5.791612, 4.717658, 5.034092, 7.6573073927514, 
8.214206, 6.087519, 7.795752, 9.147491, 9.16065391580272, 5.475244, 
6.839048, 4.307532, 0.4008883181761, 3.681525, 5.39357937244362, 
0.048702874829245, 4.884674, 9.42704096616912, 0.331449426359954, 
8.70131868583511, 9.860997, 5.96926894038996, 5.122815, 9.84364182958174, 
4.99646644487682, 8.64613509396529, 6.221252, 4.788327, 4.221885, 
6.904238, 7.027222, 6.90290115677703, 5.910114, 5.791612, 7.85232611449929, 
4.30633834185685, 5.034092, 6.587824, 3.77111448331312, 4.816565, 
5.83621984608683, 6.839048, 5.38002542796833, 2.499083, 4.07296733289583, 
7.384605), HSC2 = c(3.3250440950498, 5.69710569315867, 7.53535864842004, 
9.46294, 4.63015366085456, 6.27268560573257, 10.61808, 5.936903, 
5.754081, 5.17955, 7.34546746135814, 8.156995, 4.959736, 7.1724, 
9.519366, 8.399964626033, 3.79417, 6.580323, 3.006501, 0.465543296427136, 
3.854056, 6.19801925234426, 1.35661238539194, 2.520579, 10.1179535946398, 
0.438637606305892, 8.02299949380521, 9.599955, 5.14592215971399, 
5.362818, 9.62067506274524, 5.81177950264385, 8.6388082408386, 
6.580456, 5.507812, 4.647564, 5.933962, 7.036506, 6.61438422233323, 
7.081847, 5.936903, 7.25061985280206, 6.14119015507351, 5.17955, 
5.51992, 4.7980903060972, 4.688224, 5.75480261400296, 6.580323, 
4.61480421865767, 2.473632, 2.58901029457056, 7.141953), HSC3 = c(4.5609308176212, 
6.31335736623603, 8.08532370258223, 9.954938, 5.33971874563167, 
6.31519305036765, 8.686445, 3.652774, 1.705097, 3.590782, 5.82598582988908, 
7.160368, 2.730684, 6.544555, 8.308113, 7.28529068473834, 2.181592, 
6.153712, 3.769699, 0.686412239668329, 3.181293, 5.81660138585872, 
0.513314099277583, 3.807037, 9.40253894125251, 0.789263521770297, 
6.25643885795079, 8.4667, 3.59885151800005, 1.959458, 8.16946518123644, 
3.78892554507724, 8.17931637873862, 6.871673, 2.207662, 2.586419, 
4.611411, 6.342816, 6.24601538582422, 4.504617, 3.652774, 6.1448035804027, 
4.32474896196878, 3.590782, 4.283432, 3.97377694799887, 5.081613, 
4.67353303760197, 6.153712, 2.95856351440761, 1.797669, 2.61144324906345, 
6.927889), HSC4 = c(4.33336593087016, 5.51218211320577, 7.98927439884575, 
10.02818, 4.72376095157983, 7.06408657043682, 10.6532, 6.332262, 
4.356266, 5.063746, 7.40605558817077, 7.943625, 4.577773, 7.114057, 
10.10959, 8.39439253099313, 0.843862, 7.275198, 3.125764, 0.461081947661647, 
4.914624, 6.47822557945205, 0.151047922603591, 4.233378, 9.76778876120242, 
1.52153581933298, 7.74186897540428, 9.848883, 4.27034862337376, 
5.461201, 9.20573611283668, 5.57160015049504, 8.90499660789483, 
5.972766, 4.37926, 4.914465, 6.288035, 6.667292, 6.48347655570048, 
6.525983, 6.332262, 6.67910931337338, 5.93921207229708, 5.063746, 
5.391649, 5.14382963917955, 3.682687, 6.17864627473077, 7.275198, 
4.55820389425563, 2.464959, 3.36552973589941, 7.155267), CMP1 = c(6.87345497292835, 
5.51412758368083, 7.31352446967914, 10.55862, 6.25444074607741, 
7.17818981714724, 11.09789, 6.353011, 4.176257, 5.988031, 8.45885235860671, 
8.239023, 4.831419, 8.439534, 9.741489, 9.12973766558991, 1.63498, 
7.616455, 4.40003, 3.35836219130892, 6.782445, 8.09320436383016, 
0.034087182831375, 7.328077, 10.1348328626404, 3.77197918672699, 
8.22105235434344, 9.586611, 3.96736165755976, 6.120908, 9.66405823977144, 
5.5410623284247, 7.98439042490943, 5.617969, 4.389489, 3.320773, 
7.259381, 6.342179, 7.80157963446663, 6.00359, 6.353011, 4.88520066048698, 
4.57336386910792, 5.988031, 7.534274, 4.22034258843835, 4.407149, 
6.04554630191099, 7.616455, 5.5286242078284, 2.938658, 6.05835585199437, 
7.254343), CMP2 = c(4.57632794651802, 3.78653056181795, 7.38323687896953, 
10.18887, 5.42618113653324, 7.14753074148422, 11.10573, 6.444083, 
5.364945, 5.56755, 7.87006213457315, 8.183806, 5.547153, 7.408484, 
10.41511, 8.5734105703595, 3.332623, 7.927959, 3.044397, 2.23975823913519, 
5.948004, 6.8523382099618, -0.208208601046198, 2.502613, 9.61958525630466, 
0.083082776643226, 7.96816766770755, 9.658819, 4.28029266262047, 
6.064432, 9.51407062066367, 6.0002887227803, 8.84860518364821, 
6.63929, 5.418921, 4.246354, 6.265858, 6.726515, 6.59033513636581, 
6.599091, 6.444083, 6.42468503826279, 5.39157032731654, 5.56755, 
5.975197, 5.49143188875569, 4.882971, 6.3269787223519, 7.927959, 
4.52014312274917, 3.02202, 3.32107044636493, 7.234948), CMP3 = c(5.85154481845215, 
4.70657054545281, 7.81269743162002, 10.51041, 6.02525567584962, 
7.6061510389796, 8.938033, 4.185122, 3.453336, 4.250061, 6.95084523398581, 
7.016165, 3.711631, 6.691113, 9.291314, 6.79870749458327, 2.556527, 
6.640901, 2.472737, 0.713500223112626, 4.610029, 7.09501723097758, 
0.554991742557483, 3.663828, 8.64957961123419, 0.830920666997163, 
5.03120897448563, 8.193863, 3.66385830275847, 2.514419, 8.57920717695102, 
3.68106350062846, 7.99067978896729, 4.917504, 1.705394, 2.940584, 
4.935565, 4.679952, 5.45403468978382, 4.097788, 4.185122, 4.7017134210513, 
3.36996680968093, 4.250061, 4.841303, 4.16528140537129, 4.311709, 
4.34280333979994, 6.640901, 3.46696931369128, 1.836416, 1.2954688478789, 
6.759544), CMP4 = c(5.70607301130076, 4.90995364796149, 8.07668148492955, 
10.49127, 6.12272998130959, 8.1070578791571, 11.14272, 6.069435, 
3.77716, 5.905144, 7.80284615350651, 8.193236, 5.266133, 7.994962, 
10.62971, 8.76622729912917, 1.728943, 8.018743, 2.64787, 3.17362412630739, 
6.675791, 8.17425862958478, 1.3062705649262, 8.305058, 9.60100662458438, 
3.64083547966437, 7.03151917955059, 9.697494, 4.22387311586196, 
5.872986, 9.48040032459999, 5.9054376735385, 9.0993222961645, 
6.641411, 4.042785, 4.175351, 6.040673, 7.025595, 6.8701243794046, 
6.474802, 6.069435, 5.98875791029547, 5.44536133412665, 5.905144, 
6.253757, 5.55713735563886, 3.183721, 6.23569788279688, 8.018743, 
4.14168543985438, 3.140228, 2.85944735485205, 7.19532), GMP1 = c(6.00003380096822, 
6.45782274084263, 10.1386873750581, 11.18212, 4.99574155426759, 
8.22548270576452, 11.80921, 6.139842, 4.716938, 6.208399, 7.25702470622416, 
9.216353, 4.459075, 7.604192, 10.214, 9.71979154806924, 4.045693, 
6.892321, 4.36733, 4.54209088244969, 4.363115, 7.42142574723769, 
8.16658165526266, 13.13801, 11.7030896033115, 1.38480651276548, 
7.70549837966537, 10.51655, 5.6799276696584, 7.117451, 10.4613436109924, 
7.51060888343217, 9.45360701936786, 11.02082, 4.741664, 4.37359, 
6.757818, 7.101331, 6.51838172412493, 6.234017, 6.139842, 7.16147421243415, 
5.80674368005962, 6.208399, 6.860234, 4.69772329684801, 5.404108, 
6.45675195710298, 6.892321, 5.30230900977469, 4.155601, 4.36874064027233, 
7.42003), GMP2 = c(5.74747276487971, 5.97553824097351, 8.84397150139003, 
10.54739, 7.01942050935297, 8.32418895763336, 11.28484, 6.100887, 
5.371866, 5.782092, 6.81459497341517, 8.300889, 4.573727, 7.155416, 
10.55908, 8.53584780642442, 3.288921, 7.981419, 3.343707, 1.78160205563733, 
7.106303, 6.97534663269409, 4.30909405726115, 10.94426, 10.9546928815164, 
6.74862372900741, 7.1870575783895, 9.650893, 4.16099729988147, 
6.067064, 9.97780340347263, 5.92239739476255, 9.00840651100957, 
5.952921, 5.034178, 4.255218, 5.533772, 6.671744, 6.58968157482356, 
6.572507, 6.100887, 6.06061888187195, 4.67987580614607, 5.782092, 
5.976481, 5.57605980178547, 4.822138, 5.9343704738438, 7.981419, 
4.0036610231274, 2.709241, 2.35084397835661, 7.122418), GMP3 = c(6.86258223460792, 
6.20078322375291, 9.61446552902509, 10.80572, 7.36372917472567, 
8.3826076358515, 11.15008, 5.201591, 4.123945, 5.045783, 6.24154676477513, 
8.276453, 4.263376, 7.519041, 10.51785, 8.30200623104098, 2.495567, 
7.857207, 2.962492, 1.93915883789869, 7.249551, 7.84810925448229, 
5.84602007858824, 11.77414, 11.1027524778454, 5.63020389504886, 
6.50727637405781, 9.456897, 3.75134646474614, 5.932853, 10.1039559568546, 
4.9400044296399, 9.31472753734898, 6.039605, 3.336343, 3.975937, 
5.736387, 6.905666, 6.30344093479224, 5.426484, 5.201591, 5.47026133533826, 
4.69976751703472, 5.045783, 5.749752, 5.23937658540781, 5.154187, 
6.34478978856221, 7.857207, 3.50805939441741, 2.657933, 2.78283797334871, 
7.091083), GMP4 = c(6.05880869638876, 6.28654396576068, 9.96479543345143, 
10.73202, 7.213420739218, 8.81669595423024, 11.31576, 5.679182, 
4.155314, 5.673872, 6.43309255133785, 8.167664, 4.513147, 7.768381, 
10.68025, 8.7651559260891, 2.485242, 8.41621, 3.457858, 2.07304058721841, 
6.412872, 8.09668562132081, 5.97986866984983, 12.08623, 11.28032878957, 
6.57392060927003, 6.41585754599334, 9.749641, 3.66579392385564, 
5.878271, 9.75282317403084, 5.77880844881496, 9.31419691100924, 
5.048616, 3.784422, 4.082659, 6.015668, 6.789027, 6.44947035574528, 
6.177861, 5.679182, 5.40028170642952, 4.40100191946731, 5.673872, 
6.189491, 5.32217020480945, 3.106884, 5.98621706786421, 8.41621, 
3.507010215991, 2.810708, 2.26597487448895, 6.822586), Mono1 = c(5.2563684147039, 
6.45633325704225, 8.35683375157621, 10.4683, 6.89578871222261, 
6.89453589831897, 10.76922, 5.79888, 3.938016, 4.625604, 8.14811443428627, 
8.89819, 4.565085, 7.582637, 9.690787, 9.26841770880937, 2.680727, 
7.256856, 5.506176, 1.73004263683502, 7.168846, 7.34133258574044, 
2.04394933289888, 10.88391, 10.8831286687177, 2.76098817217713, 
7.62084289021189, 9.376334, 5.89374731019185, 5.059797, 9.58406921227736, 
6.10083260496288, 8.90601784817498, 8.926934, 4.514644, 4.671412, 
6.824876, 7.160325, 7.12646156474527, 6.029051, 5.79888, 7.45127447114964, 
6.58727075697179, 4.625604, 6.726376, 4.54492833429885, 5.482923, 
5.75789405204644, 7.256856, 5.01661617666884, 3.912327, 4.21481739920369, 
7.311136), Mono2 = c(5.85774218629914, 5.24626015596457, 7.87393184409552, 
10.74763, 6.1115477644807, 8.59285304183197, 11.30387, 6.487999, 
5.641296, 5.605635, 6.83338037544917, 8.158746, 5.031193, 7.791207, 
10.12365, 8.83146107303257, 3.839879, 7.995034, 3.864015, 1.95600811707846, 
6.547528, 7.15767104450585, 1.13087340949285, 10.60541, 10.6662569861529, 
2.45950067788357, 7.80075639569934, 9.772267, 4.10768104209722, 
6.039518, 9.45126490091168, 5.43166366925388, 8.53913541490463, 
6.852944, 5.210281, 3.909477, 6.10825, 6.759114, 6.10127101835935, 
6.394382, 6.487999, 6.77443082143061, 4.65095032762504, 5.605635, 
6.292733, 5.06179443435785, 4.687693, 5.97873952456647, 7.995034, 
4.53685791636727, 2.036068, 3.79175025763666, 7.80933), Mono3 = c(5.79480048210947, 
5.93841021449181, 8.4456428811783, 10.96997, 5.90368127873194, 
7.57633522462406, 10.77521, 5.357294, 3.631277, 5.573695, 6.02937219504517, 
7.823033, 4.89389, 7.134801, 9.942904, 8.29297682562671, 2.376142, 
7.942619, 2.938838, 2.58663314475541, 5.473615, 6.54736080917345, 
1.50818476189011, 10.39009, 9.81896143227971, 2.61179572528994, 
7.11294273571537, 9.321912, 4.59467076052555, 4.846162, 9.0889984655259, 
5.5580711224014, 8.60684080318993, 6.807437, 3.781213, 3.349656, 
5.352098, 6.732808, 6.18873397274794, 5.580769, 5.357294, 6.02896733254353, 
4.09719798968178, 5.573695, 5.576249, 4.76264681239467, 4.599397, 
5.85107919870538, 7.942619, 4.46991267319193, 2.359072, 2.49361466378781, 
7.168415), Mono4 = c(5.79136484133828, 5.22885638262284, 8.66188302349651, 
10.80097, 6.02816710441609, 8.28180453176157, 10.95579, 5.606963, 
4.781397, 6.146859, 7.35941757150855, 8.279649, 5.035288, 8.131193, 
10.46082, 8.7442177262891, 2.904981, 8.009644, 2.855958, 2.31248706248342, 
7.171729, 7.85215015030227, 1.5674747074644, 10.34766, 10.4041048711624, 
1.7198811173707, 7.7219124608883, 9.652986, 4.80881131147327, 
5.631832, 9.37540653744023, 5.93520028734304, 8.83460813839155, 
7.145424, 4.609511, 4.550807, 6.666205, 6.956604, 6.66113029874611, 
6.54366, 5.606963, 5.47022342513485, 4.59138757680696, 6.146859, 
5.969648, 5.20105550006015, 3.857023, 6.22204033269913, 8.009644, 
4.44000233834592, 2.854773, 2.88863557103663, 6.788677)), class = "data.frame", row.names = c(NA, 
-53L))
$\endgroup$
2
  • 1
    $\begingroup$ Did you read the news of the package to know if anything else has changed? Did you look at the help pages to see how is the new way to label the heatmap? $\endgroup$
    – llrs
    Jan 14, 2019 at 7:52
  • 1
    $\begingroup$ I updated to use it for oncoprint after that i see some of the old codes are not working , im slowly making changes while i read it ... $\endgroup$
    – kcm
    Jan 14, 2019 at 13:28

1 Answer 1

1
$\begingroup$

I see that you created the ColAnn variable with the Condition annotation but did not include it in the draw call (or even in the Heatmap() function). Could that be the problem here?

EDIT: Oops, just noticed that this post is really old. Doesn't have an answer, so I guess I'll let mine stay.

$\endgroup$
1
  • $\begingroup$ yeah that was the mistake i thought after updating ,it broke $\endgroup$
    – kcm
    May 12, 2019 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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