View source: R/plot_spectrum.R
plot_spectrum | R Documentation |
Plot point mutation spectrum
plot_spectrum( type_occurrences, CT = FALSE, by = NA, indv_points = FALSE, error_bars = c("95%_CI", "stdev", "SEM", "none"), colors = NA, legend = TRUE, condensed = FALSE )
type_occurrences |
Type occurrences matrix |
CT |
Distinction between C>T at CpG and C>T at other sites, default = FALSE |
by |
Optional grouping variable |
indv_points |
Whether to plot the individual samples as points, default = FALSE |
error_bars |
The type of error bars to plot. * '95 * 'stdev' for standard deviations; * 'SEM' for the standard error of the mean (NOT recommended); * 'none' Do not plot any error bars; |
colors |
Optional color vector with 7 values |
legend |
Plot legend, default = TRUE |
condensed |
More condensed plotting format. Default = F. |
Spectrum plot
read_vcfs_as_granges
,
mut_type_occurrences
## See the 'read_vcfs_as_granges()' example for how we obtained the ## following data: vcfs <- readRDS(system.file("states/read_vcfs_as_granges_output.rds", package = "MutationalPatterns" )) ## Load a reference genome. ref_genome <- "BSgenome.Hsapiens.UCSC.hg19" library(ref_genome, character.only = TRUE) ## Get the type occurrences for all VCF objects. type_occurrences <- mut_type_occurrences(vcfs, ref_genome) ## Plot the point mutation spectrum over all samples plot_spectrum(type_occurrences) ## Or with distinction of C>T at CpG sites plot_spectrum(type_occurrences, CT = TRUE) ## You can also include individual sample points. plot_spectrum(type_occurrences, CT = TRUE, indv_points = TRUE) ## You can also change the type of error bars plot_spectrum(type_occurrences, error_bars = "stdev") ## Or plot spectrum per tissue tissue <- c( "colon", "colon", "colon", "intestine", "intestine", "intestine", "liver", "liver", "liver" ) plot_spectrum(type_occurrences, by = tissue, CT = TRUE) ## Or plot the spectrum per sample. Error bars are set to 'none', because they can't be plotted. plot_spectrum(type_occurrences, by = names(vcfs), CT = TRUE, error_bars = "none") ## Plot it in a more condensed manner, ## which is is ideal for publications. plot_spectrum(type_occurrences, by = names(vcfs), CT = TRUE, error_bars = "none", condensed = TRUE) ## You can also set custom colors. my_colors <- c( "pink", "orange", "blue", "lightblue", "green", "red", "purple" ) ## And use them in a plot. plot_spectrum(type_occurrences, CT = TRUE, legend = TRUE, colors = my_colors )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.