View source: R/plot_profiles.R
plot_profiles | R Documentation |
Produces profile plots based on scores from bigwig files and genomic intervals from GRanges/GRangesList objects.
plot_profiles( bigwigs, ranges, names = NULL, x.ticks = NULL, x.ticks.lab = NULL, x.ticks.angle = 0, x.ticks.kb = TRUE, x.gridmajor = TRUE, center.name = "center", ylab = "normalized counts", title = waiver(), subtitle = waiver(), colors = NULL, loess.span = NULL, legend.ncol = NULL, lwd = 0.75, return.melted = FALSE, CI.level = NULL, CI.reps = 500, CI.workers = NULL, CI.alpha = 0.2 )
bigwigs |
a vector with paths to bigwig files |
ranges |
genomic intervals to use as GRanges or GRangesList, see details |
names |
vector of same length as profiles to plot used as names for the legend, see details. |
x.ticks |
a numeric vector that indicates the x-axis ticks to use.
Allowed values are 1 to |
x.ticks.lab |
vector of same length as |
x.ticks.angle |
numeric value, rotate tick labels by this value |
x.ticks.kb |
logical, whether to use bp or kb as label for the default x.ticks.lab. See details. |
x.gridmajor |
logical, whether to add major vertical grid lines. Only relevant when using themes that actually have grid lines, e.g. theme_bw but not theme_minimal. |
center.name |
name of the x.ticks.lab when x.ticks=NULL, see details. |
ylab |
y-axis label |
title |
main title |
subtitle |
subtitle |
colors |
a vector of same length as profiles to plot with valid color names. If NULL then colors from a colorblind-friendly palette will be used. |
loess.span |
numeric, the alpha parameter from loess. If not NULL then use loess smoothing on each profile with this span. |
legend.ncol |
numeric if having multiple profiles arrange legend in that many columns |
lwd |
numeric, the line width, default is .75 |
CI.level |
numeric, if not NULL will calculate a confidence interval for every profile This value is then the confidence level, default is .95 for the 95th CI. |
CI.reps |
numeric, the number of bootstrap replicates |
CI.workers |
workers to parallelize the bootstrapping |
CI.alpha |
the opacity when plotting the CIs as geom_ribbon, default is .2 |
=> There are two modes this function can use.
1) Use one bigwig file and plot over one or multiple sets of genomic intervals.
If using one set then ranges must be a GRanges object. If multiple then ranges must be
a GRangesList. If the list is named will use these names for the legend, else will simply
name the sets as set1, set2... etc.
This mode could be useful in a situation where one wants to plot e.g. one ChIP-seq sample over
multiple genomic sites, e.g. a set of TSS and a set of distal enhancers.
2) Use many bigwig files and one set of genomic intervals.
In this case bigwigs
should be a vector of paths to multiple bigwigs.
The ranges
must then be a GRanges object. If no names
are provided then will
use the basenames of the bigwigs for the legend names.
=> Towards the tick parameters (x.ticks etc)
It is important to note that the ranges in this function are always relative towards
the provides genomic intervals. No matter what the genomic coordiantes are the ranges
will be treated as an interval from 1 to width(ranges)
, so if you provide intervals
of width 2kb (all ranges must have the same width btw) then the default behaviour is to plot
these intervals using as ticks the leftpost position, the center position and the rightmost position.
By default these are labelled as -(width(ranges)/2), center.name
and +(width(ranges)/2).
Means that for a 2kb interval one would get default ticks as -1kb, center, +1kb.
In this default mode is x.ticks.kb=TRUE
(default) will label the interval in "kb" as above,
and if FALSE then it would be labelled as 1000bp, center, +1000bp. Option only relevant if x.ticks=NULL
.
The center.name
argument then determines the name of "center" in this above example.
Not relevant if using custom ticks.
The ticks can be modified to any value between 1 and the width of the interval.
E.g. x.ticks<-c(1,500,2000)
will set the ticks to the start of the interval, 500bp and 2kb.
The vector can have any length. The x.ticks.lab
argument can be used to provide the names for
these ticks, must have same length as x.ticks
.
=> Towards the confidence intervals
If this option is turned on then function will use bootstrapping to estimate confidence intervals
for every profile. Technically the profiles are the colMeans of the scores for every basepair of
the genomic interval. The function will then bootstrap the scores to estimate CIs for these colMeans
and add it to the plot as via geom_ribbon. The bootstrapping is repeated CI
.reps times.
This is all done with the boot package with code adapted from the Bioconductor package ChIPseeker.
This does not make sense together with loess.span
so with loess smoothing.
Alexander Toenges
# Parsing bigwigs/GRanges into a basepair-resolution ScoreMatrix: genomation: a toolkit to summarize, annotate and visualize genomic intervals Akalin, A et al (2014) Bioinformatics, Volume 31, Issue 7, 1 April 2015, Pages 1127–1129 https://doi.org/10.1093/bioinformatics/btu775
# colorblind-friendly color palette: dittoSeq: universal user-friendly single-cell and bulk RNA sequencing visualization toolkit Bunis et al (2020) Bioinformatics, btaa1011, https://doi.org/10.1093/bioinformatics/btaa1011
# an example plot ranges=readRDS(paste0(system.file("extdata",package="vizzy"), "/example_ranges.rds")) ranges2=GRangesList(group1=ranges[1:50],group2=ranges[51:100]) bigwigs=list.files(system.file("extdata", package="vizzy"), pattern = ".bigwig", full.names = TRUE) # set a common theme: theme_set(theme_bw(base_size=15)) # multiple bigwigs over one set of regions with CIs plot_profiles(bigwigs=bigwigs, ranges=ranges, CI.level=.95, CI.reps=50) # one bigwigs over multiple sets of peaks with CIs plot_profiles(bigwigs=bigwigs[1], ranges=ranges2, CI.level=.95, CI.reps=50) # custom ticks, could be positions relative to the start of the ranges being a TSS: my.ticks <- c(1, 200, 500, 1000, 2000) plot_profiles(bigwigs=bigwigs, ranges=ranges, x.ticks=my.ticks, x.ticks.angle=45, x.ticks.lab=c("TSS", "+0.2kb", "+0.5kb", "+1kb", "+2kb"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.