#' Plot the MCMC chains for the signature exposure solutions
#'
#' This function allows one to visualize the solution chains for the exposure
#' of each mutation signature. It plots each chain as a line graph, allowing
#' one to inspect for convergence.
#'
#' @param exposures_mcmc_output Output from running plot_exposures
#'
#' @return A ggplot object
#'
#' @import ggplot2
#' @import magrittr
#'
#' @export
plot_exposure_chain <- function(exposures_mcmc_output, signature_trim='Signature') {
exposures_mcmc_output$exposure_chain %>%
mutate(
chain = factor(chain),
signature = trim_signature_names(signature, signature_trim)
) %>%
ggplot(aes(
y = exposure,
x = iteration,
group = chain,
colour = chain
)) +
facet_grid(signature ~ .) +
geom_line() +
scale_colour_brewer(palette = 'Set1')
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.