Skip to content

Instantly share code, notes, and snippets.

@msonnabaum
Created April 28, 2015 18:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msonnabaum/4b8b60dcf48d7967a370 to your computer and use it in GitHub Desktop.
Save msonnabaum/4b8b60dcf48d7967a370 to your computer and use it in GitHub Desktop.
if (!"ggplot2" %in% rownames(installed.packages())) {
install.packages("ggplot2")
}
library("ggplot2")
args <- commandArgs(trailingOnly = TRUE)
before_file <- args[1]
after_file <- args[2]
if (!file.exists(before_file)) stop(paste(before_file, "does not exist!"))
if (!file.exists(after_file)) stop(paste(after_file, "does not exist!"))
df1 <- read.table(before_file, sep="\t", header = TRUE)
df2 <- read.table(after_file, sep="\t", header = TRUE)
df1$test <- "before"
df2$test <- "after"
df <- rbind(df1, df2)
svg("histogram_interleaved.svg", width = 7, height = 4)
ggplot(df, aes(ttime, fill = test)) +
scale_x_continuous(breaks = seq(min(df$ttime), max(df$ttime))) +
geom_histogram(binwidth = 1, position="dodge")
svg("histogram_facet.svg", width = 7, height = 4)
ggplot(df, aes(ttime, fill = test)) +
geom_histogram(binwidth = 1) +
facet_wrap(~test, ncol = 1)
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment