Skip to content

Commit

Permalink
Add installation instructions to README. Edit function documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomrrr1 committed Mar 4, 2024
1 parent 990288c commit 9a80456
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 15 deletions.
2 changes: 1 addition & 1 deletion R/conservative_idr.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' @returns A list containing a summary of the IDR analysis along with the path
#' to the output files.
#'
#' @export
#' @keywords internal

conservative_idr <- function(treat_files,
control_files = NULL,
Expand Down
2 changes: 1 addition & 1 deletion R/feature_counts_matrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ feature_counts_matrix <- function(peak_file,
# Read the peak file and subset desired columns
peak <-
utils::read.table(peak_file, header = FALSE)
peak_df <- peak[, c(4, 1, 2, 3, 6)]
peak_df <- peak[, c(4, 1, 2, 3, 6)] # name, chr, start, end, strand

# Set column names for SAF format
colnames(peak_df) <- c("GeneID", "Chr", "Start", "End", "Strand")
Expand Down
2 changes: 1 addition & 1 deletion R/optimal_idr.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#'
#' @returns Summary of the IDR output
#'
#' @export
#' @keywords internal
optimal_idr <- function(treat_files,
control_files = NULL,
is_paired,
Expand Down
16 changes: 9 additions & 7 deletions R/pool_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
#'
#' @param named_list A named list containing paths to BAM files.
#' This list is outputted from the `prepare_named_list` function.
#'
#' The list includes:
#' \itemize{
#' \item{"treatment_file_1"}{Path to the first treatment replicate.}
#' \item{"treatment_file_2"}{Path to the second treatment replicate.}
#' \item{"control_file_1"}{Optional. Path to the first control replicate.}
#' \item{"control_file_2"}{Optional. Path to the second control replicate.}
#' }
#' - "treatment_file_1" Path to the first treatment replicate.
#' - "treatment_file_2" Path to the second treatment replicate.
#' - "control_file_1" Optional. Path to the first control replicate.
#' - "control_file_2" Optional. Path to the second control replicate.
#'
#' @param out_dir The directory where the merged BAM files will be saved.
#' @return Vector containing file paths to the output BAM files
#'
#' @keywords internal

pool_files <- function(named_list,
pool_files <- function(named_list, # formatted by prepare_named_list
out_dir) {
rep1 <- named_list[["treatment_file_1"]]
rep2 <- named_list[["treatment_file_2"]]
Expand Down
2 changes: 2 additions & 0 deletions R/prepare_named_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#' "treatment_file_2", "control_file_1", and "control_file_2", corresponding
#' to the provided file paths. The list is filtered to exclude any that are
#' NULL.
#'
#' @keywords internal

prepare_named_list <- function(treat_files,
control_files = NULL) {
Expand Down
2 changes: 1 addition & 1 deletion R/process_peak_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ process_peak_file <- function(peak_list,
for (i in seq_along(peak_files)) {
peak_file <- peak_files[i]
peak <- utils::read.table(peak_file, header = FALSE)
peak_df <- peak[, c(1, 2, 3, 4, 8, 6)] # macs3 columns required for MSPC
peak_df <- peak[, c(1, 2, 3, 4, 8, 6)] # MACS3 columns required for MSPC

output_file_path <- file.path(out_dir,
paste0("processed_peak_rep_", i, ".bed"))
Expand Down
59 changes: 55 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,60 @@ Authors: <i>Thomas Roberts</i>
</h4>
2024-02-04

## R Markdown
## Introduction

Package for calling consensus peaks from multiple biological replicates.
`ConsensusPeak` is an R Package for calling consensus peaks from multiple
biological replicates. We implement several methods for thresholding, including
IDR conservative, IDR optimal, MSPC and ChIP-R.

The package is unsupported on Windows because of its use of MACSr, a
bioconductor package that is itself unsupported.
## Installation

```R
if(!require("remotes")) install.packages("remotes")
remotes::install_github("neurogenomics/ConsensusPeak")
```

## Usage

Load example data:

```R
rep_treat_1 <- system.file("extdata",
"r1_creb_chr22.bam",
package = "ConsensusPeak")
rep_treat_2 <- system.file("extdata",
"r2_creb_chr22.bam",
package = "ConsensusPeak")
```

Run MACS3 peak calling and IDR thresholding with a single command:

```R
result <- conservative_idr(
treat_files = c(rep_treat_1, rep_treat_2),
out_dir = ".", # Directory to write the output files
idr_stringent = TRUE, # Threshold at 0.01 or 0.05
is_paired = FALSE, # Is the data paired-end?
nomodel = TRUE # MACS3 setting
)
```




















0 comments on commit 9a80456

Please sign in to comment.