R/distalAdj.R

Defines functions distalAdj

Documented in distalAdj

distalAdj <- function(distalCPs, classifier, classifier_cutoff,
                      shift_range, genome, step=1){
    dCPs <- distalCPs$dCPs
    next.exon.gap <- distalCPs$next.exon.gap
    gap.cov <- mapply(function(gap, cp, ID, strand){
        if(cp>0){
            coor <- as.integer(gsub("^.*_SEP_", "", names(gap[1:cp])))
            start <- coor[length(coor)]
            end <- ifelse(length(coor) > 2*shift_range, 
                          coor[length(coor)-2*shift_range], 
                          coor[1])
            pos <- seq(start, end, by=ifelse(strand=="+", -1*step, 1*step))
            idx <- match(pos, coor)
            cbind(pos, idx, ID)
        }else{
            NULL
        }
    }, next.exon.gap, dCPs$distalCP, 
    1:length(next.exon.gap), dCPs$strand,
    SIMPLIFY=FALSE)
    gap.cov <- do.call(rbind, gap.cov)
    if(length(gap.cov)>0){
        idx <- PAscore2(dCPs$seqnames[gap.cov[, "ID"]],
                        gap.cov[, "pos"],
                        dCPs$strand[gap.cov[, "ID"]],
                        gap.cov[, "idx"],
                        gap.cov[, "ID"],
                        genome, classifier, classifier_cutoff)
        distalCPs$dCPs[idx$idx.gp, "distalCP"] <- idx$idx
    }
    distalCPs
}

Try the InPAS package in your browser

Any scripts or data that you put into this service are public.

InPAS documentation built on Nov. 8, 2020, 5:03 p.m.