Description Usage Arguments Details Value See Also Examples
View source: R/plot_spectrum_region.R
A spectrum similar to the one from 'plot_spectrum()' is plotted. However the spectrum is plotted separately per genomic region. As input it takes a 'type_occurrences' matrix that was calculated per genomic region. To get a 'type_occurrences' matrix per region, first use the 'split_muts_region()' function on a GR or GRangesList. Then use the 'mut_type_occurrences' as you would normally. The by, colors and legend argument work the same as in 'plot_spectrum()'.
1 2 3 4 5 6 7 8 9 10 |
type_occurrences |
Type occurrences matrix |
by |
Optional grouping variable |
mode |
The y-axis plotting mode. * 'relative_sample', the number of variants will be shown divided by the total number of variants in that sample; * 'relative_sample_feature', the number of variants will be shown divided by the total number of variants in that sample and genomic region (Default); * 'absolute' The absolute number of mutations is shown; |
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. |
The y-axis can be plotted with three different modes. With 'relative_sample_feature', the number of variants will be shown divided by the total number of variants in that sample and genomic region. This is generally the most usefull, because it allows you to compare the spectra off different regions. When you use 'relative_sample', the number of variants will be shown divided by the total number of variants in that sample. This can be usefull when you want to compare the number of mutations between regions. Finally, when you use 'absolute', the absolute mutation numbers are shown. This can be usefull when you want to compare the mutation load between different groups of samples.
Spectrum plot by genomic region
read_vcfs_as_granges
,
mut_type_occurrences
,
plot_spectrum
,
split_muts_region
Other genomic_regions:
bin_mutation_density()
,
lengthen_mut_matrix()
,
plot_profile_region()
,
split_muts_region()
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 | ## See the 'split_muts_region()' example for how we obtained the
## following data:
grl <- readRDS(system.file("states/grl_split_region.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(grl, ref_genome)
## Plot the relative point mutation spectrum per genomic region
plot_spectrum_region(type_occurrences)
## Include the individual sample points
plot_spectrum_region(type_occurrences, indv_points = TRUE)
## Plot the relative point mutation spectrum per genomic region,
## but normalize only for the samples
plot_spectrum_region(type_occurrences, mode = "relative_sample")
## Plot the absolute point mutation spectrum per genomic region
plot_spectrum_region(type_occurrences, mode = "absolute")
## Plot the point mutations spectrum with different error bars
plot_spectrum_region(type_occurrences, error_bars = "stdev")
## Plot the relative point mutation spectrum per sample type and per genomic region
## Determine tissue names
tissue <- c(
"colon", "colon", "colon",
"intestine", "intestine", "intestine",
"liver", "liver", "liver"
)
plot_spectrum_region(type_occurrences, by = tissue)
## Plot the relative point mutation spectrum per individual sample and per genomic region
## Determine sample names
sample_names <- c(
"colon1", "colon2", "colon3",
"intestine1", "intestine2", "intestine3",
"liver1", "liver2", "liver3"
)
plot_spectrum_region(type_occurrences, by = sample_names, error_bars = "none")
## Plot it in a more condensed manner,
## which is is ideal for publications.
plot_spectrum_region(type_occurrences,
by = sample_names,
error_bars = "none",
condensed = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.