Description Usage Arguments Value Author(s) Examples
View source: R/plotMetageneAnnotProfile.R
Plot metagene annotation profiles for different groups of genes.
1 2 3 4 5 6 | plotMetageneAnnotProfile(
avgprofs,
gscolors = NULL,
usePercent = FALSE,
freeY = FALSE
)
|
avgprofs |
A data frame with average profiles for different groups of genes (or "gene sets"). The object should contain the following columns:
|
gscolors |
Optional named character vector with colors per gene sets. Names of |
usePercent |
Logical (defaults to FALSE) indicating if annotation coverages were expressed as presence/absence (and thus the |
freeY |
Logical (defaults to FALSE) indicating if y-axis scales for sense and antisense strands should be different |
A ggplot object
Pascal GP Martin
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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.