R/normalize.R

Defines functions normalizeMotifs

Documented in normalizeMotifs

normalizeMotifs <- function(x, norms) {
  
    ## find the 'from' sequence
    s = BStringSet(rownames(x))
    
    base_motif = subseq(s, 4, 6)
    subseq(base_motif, 2, 2) = subseq(s, 1, 1)
    bs = as(base_motif, "character")
    
    ## check if the names are covered
    stopifnot(all(bs %in% names(norms)))
    
    idx = match(bs, names(norms))
    
    sss = as.vector(norms[idx])

    stopifnot(nrow(x) == length(sss))
    y = x * sss ## checked

    return(y)
}

Try the SomaticSignatures package in your browser

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

SomaticSignatures documentation built on Nov. 8, 2020, 5:52 p.m.