View source: R/core_mutSignatures_scr_5.R
1 | removeMismatchMut(mutData, refMut_colName = "mutation", context_colName = "context", refMut_format = "N>N")
|
mutData |
|
refMut_colName |
|
context_colName |
|
refMut_format |
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 | ##---- 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 (mutData, refMut_colName = "mutation", context_colName = "context",
refMut_format = "N>N")
{
if (!((is.data.frame(mutData) | is.matrix(mutData)) & sum(c(refMut_colName,
context_colName) %in% colnames(mutData)) == 2))
stop("Issue with the input dataset. Make sure to feed in a data.frame or\n a matrix and double check the name of the fields pointing to chromosome\n name, start and end positions")
if (!refMut_format %in% c("N>N", "N"))
stop("Unrecognized refMut_format")
output <- data.frame(mutData, stringsAsFactors = FALSE, row.names = NULL)
colnames(output) <- colnames(mutData)
if (refMut_format == "N>N") {
output$mutSite.dnaSeq.Ref <- substr(mutData[, refMut_colName],
1, 1)
output$mutSite.dnaSeq.Mut <- substr(mutData[, refMut_colName],
3, 3)
refMut_colName <- "mutSite.dnaSeq.Ref"
}
pos.to.extr <- (0.5 * (nchar(output[, context_colName]) -
1)) + 1
keep.id <- output[, refMut_colName] == substr(output[, context_colName],
pos.to.extr, pos.to.extr)
if (sum(keep.id == FALSE) > 0)
message(paste("Removing", sum(keep.id == FALSE), "rows because of mismatch"))
output <- output[keep.id, ]
rownames(output) <- NULL
return(output)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.