downsample_ChIPpeaks: Function for downsampling peaks in ChIP-data to simulate...

Description Usage Arguments Value Examples

View source: R/peakDownSampling.R

Description

Function to downsample bam files: reads ChIP and Input bam files, calles peaks and removes randomly 60percent of the reads from the peaks. Returns a downsampled ChIP dataframe.

downsample_ChIPpeaks

Usage

1
2
3
4
5
6
7
8
downsample_ChIPpeaks(
  chip.data,
  input.data,
  read_length,
  annotationID = "hg19",
  mc = 1,
  debug = FALSE
)

Arguments

chip.data

data-structure with tag information reads from bam file (see readBamFile())

input.data

data-structure with tag information reads from bam file (see readBamFile())

read_length

Integer, length of the reads

annotationID

String, indicating the genome assembly (Default="hg19")

mc

Integer, the number of CPUs for parallelization (default=1)

debug

Boolean, to enter debugging mode. Intermediate files are saved in working directory

Value

chip.dataDownSampeld, data-structure with downsampled tags

Examples

 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
## This command is time intensive to run

## To run this example code the user MUST provide 2 bam files: one for ChIP 
## and one for the input". Here we used ChIP-seq data from ENCODE. Two 
## example files can be downloaded using the following link:
## https://www.encodeproject.org/files/ENCFF000BFX/
## https://www.encodeproject.org/files/ENCFF000BDQ/
## and save them in the working directory (here given in the temporary 
## directory "filepath"

mc=4
## Not run: 

filepath=tempdir()
setwd(filepath)

data("chipSubset", package = "ChIC.data", envir = environment())
chipBam=chipSubset
data("inputSubset", package = "ChIC.data", envir = environment())
inputBam=inputSubset
chip.dataNew=downsample_ChIPpeaks(chip.data=chipBam, 
   input.data=inputBa, read_length=read_length,
   annotationID="hg19", mc=mc, debug=FALSE)

message(" downsampling from", sum(unlist(lapply(chipBam$tags,length)))," to ",
sum(unlist(lapply(chip.dataNew$tags,length))))

## End(Not run)

carmencita/CHIC documentation built on May 2, 2021, 5:09 p.m.