Hi ! I could use some help to figure out what's going awry.
I'm generating an alteration frequency plot with selected amplified or deleted genes annotated up top. I've added a labels_gp(col = gene.colors), and link_gp(col = gene.colors); where gene.colors is a named vector to color code amplified or deleted genes.
However, the colors in the rendered plot are not as expected. Is there a different way to code these ? or any idea of what's happening?
Here's what I'm doing:
## list of genes
## the mark genes function returns the location of each gene in the heatmap matrix
gth <- mark.genes(cnr, gene.list = genes.to.highlight)
## head(gth)
#> g1 g2 g3 g4 g5 g6
#> 413 874 949 1177 1240 1306
## pull pre-estimated gene frequencies
gene.fq <- gene.frequencies.all[gsub("-", ".", names(gth)), c("AmpFQ", "delFQ")]
fqa <- gene.frequencies.all$AmpFQ
fqd <- gene.frequencies.all$delFQ
## which gene is amplified or deleted
## which is max (1 = AmpFQ, 2 = delFQ)
wmx <- apply(gene.fq, 1, which.max)
## conditional color coding, if 1 == 'red', 2 == 'blue'
## black otherwise
gene.colors <- ifelse(wmx == 1, "red",
ifelse(wmx == 2, "blue", "black"))
## check if statments match order of gth
head(gene.colors, n = 11)
#> g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 g11
#> "red" "blue" "blue" "blue" "blue" "blue" "blue" "blue" "red" "red" "red"
head(gth, n = 11)
#> g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 g11 g12 g13
#> 413 874 949 1177 1240 1306 1476 1522 1783 1810 2260 2948 3046
## check all is concordant
head(cbind(gth, gene.fq, wmx, gene.colors), n = 12)
#> gth AmpFQ delFQ wmx gene.colors
#> g1 413 0.14583333 0.04166667 1 red
#> g2 874 0.00000000 0.29166667 2 blue
#> g3 949 0.00000000 0.31250000 2 blue
#> g4 1177 0.00000000 0.29166667 2 blue
#> g5 1240 0.00000000 0.29166667 2 blue
#> g6 1306 0.00000000 0.43750000 2 blue
#> g7 1476 0.00000000 0.29166667 2 blue
#> g8 1522 0.00000000 0.56250000 2 blue
#> g9 1783 0.31250000 0.02083333 1 red
#> g10 1810 0.31250000 0.02083333 1 red
#> g11 2260 0.95833333 0.00000000 1 red
#> g12 2948 0.00000000 0.54166667 2 blue
## generate genome annotation track
## annotated genes up top color coded for Amp / Del
## Amplification Frequency Plot
## Deletion Frequency Plot
genome_annotation <- HeatmapAnnotation(
genes = anno_mark(at = gth, labels = names(gth),
link_height = unit(4, "mm"),
labels_gp = gpar(fontsize = 5,
col = gene.colors,
fontface = "italic"),
link_gp = gpar(col = gene.colors)),
fqa = anno_barplot(fqa,
gp = gpar(col = "#D40000"),
axis_param = list(gp=gpar(fontsize = 5)),
ylim = c(0, 1)),
fqd = anno_barplot(fqd,
gp = gpar(col = "#318CE7"),
axis_param = list(gp = gpar(fontsize = 5),
direction = "reverse"),
ylim = c(0, 1)),
annotation_name_side = "left",
annotation_name_gp = gpar(fontsize = 6),
show_legend = FALSE)
## generate heatmpa + alteration summary
out_hm <- Heatmap(cnr,
top_annotation = genome_annotation,
show_row_names = FALSE,
border = TRUE)
However, the figure once plotted does not show the color codes as expected (Shown above for g1-g12). Here are a few examples where:
We'd expect g1 to be red, g6 and g8 to be blue. which does not match.
Similarly, down the plot, we expect g48 to be red, g49->g59 to be all blue, and g60->67 to be red, and these colors appear inverted.
Hi ! I could use some help to figure out what's going awry.
I'm generating an alteration frequency plot with selected amplified or deleted genes annotated up top. I've added a
labels_gp(col = gene.colors)
, andlink_gp(col = gene.colors)
; wheregene.colors
is a named vector to color code amplified or deleted genes.However, the colors in the rendered plot are not as expected. Is there a different way to code these ? or any idea of what's happening?
Here's what I'm doing:
However, the figure once plotted does not show the color codes as expected (Shown above for g1-g12). Here are a few examples where: We'd expect g1 to be red, g6 and g8 to be blue. which does not match.
Similarly, down the plot, we expect g48 to be red, g49->g59 to be all blue, and g60->67 to be red, and these colors appear inverted.