View source: R/core_mutSignatures_scr_5.R
1 | prelimProcessAssess(input, maxProcess = 6, approach = "counts", plot = TRUE, verbose = TRUE)
|
input |
|
maxProcess |
|
approach |
|
plot |
|
verbose |
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | ##---- 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 (input, maxProcess = 6, approach = "counts", plot = TRUE,
verbose = TRUE)
{
tmpParams <- setMutClusterParams(num_processesToExtract = 1,
approach = approach, stopconv = 10000, niter = 1e+05,
thresh_removeWeakMutTypes = 0.01, thresh_removeLastPercent = 0.025,
num_totIterations = 10, num_parallelCores = 1, debug = FALSE,
logIterations = "full")
tmpParams <- as.list(tmpParams)
input_mutCounts <- as.matrix(input)
if (tmpParams$approach != "counts") {
tmpFRQ.input <- frequencize(input_mutCounts)
tmpParams$approach <- "counts"
input_mutCounts <- tmpFRQ.input$freqs
}
bckgrnd.removed.mutCounts <- removeWeak(input_mutCounts,
tmpParams)
bckgrnd.removed.mutset <- bckgrnd.removed.mutCounts$removed.mutset
bckgrnd.removed.mutCounts <- bckgrnd.removed.mutCounts$output.mutCounts
total.mutationTypes <- nrow(bckgrnd.removed.mutCounts)
total.samples <- ncol(bckgrnd.removed.mutCounts)
tmpParams$num_totIterations <- 1
medianMaxErr <- sum(t(sapply(1:nrow(bckgrnd.removed.mutCounts),
(function(i) {
((median(bckgrnd.removed.mutCounts[i, ]) - bckgrnd.removed.mutCounts[i,
]))^2
}))))
if (verbose)
message("Preliminary Mutational Process Assessment: ",
appendLF = FALSE)
outRes <- lapply(1:maxProcess, (function(i) {
tmpParams$num_processesToExtract <- i
tmpRes <- suppressWarnings(suppressMessages(extractSignatures(mutCountMatrix = bckgrnd.removed.mutCounts,
params = tmpParams, bootStrap = FALSE)))
tmpErr <- sum((bckgrnd.removed.mutCounts - tmpRes$mutCounts.reconstructed)^2)
if (verbose)
message(".", appendLF = FALSE)
tmpErr
}))
if (verbose)
message("", appendLF = TRUE)
err.points <- c(medianMaxErr, do.call(c, outRes))
err.points <- (-1) * (err.points - max(err.points))
err.points <- err.points/max(err.points, na.rm = TRUE)
if (plot) {
plot(err.points ~ c(0:(length(err.points) - 1)), type = "n",
las = 1, axes = FALSE, ylab = "", xlab = "", main = "Preliminary Mutational Process Assessment")
axis(side = 1, at = NULL, cex = 0.65, font = 3)
axis(side = 2, at = seq(0, 1, by = 0.2), cex = 0.65,
font = 3, labels = format(seq(1, 0, by = -0.2), digits = 2,
nsmall = 2), las = 1)
lines(c(0:(length(err.points) - 1)), err.points, lwd = 1.5,
col = "red2")
points(c(0:(length(err.points) - 1)), err.points, pch = 19,
col = "gray30")
title(xlab = "Num of Signatures", line = 2.2, cex.lab = 1.2,
font = 2)
title(ylab = "Error (% vs. Median)", line = 3.1, cex.lab = 1.2,
font = 2)
box()
}
return(data.frame(numProcess = c(0:(length(err.points) -
1)), percentErr = (1 - err.points), stringsAsFactors = TRUE))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.