plot_region_counts {ribor} | R Documentation

## Plots the region counts of UTR5, CDS, and UTR3

### Description

The function `plot_region_counts` can take either a DataFrame or a "Ribo" object to generate the a stacked bar plot of proportions that correspond to the "UTR5", "CDS", and "UTR3" regions.

### Usage

    plot_region_counts(
      x,
      experiment,
      range.lower,
      range.upper,
      title = "Region Counts"
    )

### Arguments

`x` | A 'Ribo' object or a DataFrame generated from `get_region_counts`
`experiment` | a list of experiment names
`range.lower` | a lower bounds for a read length range
`range.upper` | an upper bounds for a read length range
`title` | a title for the generated plot

### Details

When given a 'Ribo' object, `plot_region_counts` calls `get_region_counts` to retrieve the necessary information for plotting. This option is in the case that a DataFrame of the region count information is not required.

The user can instead provide a DataFrame with the same structure as the output of the `get_region_counts` function where the 'transcript' and 'length' parameters are the default values of TRUE. This also means that the remaining parameters of the `plot_region_counts` function are not necessary. The run time becomes substantially faster when `plot_region_counts` is given the direct DataFrame to plot. However, the DataFrame needs to follow the format and types in the output of the reading functions

### Value

A 'ggplot' of the region counts for each of the experiments

### See Also

`get_region_counts` to generate a DataFrame that can be provided as input, `Ribo` to create a ribo.object that can be provided as input

### Examples

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

    #specify the regions and experiments of interest
    regions <- c("UTR5", "CDS", "UTR3")
    experiments <- c("Hela_1", "Hela_2", "WT_1")

    plot_region_counts(sample,
                       range.lower = 2,
                       range.upper = 5,
                       experiments)

    #DataFrame use case
    #obtains the region counts at each individual read length, summed across every transcript
    region.counts <- get_region_counts(sample,
                                       region = regions,
                                       range.lower = 2,
                                       range.upper = 5,
                                       tidy = TRUE,
                                       length = TRUE,
                                       transcript = TRUE)

    #the params 'length' and 'transcript' must be set to true to use a DataFrame
    plot_region_counts(region.counts)

[Package ribor version 0.99.8 Index]