When I run the oncoprint function on my data code, I see the following warnings (although it still makes the oncoprint, I can't tell if anything is wrong):
1: You defined cell_fun
for a heatmap with more than 100 rows or columns, which might be very slow to draw. Consider to use the vectorized version layer_fun
.
2: Values in column annotation 'Molecular' have a different order of names from the matrix column names. It may lead to wrong conclusion of your data. Please double check.
(Warning #2 ^ applies to every single column annotation I use (ex: gender, age, etc))
Where is the cell_fun parameter? I didn't pass an argument called cell_fun, so I assume it's a parameter for some function used by oncoprint(). How is layer_fun different than cell_fun? How would I create this variable and pass it to the oncoprint function?
As for Warning 2, I have tried searching the forums and (I think) the github source code, but could not make sense of what this means or how to fix it. At the moment, I'm testing subsets of my whole data set because it takes so long to run. Consequently, not every type of molecular diagnosis in my subset of data-- is that why this warning occurs? Because the annotation column has more diagnoses than one sees in my subset of data? Would that explain all of my warnings like warning 2?
I tried to make a reproducible sample with toy data/a subset of the data, but when I run it, I don't see the warnings any more! I have no idea what to do without sending someone a data file to try on their own.
Here are the lines I am running:
#label rows as Sample ID, then rm sample col
row.names(toydf) <- toydf$samples
toydf <- toydf[, 2:length(toydf)]
#Create Colors for Annotation
gender_cols <- c("Male" = "blue", "Female" = "pink")
grade_cols <- c("1" = "white", "2" = "gray", "3" = "black")
mol_cols <- c("Glioma" = "yellow",
"GBM" = "black",
"Oligo" = "pink")
col <-
c(
"arm_level_gain" = "blue",
"wt" = "beige",
"missense" = "pink",
"arm_level_loss" = "red",
"damaging_mutation" = "purple"
)
ha_top = HeatmapAnnotation(
df = toydf,
col = list(
Molecular = mol_cols, # defined earlier in script
Grade = grade_cols,
Gender = gender_cols
),
na_col = "grey"
)
ha_all = HeatmapAnnotation( #constructor function-- read complexheatmap documentation
df = toydf,
col = list(Molecular = mol_cols,
Grade = grade_cols,
Gender = gender_cols),
na_col = "grey"
)
#some var that oncoprint needs
## Define grfphical representations of different alteration types
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 = "beige", col = NA)),
focal_loss = function(x, y, w, h)
grid.rect(x, y, w * 0.9, h * 0.9,
gp = gpar(fill = col["focal_loss"], col = NA)),
damaging_mutation = function(x, y, w, h)
grid.rect(x, y, w * 0.9, h * 0.9,
gp = gpar(fill = col["damaging_mutation"], col = NA)),
missense = function(x, y, w, h)
grid.rect(x, y, w * 0.9, h * 0.9,
gp = gpar(fill = col["missense"], col = NA)),
focal_gain = function(x, y, w, h)
grid.rect(x, y, w * 0.9, h * 0.9,
gp = gpar(fill = col["focal_gain"], col = NA)),
arm_level_gain = function(x, y, w, h)
grid.rect(x, y, w * 0.9, h * 0.9,
gp = gpar(fill = col["arm_level_gain"], col = NA)),
arm_level_loss = function(x, y, w, h)
grid.rect(x, y, w * 0.9, h * 0.9,
gp = gpar(fill = col["arm_level_loss"], col = NA))
)
barplot_traits <- c("focal_loss", "damaging_mutation", "missense", "focal_gain", "arm_level_gain",
"arm_level_loss", "wt")
oncoPrint(
toym,
alter_fun = alter_fun,
show_pct = F,
row_names_gp = gpar(size = 16),
col = col,
#cluster_columns = hc_order, #is hc_order a dendrogram/hclust object?
top_annotation = ha_all,
#column_split = toydf$Molecular,
row_names_side = "left",
#row_order = genes_order,
right_annotation = rowAnnotation(
row_barplot = anno_oncoprint_barplot(barplot_traits, # only AMP and HOMDEL
border = TRUE, #height = unit(4, "cm"),
axis_param = list(side = "bottom", labels_rot = 90))))