View source: R/core_mutSignatures_scr_5.R
1 | plotMutCount(mutCount, top = 50)
|
mutCount |
|
top |
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 | ##---- 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 (mutCount, top = 50)
{
if (class(mutCount) == "mutationExposure") {
mutCount <- as.data.frame(mutCount)
}
rownames(mutCount) <- NULL
mutCount <- mutCount[order(apply(mutCount, 1, sum), decreasing = TRUE),
]
rownames(mutCount) <- NULL
if (is.null(top)) {
mutDF <- table2df(dataMatrix = mutCount)
}
else if (is.na(top[1]) | top[1] > nrow(mutCount) | top[1] <
2) {
mutDF <- table2df(dataMatrix = mutCount)
}
else {
mutDF <- table2df(dataMatrix = mutCount[1:top, ])
}
mutDF$sample <- 1e+05 + as.numeric(as.character(mutDF$sample))
mutDF$sample <- as.character(mutDF$sample)
mutDF$feature <- factor(mutDF$feature, levels = rev(colnames(mutCount)))
bp <- ggplot(data = mutDF, aes(x = sample, y = count, fill = feature)) +
geom_bar(stat = "identity")
bp <- bp + theme_minimal() + theme(axis.ticks.x = element_blank(),
axis.text.x = element_blank(), panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) + theme(axis.line.y = element_line(colour = "black",
size = 0.75), axis.line.x = element_line(colour = "black",
size = 0.75), axis.ticks.y = element_line(colour = "black",
size = 1), axis.ticks.length = unit(x = 6, "points"),
plot.title = element_text(hjust = 0.5)) + scale_y_continuous(expand = c(0,
0), limits = c(0, 1.2 * max(apply(mutCount, 1, function(rx) sum(rx,
na.rm = TRUE)))))
return(bp)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.