Entering edit mode
16 months ago
luffy
▴
130
Hello all,
I have plotted an oncoprint following this link but I am facing trouble in arranging the labels and modifying annotations, here is the code I have used.
Input:
Sample1 Sample2 Sample3 Sample4 Sample5
Gene1 "" "Nonsense" "" "" "Nonsense" "Nonsense"
Gene2 "" "" "" "" "" ""
Gene3 "" "" "Splice_site" "" "" ""
code:
## input
mat = read.table('input_oncoprint.txt', header = TRUE, sep = "\t")
mat[is.na(mat)] <- ''
rownames(mat) <- mat[,1]
mat <- mat[,-1]
mat <- mat[, -ncol(mat)]
mat <- t(as.matrix(mat))
col <- c("Missense" = "#f5f251", "Frameshift" = "#a051f5", "Splice_site" = "#5d79f5", "Nonsense" = "#f55dc5", "CNV" = "#f5835d", "Y" = "#78e2fa", "N" = "#78fad3")
alter_fun <- list(
background = function(x,y,w,h){
grid::grid.rect(x,y,w - grid::unit(0.5,"mm"), h - grid::unit(0.5,"mm"),gp=grid::gpar(fill = "#CCCCCC",col=NA))
},
Missense = function(x,y,w,h){
grid::grid.rect(x,y,w - grid::unit(0.5,"mm"),h - grid::unit(0.5, "mm"),gp=grid::gpar(fill=col["Missense"],col=NA))
},
Nonsense = function(x,y,w,h){
grid::grid.rect(x,y,w - grid::unit(0.5,"mm"),h - grid::unit(0.5,"mm"),gp = grid::gpar(fill=col["Nonsense"],col=NA))
},
CNV = function(x,y,w,h){
grid::grid.rect(x,y,w - grid::unit(0.5,"mm"),h - grid::unit(0.5,"mm"),gp = grid::gpar(fill=col["CNV"],col=NA))
},
Frameshift = function(x,y,w,h){
grid::grid.rect(x,y,w - grid::unit(0.5,"mm"),h - grid::unit(0.5,"mm"),gp = grid::gpar(fill=col["Frameshift"],col=NA))
},
Splice_site = function(x,y,w,h){
grid::grid.rect(x,y,w - grid::unit(0.5,"mm"),h*0.33, gp = grid::gpar(fill=col["Splice_site"],col = NA))
},
)
column_title <- "Types of Varaints"
heatmap_legend_param <- list(title = "Variant types", at = c("Missense","Frameshift","Splice_site", "Nonsense", "CNV"), labels = c("Missense","Frameshift","Splice_site", "Nonsense", "CNV"))
ha = HeatmapAnnotation(age = anno_points(yearstobirth, ylim = c(0, max(yearstobirth, na.rm = TRUE)), axis = TRUE),annotation_height = unit(c(15), "mm"))
png("plot_onco_fh_consang.png", units="in", width=7, height=7, res=300)
oncoPrint(mat,alter_fun = alter_fun, col = col, column_order = sample_order, column_title = column_title, heatmap_legend_param = heatmap_legend_param, top_annotation = HeatmapAnnotation(Fam_His = fh, his_cons = cansang, col = list(Fam_His = c("Y" = "#f50c7c", "N" = "#fab1d5"), his_cons = c("Y" = "#02c1d6", "N" = "#9ff3fc")), gp = gpar(col = "#9e9d9d")), bottom_annotation = ha)
dev.off()
Output
My questions are
- How do put the labels one below the other and reduce the size of it so that the plot area would be wide?
- How to I reduce the scale of x axis of the bottom annotation plot?
- How to change the font of the lables top and bottom annotation?
Thank you for your time
Any help would be much appreciated
To change size, fontface etc, you need to supply associated gp parameters. For bottom annotation label font size, for example, use
ha = HeatmapAnnotation(age = anno_points(yearstobirth, ylim = c(0, max(yearstobirth, na.rm = TRUE)), axis = TRUE), annotation_name_gp = gpar(size = 2)
. Change the number until you like the size.@Ram, Thank you for your response,
Is it possible to print the title of the legend (Family History) and only in short in the top annotation (FH) as full label is overlappingthe bar plot on the right
The code you have shared, i can adjust the plot area in the bottom annotation but how do i scale the
Y axis
, i can not remove the outliers, is it possible to scale it like0, 25, 50, 75, 100, 150
Thank you