plotMetageneAnnotProfile: Plot metagene annotation profiles for different groups of...

Description Usage Arguments Value Author(s) Examples

View source: R/plotMetageneAnnotProfile.R

Description

Plot metagene annotation profiles for different groups of genes.

Usage

1
2
3
4
5
6
plotMetageneAnnotProfile(
  avgprofs,
  gscolors = NULL,
  usePercent = FALSE,
  freeY = FALSE
)

Arguments

avgprofs

A data frame with average profiles for different groups of genes (or "gene sets"). The object should contain the following columns:

  • Position. Integer vector of genomic positions. The following rules should apply:

    • The region upstream of the focus features has negative positions.

    • The region downstream of the focus features has positive coordinates. The highest number in the Position column should correspond to the end of this region

    • Positions of the TSS (beginning of focus features) and TES (end of focus features) should both be 0

  • Xcoord. Numeric in [0,5]. Coordinates to use on the x axis. The following rules should apply:

    • The Xcoord of the upstream region cover [0,2[

    • The Xcoord of the TSS (beginning of focus feature) is 2

    • The Xcoord of the body of the focus feature cover ]2,3[

    • The Xcoord of the TES (end of focus feature) is 3

    • The Xcoord of the downstream region cover ]3,5]

  • Strand. Character vector of factor (with values "sense" or "antisense") for strand information.

  • Profile. Numeric. The actual signal that is plotted.

  • Upper. Numeric. Upper bound of the confidence interval for AnnotationCoverage.

  • Lower Numeric. Lower bound of the confidence interval for AnnotationCoverage.

  • GeneSet Character vector or factor defining the different gene sets.

gscolors

Optional named character vector with colors per gene sets. Names of gscolors should match the levels of the GeneSet column.

usePercent

Logical (defaults to FALSE) indicating if annotation coverages were expressed as presence/absence (and thus the AnnotationCoverage column is a percentage)

freeY

Logical (defaults to FALSE) indicating if y-axis scales for sense and antisense strands should be different

Value

A ggplot object

Author(s)

Pascal GP Martin

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
38
39
40
## Extract profiles around (+/-50bp) all genes.
  Prof <- annotationCoverageAroundFeatures(Genegr,
                                           sidedist = 50,
                                           usePercent = TRUE,
                                           nbins=3)
## Assemble the profiles:
  Prof <- assembleProfiles(Prof)
## Get the average profile for all genes on the sense and antisense strands
  avgALLsense = getAvgProfileWithCI(Prof$Profiles_Sense,
                                    pos = c(-50:0, 1:3, 0:50))
  avgALLantisense = getAvgProfileWithCI(Prof$Profiles_Antisense,
                                        pos = c(-50:0, 1:3, 0:50))
## Select genes with a close neighbor on the same strand
  selGenes <- names(Genegr)[S4Vectors::mcols(
                  GenomicRanges::distanceToNearest(Genegr))$distance <= 5]
## Get their average profiles
  avgSELsense = getAvgProfileWithCI(Prof$Profiles_Sense,
                                    selFeatures = selGenes,
                                    pos = c(-50:0, 1:3, 0:50))
  avgSELantisense = getAvgProfileWithCI(Prof$Profiles_Antisense,
                                        selFeatures = selGenes,
                                        pos = c(-50:0, 1:3, 0:50))
## Define the xcoordinates:
  xcoord = c(seq(0, 2, length.out = 51),
             seq(2, 3, length.out = 5)[2:4],
             seq(3, 5, length.out = 51))
## Assemble the data for plotting:
  avgprof <- rbind(avgALLsense, avgALLantisense,
                   avgSELsense, avgSELantisense)
  avgprof$Strand = rep(rep(c("sense", "antisense"),
                           each = 105),
                       times =2)
  avgprof$Xcoord = rep(xcoord, 4)
  avgprof$GeneSet = rep(c("All genes", "Close tandem neighbor"),
                        each = 210)
## Finally plot the results:
  plotMetageneAnnotProfile(avgprof, usePercent = TRUE)
## Focus on a region closer to the genes:
  plotMetageneAnnotProfile(avgprof, usePercent = TRUE) +
    ggplot2::coord_cartesian(xlim=c(1,4))

pgpmartin/GeneNeighborhood documentation built on Sept. 2, 2021, 6:37 a.m.