Created
August 29, 2016 17:46
-
-
Save danielecook/c9bf690eddb6ae2b6d4c45f1b93dfd75 to your computer and use it in GitHub Desktop.
Plot NIL/RIL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(dplyr) | |
df <- readr::read_tsv("<your_file>") %>% | |
dplyr::group_by(sample) %>% | |
dplyr::filter(chrom != "MtDNA") %>% | |
dplyr::mutate(gt = ifelse(gt == 1, "parent_1", "parent_2")) | |
df$index <- dplyr::group_indices(df) | |
strain_index <- df$sample | |
names(strain_index) <- df$index + 0.5 | |
ggplot(df) + | |
geom_rect(aes(xmin = start, xmax = end, ymin = index, ymax = index + 1, fill = gt)) + | |
scale_fill_manual(values = c("#0080FF", "#FF8000")) + | |
facet_grid(.~chrom, scales="free", space="free") + | |
theme_bw() + | |
scale_x_continuous(labels = function(x) { x/1e6 }, expand = c(0,0)) + | |
scale_y_continuous(breaks = unique(df$index) + 0.5, labels = function(x) { strain_index[as.character(x)] }, expand = c(0,0)) + | |
theme(strip.background = element_blank(), | |
legend.position = "None") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment