plot_numerical_coannotations {annotatr} | R Documentation

## Plot numerical data occurring in pairs of annotations

### Description

Plot numerical data associated with regions occurring in `annot1`, `annot2` and in both. As with `plot_numerical()`, the result is a plot of histograms or x-y scatterplots.

### Usage

    plot_numerical_coannotations(annotated_regions, x, y, annot1, annot2,
      bin_width = 10, plot_title, x_label, y_label, legend_facet_label,
      legend_cum_label, quiet = FALSE)

### Arguments

`annotated_regions` | A `GRanges` returned from `annotate_regions()`.
`x` | A string indicating the column of the `GRanges` to use for the x-axis.
`y` | A string indicating the column of the `GRanges` to use for the y-axis. If missing, a histogram over `x` will be plotted. If not missing, a scatterplot is plotted.
`annot1` | A string indicating the first annotation type.
`annot2` | A string indicating the second annotation type.
`bin_width` | An integer indicating the bin width of the histogram used for score. Default 10. Select something appropriate for the data. NOTE: This is only used if `y` is `NULL`.
`plot_title` | A string used for the title of the plot. If missing, no title is displayed.
`x_label` | A string used for the x-axis label. If missing, no x-axis label is displayed.
`y_label` | A string used for the y-axis label. If missing, no y-axis label is displayed.
`legend_facet_label` | A string used to label the gray bar portion of the legend. Defaults to "x in annot pair".
`legend_cum_label` | A string used to label the red outline portion of the legend. Defaults to "All x".
`quiet` | Print progress messages (FALSE) or not (TRUE).

### Details

For example, a CpG with associated percent methylation annotated to a CpG island and a promoter will count once in the All distribution and once in the CpG island / promoter facet distribution. However, a CpG associated only with a promoter will count once in the All distribution and once in the promoter / promoter distribution.

### Value

A `ggplot` object which can be viewed by calling it, or saved with `ggplot2::ggsave`.

### Examples

       # Get premade CpG annotations
       data('annotations', package = 'annotatr')

       dm_file = system.file('extdata', 'IDH2mut_v_NBM_multi_data_chr9.txt.gz', package = 'annotatr')
       extraCols = c(diff_meth = 'numeric', mu1 = 'numeric', mu0 = 'numeric')
       dm_regions = read_regions(con = dm_file, extraCols = extraCols,
           rename_score = 'pval', rename_name = 'DM_status', format = 'bed')
       dm_regions = dm_regions[1:1000]

       dm_annots = annotate_regions(
           regions = dm_regions,
           annotations = annotations,
           ignore.strand = TRUE)

       dm_vs_num_co = plot_numerical_coannotations(
           annotated_regions = dm_annots,
           x = 'mu0',
           annot1 = 'hg19_cpg_islands',
           annot2 = 'hg19_cpg_shelves',
           bin_width = 5,
           plot_title = 'Group 0 Perc. Meth. in CpG Islands and Promoters',
           x_label = 'Percent Methylation')

[Package annotatr version 1.4.1 Index]