R/getgc.R

Defines functions getgc

Documented in getgc

getgc <- function(chr, ref) {
    if (chr == "X" | chr == "x" | chr == "chrX" | chr == "chrx") {
        chrtemp <- 23
    } else if (chr == "Y" | chr == "y" | chr == "chrY" | chr == "chry") {
        chrtemp <- 24
    } else {
        chrtemp <- as.numeric(mapSeqlevels(as.character(chr), "NCBI")[1])
    }
    if (length(chrtemp) == 0) 
        message("Chromosome cannot be found in NCBI Homo sapiens database!")
    chrm <- unmasked(Hsapiens[[chrtemp]])
    seqs <- Views(chrm, ref)
    af <- alphabetFrequency(seqs, baseOnly = TRUE, as.prob = TRUE)
    gc <- round((af[, "G"] + af[, "C"]) * 100,2)
    gc
}

Try the CODEX package in your browser

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

CODEX documentation built on Nov. 8, 2020, 8:22 p.m.