Skip to content

Commit

Permalink
add report name option and example
Browse files Browse the repository at this point in the history
  • Loading branch information
stevekm committed Jul 31, 2017
1 parent 9dbd406 commit b462646
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions compile-report.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env Rscript

## USAGE: compile_RMD_report.R report.Rmd
## EXAMPLE: ./compile-report.R -n "peaks.by_sample.macs_broad" --height 42 --width 12 results/peaks.by_sample.macs_broad
## Requires pandoc version 1.13+
# module load pandoc/1.13.1

Expand All @@ -15,7 +16,7 @@ library("tools")

# ~~~~~ GET SCRIPT ARGS ~~~~~~~ #
option_list <- list(
make_option(c("-n", "--name"), type="character", default=FALSE,
make_option(c("-n", "--name"), type="character", default='peaks-report',
dest="report_name", help="A different output name to use for the report file (excluding file extension)"),
make_option(c("--height"), type="numeric", default=12,
dest = "plot_height", help="Height for boxplot [default %default]",
Expand Down Expand Up @@ -45,4 +46,5 @@ if(report_name != FALSE){
}
rmarkdown::render(input = Rmdfile, params = list(input_dir = input_dir,
plot_height = plot_height,
plot_width = plot_width))
plot_width = plot_width,
report_name = report_name))
3 changes: 3 additions & 0 deletions peaks-report.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ params:
input_dir: "/path/to/peaks_dir"
plot_height: 12
plot_width: 10
report_name: "peaks_report"
---

```{r setup, include=FALSE}
Expand Down Expand Up @@ -85,12 +86,14 @@ make_peaks_barplot <- function(df){
input_dir <- normalizePath(params$input_dir)
plot_height <- as.numeric(params$plot_height)
plot_width <- as.numeric(params$plot_width)
report_name <- as.character(params$report_name)
bed_df <- make_bed_df(input_dir = input_dir)
peaks_barplot <- make_peaks_barplot(df = bed_df)
save.image(file = "loaded_data.Rdata", compress = TRUE)
write.table(x = bed_df, file = sprintf("%s.csv", report_name), quote = FALSE, sep = ',', row.names = FALSE, col.names = TRUE)
```

# Input dir
Expand Down

0 comments on commit b462646

Please sign in to comment.