using the "oncoPrint" function in "ComplexHeatmap" package I wish to rotate the column names (shown in green in attached image) from being vertical, to being horizontal as this will be easier to read.
I've tried lots of gpar options without success: las, rot, crt, srt
example: column_names_gp = gpar(las=1)
example: ht_global_opt(heatmap_column_names_gp=gpar(las=0))
This must be possible... but how?
Here's my amateurish code followed by some data (the gene names have been changed to protect the innocent).
library(ComplexHeatmap)
Filepath_details<-file.choose()
mat = read.table(Filepath_details, header = TRUE,stringsAsFactors=FALSE, sep = ",")
mat[is.na(mat)] = ""
rownames(mat) = mat[, 1] #define row names as the sample ID.
mat = mat[, -1] #column 1 is now superfluous so delete it.
mat= mat[, -ncol(mat)] #making sure that he whole table id selected.
mat = t(as.matrix(mat))#turning the data into a matrix.
mat[1:3, 1:3] #this just gives a visual check of data processing 3x3 only
alter_fun_list = list( background = function(x, y, w, h) { grid.rect(x, y, w-unit(0.5, "mm"), h-unit(0.5, "mm"), gp = gpar(fill = "#CCCCCC", col = NA)) }, "nonsense" = function(x, y, w, h) { grid.rect(x-0.008, y, w*0.45, h-unit(0.5, "mm"), gp = gpar(fill = "red", col = NA)) }, "missense" = function(x, y, w, h) { grid.rect(x-0.008, y, w*0.45, h-unit(0.5, "mm"), gp = gpar(fill = "blue", col = NA)) }, "silent" = function(x, y, w, h) { grid.rect(x+0.008, y, w*0.45, h-unit(0.5, "mm"), gp = gpar(fill = " forestgreen", col = NA)) } )
col = c("silent" = " forestgreen","nonsense" = "red", "missense" = "blue")
oncoPrint(mat, get_type = function(x) strsplit(x, "-")[1], alter_fun_list = alter_fun_list, col = col, show_column_names = TRUE, column_names_gp = gpar(cex=0.5, font=1, col= "green"), heatmap_legend_param = list(title = "Mutations"))
A tiff image of some fictional gene mutation data
some fictional data to be saved as a text file: ,TOM,DICK,HARRY,FRED,BILL,TOD,ERNIE,ANDY,SIMON,JED,WESS,GARY,PHILL,BURT,JOHN,WALT,DOUG,STAN,HUGH,CLIFF,NATH,EARL,GREG,ED,HENRY,WILL,PAUL,JACK,MICK 2,,,,,,,,,,,,,,,,,missense,,,,,,,,,,,,
5,,,silent,,,,,,,,,,missense,,,,,,silent-missense,,missense,,missense,,,,,,
6,,,,,,,,,,,,,,,,,,,,,,,,,silent,,,,
11,,,,,,,,silent,,,,,,,,,,,,,,,,,,,,,
12,,,,,,,,,,,,,,,,missense,,,,,,,,,,,,missense,
14,,,,,,,,,,,,,,,,,,,,,,,,,,,,missense,
15,,,,,,,,,,,,silent,,missense,,,,,,,,,,,,,,,
17,,,,,,,,silent,,,,silent,,,,,,,,,,,,,,,,missense,
18,,,,,missense,,,,,,,,,,,,missense,,,,,missense,,,,,,,
19,,,,,,,,,,,,,,,,,missense,,,,,,,,,,,,
20,,,silent,,,,,,,,,,,,,,,,,,,,,,,,,missense,
23,,,,,,,,,,,,,,missense,,,,,,,,,,,,,,nonsense,
27,,,,,,,,,,,,,,,,,missense,,,,,,,,,,,,
28,,,missense,,,,,,,silent,,,,,,,,,,,,,,,,,,missense,
29,,missense,,,,,,,missense,,,,,,,,,,,,,,,,,,,,
30,,,,,,missense,,,,,,,,,,,,,,,,,,,,,,,
31,,,,,,,,,,,missense,,,,,,missense,,,,,,,,,,,missense,
39,,,,,,,,,,,,,,,,,,missense,,,,,,,,,,,
42,,,,,,,,,,,,silent,,,,,missense,missense,,,,,,,silent,,,,
43,,,,,,,,,,silent,,,,,,,,,,,,,,,,,,missense,silent
45,,,,silent,,,,,,,,,,,,,,,,,,,,,,,,missense,
46,missense,,,,,,,,,,,,,,,,,,,,,silent-missense,,,,,,missense,
47,,,,,,,,,,missense,,,,,,,,,,,nonsense,,,,,,,,
50,,,,,,,,,,,,,,,,,missense,,,,,,,nonsense,,,,,
51,,,,,,,,,,,,,,,,,,,,missense,,,,,,,,,
52,,,,,,,,,,,,,silent,,missense,,,,silent,,,,,missense,missense,missense,silent,,
60,,,,,,,missense,,,,,,,,,,,,,,,,,,,,,,
63,,,,,,,,,,,,,,,,,,,,,,,,,,,,nonsense,
64,,,,,,,,,,,,,,,,,,,,missense,,,,,,,,missense,
65,,,,,,,,,,,,,,,,,missense,,,,,,,,,,,,
66,,,,,,,,,,,,,silent,,,,,,,,,,,,,,,,
I really hope somebody can help me here... I've not been so stumped with R before.
with thanks...
Andrew