Generate plots of TSS or TSR positional density relative to annotated TSSs.

plot_density(
  experiment,
  data_type = c("tss", "tsr"),
  samples = "all",
  consider_score = FALSE,
  upstream = 1000,
  downstream = 1000,
  threshold = NULL,
  ncol = 1,
  use_normalized = FALSE,
  dominant = FALSE,
  exclude_antisense = TRUE,
  data_conditions = NULL,
  color = "default",
  ...
)

Arguments

experiment

TSRexploreR object.

data_type

Whether to plot TSS ('tss') or TSR ('tsr') density.

samples

A vector of sample names to analyze.

consider_score

Whether the score of each TSS or TSR score should be be considered in addition to its unique location.

upstream

Bases upstream of plot center.

downstream

Bases downstream of plot center.

threshold

TSSs or TSRs with a score below this value will not be considered.

ncol

Integer specifying the number of columns to arrange multiple plots.

use_normalized

Whether to use the normalized (TRUE) or raw (FALSE) counts.

dominant

If TRUE, will only consider the highest-scoring TSS per gene, transcript, or TSR or highest-scoring TSR per gene or transcript.

exclude_antisense

Remove antisense TSSs/TSRs prior to analysis.

data_conditions

Apply advanced conditions to the data.

color

Either 'default' or a valid color format to set plot color.

...

Arguments passed to geom_density.

Value

ggplot2 object of density plot.

Details

This plotting function generates a density plot of TSS or TSR positions relative to annotated TSSs. The plot is returned as a ggplot2 object.

By default, only the TSS or TSR position is considered, effectively giving every TSS or TSR a score of 1. If 'consider_score' is set to TRUE, the score of each TSS or TSR will be considered when making the plot, giving more weight to stronger TSSs or TSRs.

The region around the annotated TSS used for plotting is controlled by 'upstream' and 'downstream', which should be positive integers.

A set of functions to control data structure for plotting are included. 'use_normalized' will use normalized scores, which only matters if 'consider_score' is TRUE. 'threshold' defines the minimum number of raw counts a TSS or TSR must have to be considered. dominant' specifies whether only the dominant TSS or TSR (determined using the 'mark_dominant' function) is considered. For TSSs, this can be either dominant TSS per TSR or gene/transcript, and for TSRs it is the dominant TSR per gene/transcript. 'data_conditions' can be used to filter, quantile, order, and/or group data for plotting. Finally, 'exclude_antisense' removes anti-sense TSSs or TSRs prior to plotting.

See also

annotate_features to annotate TSSs or TSRs.

Examples

data(TSSs_reduced) annotation <- system.file("extdata", "S288C_Annotation.gtf", package="TSRexploreR") exp <- TSSs_reduced %>% tsr_explorer(genome_annotation=annotation) %>% format_counts(data_type="tss") %>% annotate_features(data_type="tss")
#> Import genomic features from the file as a GRanges object ...
#> OK
#> Prepare the 'metadata' data frame ...
#> OK
#> Make the TxDb object ...
#> Warning: The "phase" metadata column contains non-NA values for features of type #> stop_codon. This information was ignored.
#> OK
p <- plot_density(exp, data_type="tss")