plot_metagene: Plots the metagene coverage data

Description Usage Arguments Details Value Examples

View source: R/metagene_functions.R

Description

The function plot_metagene plots the metagene site coverage, separating by experiment.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
plot_metagene(
  x,
  site,
  experiment,
  range.lower,
  range.upper,
  normalize = FALSE,
  title = "Metagene Site Coverage",
  tick = 10
)

Arguments

x

A 'Ribo' object or a data frame generated from get_metagene

site

"start" or "stop" site

experiment

list of experiments

range.lower

lower bound of the read length, inclusive

range.upper

upper bound of the read length, inclusive

normalize

When TRUE, normalizes the data by the total reads.

title

title of the generated plot

tick

x-axis labeling increment

Details

If a DataFrame is provided as param 'x', then the only additional parameter is the optional title' parameter for the generated plot. If a ribo.object is provided as param 'x', the rest of the parameters listed are necessary.

When given a ribo class object, the plot_metagene function generates a DataFrame by calling the get_tidy_metagene function, so the run times in this case will be mostly comprised of a call to the get_metagene function.

This function uses ggplot in its underlying implementation.

Value

A 'ggplot' of the metagene site coverage

Examples

 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
#a potential use case is to directly pass in the ribo object file as param 'x'

#generate the ribo object to directly use
file.path <- system.file("extdata", "sample.ribo", package = "ribor")
sample <- Ribo(file.path)

#specify experiments of interest
experiments <- c("Hela_1", "Hela_2", "WT_1")

#plot the metagene start site coverage for all experiments in 'sample.ribo'
#from read length 2 to 5
plot_metagene(x = sample,
              site = "start",
              range.lower = 2,
              range.upper = 5,
              experiment = experiments)

#Note that the site, range.lower, range.upper, and experiment parameter are only
#necessary if a ribo object is being passed in as param 'x'. If a ribo
#object is passed in, then the param 'experiments' will be set to all of
#the experiments by default.

#If a DataFrame is passed in, then the plot_metagene function
#does not need any other information. All of the elements of the DataFrame
#will be used, assuming that it contains the same column names and number of
#columns as the output from get_tidy_metagene()

#gets the metagene start site coverage from read length 2 to 5
#note that the data must be summed across transcripts and read lengths
#for the plot_metagene function
data <- get_tidy_metagene(sample,
                          site = "start",
                          range.lower = 2,
                          range.upper = 5)

#plot the metagene data
plot_metagene(data)

ribosomeprofiling/ribor documentation built on May 21, 2021, 8:02 a.m.