-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplot_event_count_vs_chr_length.R
executable file
·39 lines (30 loc) · 1.6 KB
/
plot_event_count_vs_chr_length.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env Rscript
##############################################################
# script: plot_event_count_vs_chr_length.R
# author: Jia-Xing Yue (GitHub ID: yjx1217)
# last edited: 2019.10.11
# description: plot the relationship between recombination event count and chromosome lengths
# example: Rscript --vanilla plot_event_count_vs_chr_length.R --input prefix.event_count_vs_chr_length.summary.txt --output prefix.event_count_vs_chr_length.summary.pdf
###############################################################
library(ggplot2)
library(optparse)
library(scales)
option_list <- list(
make_option(c("--input"), type = "character", default = NULL,
help = "the summary table generated by event_count_vs_chr_length.plreference genome [default=%default]", metavar = "character"),
make_option(c("--output"), type = "character", default = "out.pdf",
help = "the file name for the ouput plot [default=%default]", metavar = "character")
);
opt_parser <- OptionParser(option_list = option_list)
opt <- parse_args(opt_parser)
data <- read.table(opt$input,
sep = "\t",
header = TRUE)
ggplot(data, aes(x = chr_length/1000, y = event_count_mean, color = chr)) +
geom_point() +
geom_errorbar(aes(ymin = event_count_mean - event_count_stderr, ymax = event_count_mean + event_count_stderr)) +
scale_x_continuous("Chromosome length (kb)") +
scale_y_continuous("Recombination event count per chromosome per tetrad") +
facet_wrap(~ event_type) +
theme_bw()
ggsave(filename = opt$output, device = "pdf", width = 8, height = 6, limitsize = FALSE)