Learn R Programming

HBP (version 0.1.2)

check_bed_bin: process the bed file data to bin

Description

process the bed file data to bin

Usage

check_bed_bin(m_bed, bin = 2000)

Arguments

m_bed

bin

Examples

Run this code
# NOT RUN {
##---- 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)
  }
# }

Run the code above in your browser using DataLab