Recursively find peak/picard files stored within subdirectories and import them as a list of GRanges objects.

gather_files(
  dir,
  type = "peaks.stringent",
  nfcore_cutandrun = FALSE,
  return_paths = FALSE,
  rbind_list = FALSE,
  workers = check_workers(),
  verbose = TRUE
)

Arguments

dir

Directory to search within.

type

File type to search for. Options include:

  • "<pattern>"Finds files matching an arbitrary regex pattern specified by user.

  • "peaks.stringent"Finds files ending in "*.stringent.bed$"

  • "peaks.consensus"Finds files ending in "*.consensus.peaks.bed$"

  • "peaks.consensus.filtered" Finds files ending in"*.consensus.peaks.filtered.awk.bed$"

  • "picard"Finds files ending in "*.target.markdup.MarkDuplicates.metrics.txt$"

nfcore_cutandrun

Whether the files were generated by the nf-core/cutandrun Nextflow pipeline. If TRUE, can use the standardised folder structure to automatically generate more descriptive file names with sample IDs.

return_paths

Return only the file paths without actually reading them in as GRanges.

rbind_list

Bind all objects into one.

workers

Number of cores to parallelise across (in applicable functions). If NULL, will set to the total number of available cores minus 1.

verbose

Print messages.

Value

A named list of GRanges objects.

Details

For "peaks.stringent" files called with SEACR, column names will be automatically added:

  • total_signal : Total signal contained within denoted coordinates.

  • max_signalMaximum bedgraph signal attained at any base pair within denoted coordinates.

  • max_signal_region Region representing the farthest upstream and farthest downstream bases within the denoted coordinates that are represented by the maximum bedgraph signal.

Examples

#### Make example files ####
save_paths <- EpiCompare::write_example_peaks()
#> Writing ==> /tmp/RtmpKu2U4A/processed_results/encode_H3K27ac.narrowPeaks.bed
#> Writing ==> /tmp/RtmpKu2U4A/processed_results/CnT_H3K27ac.narrowPeaks.bed
#> Writing ==> /tmp/RtmpKu2U4A/processed_results/CnR_H3K27ac.narrowPeaks.bed
dir <- unique(dirname(save_paths))
#### Gather/import files ####
peaks <- EpiCompare::gather_files(dir=dir, 
                                  type="peaks.narrow",
                                  workers = 1)
#> Searching for peaks.narrow files...
#> 3 matching files identified.
#> Constructing file names.
#> Importing files.
#> 3 files retrieved.