TL;DR - create tile plot, two aesthetics in same tile cause tile color to not render, not sure if it's my code or something with ggplot2, anyone experienced this?
I'm getting a strange plotting issue (not an error, this silently fails and I only notice the problem when looking at the final representation) when I try to plot multiple aesthetics in the same tile using ggplot.
my data:
satur_muts <- structure(list(id = c("0400136_T1", "0400136_T1", "0400136_T1", 
"0400136_T1", "0400171_T1", "0400171_T1", "0400171_T1", "0400171_T1", 
"0400179_T1", "0400179_T1", "0400179_T1", "0400195_T1", "0400195_T1", 
"0400195_T1", "0400195_T1"), gene = c("CDKN2A", "TP53", "KRAS", 
"KRAS", "CDKN2A", "TP53", "KRAS", "KRAS", "CDKN2A", "TP53", "KRAS", 
"CDKN2A", "TP53", "KRAS", "KRAS"), mut_type = structure(c(NA, 
NA, 1L, NA, NA, NA, NA, 1L, NA, NA, 1L, NA, NA, 1L, NA), .Label = "Missense", class = "factor"), 
    is_cnv = c(NA, NA, FALSE, TRUE, NA, NA, TRUE, FALSE, NA, 
    NA, FALSE, NA, NA, FALSE, TRUE)), row.names = c(NA, -15L), .Names = c("id", 
"gene", "mut_type", "is_cnv"), class = c("tbl_df", "tbl", "data.frame"
))
cnv_dat <- structure(list(id = structure(1:3, .Label = c("0400136_T1", "0400171_T1", 
"0400195_T1"), class = "factor"), gene = structure(c(1L, 1L, 
1L), .Label = "KRAS", class = "factor"), mut_type = structure(c(NA_integer_, 
NA_integer_, NA_integer_), .Label = character(0), class = "factor"), 
    cnv = structure(c(1L, 1L, 1L), .Label = "High-level amplification", class = "factor"), 
    is_cnv = c(TRUE, TRUE, TRUE)), row.names = c(NA, -3L), .Names = c("id", 
"gene", "mut_type", "cnv", "is_cnv"), class = c("tbl_df", "tbl", 
"data.frame"))
cb_palette <- c("Missense" = "#095481",
                "Splice site" = "#DE5423",
                "Frameshift" = "#179F30",
                "Nonsense" = "#F5B02C",
                "Nonstop" = "#FF69B4",
                "In-frame indel" = "#9C39B6")
mut_levels = c("Missense", "Splice site", "Frameshift", "Nonsense", "Nonstop", "In-frame indel")
my code:
library(dplyr); library(readr); library(ggplot2)
p1 <- ggplot(data = satur_muts) + 
  geom_tile(mapping = aes(x = id, y = gene, fill = mut_type), height=0.9, width=0.9) +
  scale_fill_manual(values = cb_palette, na.value = "Grey95", drop = F,
                    guide = guide_legend(title = "Somatic mutations", override.aes = list(size=4.5))  ,
                    breaks = unique(satur_muts$mut_type)[order(mut_levels)] %>% na.omit()) + 
  geom_tile(data = filter(satur_muts, gene == ""), 
            mapping = aes(x=id, y=gene), 
            fill = "white",
            height = 1, width = 1)
o <- levels(cnv_dat$cnv)
v_tuple <- c("High-level amplification"= 24, "Homozygous deletion" = 25)
b <- c("High-level amplification", "Homozygous deletion")
keep <- which( names(v_tuple) %in% unique(cnv_dat$cnv)[ order(o) ] )
p2 <- p1 + 
  geom_point(data = cnv_dat,  aes(x = id, y = gene, shape = cnv),
             fill = "grey", size = 3, stroke = 0.5, inherit.aes = F) +
  scale_shape_manual(values = v_tuple[keep], 
                     breaks = b[keep]) +
  guides(shape = guide_legend(title = "Somatic Copy Number Aberration"), override.aes = list(size=4.5), drop = T )
p2
The two tiles to the left of the last blue-and-up-triangle tile should also have a blue background, per my data check below. I don't understand why one sample would plot correctly while the others don't.
mt <- left_join(satur_muts, cnv_dat) %>% filter(!is.na(is_cnv))
t <- mt %>% filter(gene == "KRAS") 
# A tibble: 7 × 5
          id  gene mut_type is_cnv                      cnv
       <chr> <chr>    <chr>  <lgl>                   <fctr>
1 0400136_T1  KRAS Missense  FALSE                       NA
2 0400136_T1  KRAS     <NA>   TRUE High-level amplification
3 0400171_T1  KRAS     <NA>   TRUE High-level amplification
4 0400171_T1  KRAS Missense  FALSE                       NA
5 0400179_T1  KRAS Missense  FALSE                       NA
6 0400195_T1  KRAS Missense  FALSE                       NA
7 0400195_T1  KRAS     <NA>   TRUE High-level amplification
Rsession info
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] parallel  grid      stats     graphics  grDevices utils     datasets  methods   base     
other attached packages:
 [1] viridis_0.3.4      RColorBrewer_1.1-2 doMC_1.3.4         iterators_1.0.8    foreach_1.4.3      cowplot_0.7.0      lattice_0.20-34    gridExtra_2.2.1    readxl_0.1.1      
[10] forcats_0.2.0      stringr_1.2.0      devtools_1.12.0    dplyr_0.5.0        purrr_0.2.2        readr_1.0.0        tidyr_0.6.2        tibble_1.3.0       ggplot2_2.2.1     
[19] tidyverse_1.1.1   
loaded via a namespace (and not attached):
 [1] Rcpp_0.12.10     plyr_1.8.4       tools_3.3.2      digest_0.6.12    jsonlite_1.4     lubridate_1.6.0  memoise_1.0.0    gtable_0.2.0     nlme_3.1-131     psych_1.6.12    
[11] DBI_0.5-1        haven_1.0.0      withr_1.0.2      httr_1.2.1       xml2_1.1.1       hms_0.3          R6_2.2.0         foreign_0.8-67   reshape2_1.4.2   modelr_0.1.0    
[21] magrittr_1.5     codetools_0.2-15 scales_0.4.1     assertthat_0.1   mnormt_1.5-5     rvest_0.3.2      colorspace_1.3-2 labeling_0.3     stringi_1.1.5    lazyeval_0.2.0  
[31] munsell_0.4.3    broom_0.4.2   
and Rstudio version
$version
[1] ‘1.0.136’

 
    