check_bed_bin: process the bed file data to bin

Description Usage Arguments Author(s) Examples

View source: R/calbed.R

Description

process the bed file data to bin

Usage

1
check_bed_bin(m_bed, bin = 2000)

Arguments

m_bed
bin

Author(s)

Chao He

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
29
30
31
32
33
34
35
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (m_bed, bin = 2000)
{
    ooo = matrix(data = 0, nrow = dim(m_bed)[1], ncol = 4)
    for (i in 1:dim(m_bed)[1]) {
        st = (ceiling(m_bed[i, 2]/bin))
        ed = (ceiling(m_bed[i, 3]/bin))
        st1 = (ceiling((m_bed[i, 2] - 500)/bin))
        ed1 = (ceiling((m_bed[i, 3] + 500)/bin))
        if (st != ed) {
            ooo[i, 2] = st
            ooo[i, 3] = ed
            if (st1 != st) {
                ooo[i, 1] = st1
            }
            if (ed1 != ed) {
                ooo[i, 4] = ed1
            }
        }
        else {
            ooo[i, 2] = st
            if (st1 != st) {
                ooo[i, 1] = st1
            }
            if (ed1 != ed) {
                ooo[i, 4] = ed1
            }
        }
    }
    return(ooo)
  }

HBP documentation built on July 7, 2017, 9:02 a.m.

Related to check_bed_bin in HBP...