Open prinkessbambi opened 2 years ago
I think it is because you have too many columns. In the following code:
alter_fun = list(
background = function(x, y, w, h) {
grid.rect(x, y, w-unit(0.5, "mm"), h-unit(0.5, "mm"),
gp = gpar(fill = "beige", col = NA))
},
"wt" = function(x, y, w, h)
grid.rect(x, y, w * 0.9, h * 0.9,
gp = gpar(fill = alts_col["wt"], col = NA)),
...
the background and other graphics actually have 0.5mm (or 0.05% of the cell width) white borders. When you save it as a png or view it not in its 100% size, these white borders are merged into neighbour pixels, which results in white lines (depends on neighbour colors or randomness).
To solve it, just remove these white borders:
alter_fun = list(
background = function(x, y, w, h) {
grid.rect(x, y, w, h,
gp = gpar(fill = "beige", col = NA))
},
"wt" = function(x, y, w, h)
grid.rect(x, y, w, h*0.9,
gp = gpar(fill = alts_col["wt"], col = NA)),
...
How can I preserve the white gap between each row (gene) that is in my code?
HIA GHOSH University of Rochester | Computational Biology, B.Sc. Class of '19 | Take Five Scholar '20
On Wed, Aug 31, 2022 at 7:52 AM Zuguang Gu @.***> wrote:
I think it is because you have too many columns. In the following code:
alter_fun = list(background = function(x, y, w, h) { grid.rect(x, y, w-unit(0.5, "mm"), h-unit(0.5, "mm"),gp = gpar(fill = "beige", col = NA)) }, "wt" = function(x, y, w, h) grid.rect(x, y, w 0.9, h 0.9,gp = gpar(fill = alts_col["wt"], col = NA)), ...
the background and other graphics actually have 0.5mm (or 0.05% of the cell width) white borders. When you save it as a png or view it not in its 100% size, these white borders are merged into neighbour pixels, which results in white lines (depends on neighbour colors or randomness).
To solve it, just remove these white borders:
alter_fun = list(background = function(x, y, w, h) { grid.rect(x, y, w, h,gp = gpar(fill = "beige", col = NA)) }, "wt" = function(x, y, w, h) grid.rect(x, y, w, h*0.9,gp = gpar(fill = alts_col["wt"], col = NA)), ...
— Reply to this email directly, view it on GitHub https://github.com/jokergoo/ComplexHeatmap/issues/975#issuecomment-1232835077, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJN532DEWVP73AXKZQ32CBTV35BPRANCNFSM57XXORQA . You are receiving this because you authored the thread.Message ID: @.***>
When you set alter_fun
, you can set do like:
alter_fun = list(
background = function(x, y, w, h) {
grid.rect(x, y, w, h - unit(4, "mm"),
gp = gpar(fill = "beige", col = NA))
},
"wt" = function(x, y, w, h)
grid.rect(x, y, w, h - unit(4, "mm"),
gp = gpar(fill = alts_col["wt"], col = NA)),
Then you will see 4mm gap between rows.
Hello, I've organized my oncoprint so that samples with alterations in gene1, 13, and 14 are displayed first/clustered. The oncoprint has these blocks of stripes throughout the rows corresponding to gene 1,13, and 14 that should not be there. I've ordered the matrix by my column order and inspected it-- my ordering is correct. These white lines don't represent samples with wt/missing data-- they should be colored in, as their corresponding samples in the matrix are marked as missense.
The matrix and column order are attached as CSV's because it is difficult to create a toy dataframe to show what's wrong.
test_mat.csv col_order.csv
`
The alter fun function
alter_fun = list( background = function(x, y, w, h) { grid.rect(x, y, w-unit(0.5, "mm"), h-unit(0.5, "mm"), gp = gpar(fill = "beige", col = NA)) },
"wt" = function(x, y, w, h) grid.rect(x, y, w 0.9, h 0.9, gp = gpar(fill = alts_col["wt"], col = NA)),
"missense" = function(x, y, w, h) grid.rect(x, y, w 0.9, h 0.9, gp = gpar(fill = alts_col["missense"], col = NA)),
"damaging_mutation" = function(x, y, w, h) grid.rect(x, y, w 0.9, h 0.9, gp = gpar(fill = alts_col["damaging_mutation"], col = NA)),
"not_covered" = function(x, y, w, h) grid.rect(x, y, w 0.9, h 0.9, gp = gpar(fill = alts_col["not_covered"], col = NA)),
"rearrangement" = function(x, y, w, h) grid.rect(x, y, w 0.9, h 0.4, gp = gpar(fill = alts_col["rearrangement"], col = NA)),
"focal_gain" = function(x, y, w, h) grid.rect(x, y, w 0.9, h 0.9, gp = gpar(fill = alts_col["focal_gain"], col = NA)), "focal_loss" = function(x, y, w, h) grid.rect(x, y, w 0.9, h 0.9, gp = gpar(fill = alts_col["focal_loss"], col = NA)),
"arm_level_loss" = function(x, y, w, h) grid.rect(x, y, w 0.9, h 0.9, gp = gpar(fill = alts_col["arm_level_loss"], col = NA)),
"arm_level_gain" = function(x, y, w, h) grid.rect(x, y, w 0.9, h 0.9, gp = gpar(fill = alts_col["arm_level_gain"], col = NA)) )
For alterations on heatmap legend
alts_col <- c("blue", "red", "green", "skyblue", "orange", "beige", "white", "red", "blue") names(alts_col) <- c("focal_loss", "focal_gain", "rearrangement", "missense", "damaging_mutation", "wt", "not_covered", "arm_level_gain","arm_level_loss")
Read in data
umat <- read.csv("test_mat.csv", header = T, row.names = 1) ro <- read.csv("col_order.csv")
file = "test_mat.png" png( file , width = 1600, height = 1200); onc <- oncoPrint( umat, use_raster = F, column_order = ro$samples, show_pct = T, pct_side = "right", pct_gp = gpar(fontsize = 20), row_names_side = "left", row_names_gp = gpar(fontsize = 25), alter_fun_is_vectorized = TRUE, alter_fun = alter_fun, col = alts_col, heatmap_legend_param = list( labels_gp = gpar(fontsize = 20), title_gp = gpar(fontsize = 20, fontface = "bold"), title = "Alterations" ), right_annotation = rowAnnotation( #move barplot to left side rbar = anno_oncoprint_barplot( axis_param = list(direction = "reverse") )), row_order = rownames(umat), ); ComplexHeatmap::draw(onc, merge_legend = T); dev.off()
`