profileGenomicFeatures: Calculate metadata profiles across genomic features

Description Usage Arguments Value Examples

View source: R/profileGenomicFeatures.R

Description

This function calculates metadata profiles across genomic features using a procedure similar to that used in (https://www.sciencedirect.com/science/article/pii/S1097276519303533?via

Usage

1
2
3
4
profileGenomicFeatures(genomicRegions = NULL, sampleObject = NULL,
  TxDb = NULL, bins = c(100, 100, 100, 100), weightCol = NULL,
  ignoreStrand = FALSE, dropEmpty = TRUE, normType = c("density",
  "max", "none"), collapse = TRUE, verbose = TRUE)

Arguments

genomicRegions

A named list of GenomicRanges objects.

sampleObject

A GenomicRanges or GenomicAlignments object.

TxDb

A GenomicFeatures object. Required if genomicRegions is not provided. It must contain GenomeInfoDb information.

bins

An ordered integer vector (must be greater equal that the length of genomicRegions), or 3 if the latter is not provided. The vector order determines the number of bins for each region. If more bins than regions are provided, the additional will be ignored. Default order: Upstream, Exon, Downstream, Intron.

weightCol

A single character string. This must be the name of an integer column in the sampleObject object.

ignoreStrand

When set to 'TRUE', the strand information in sampleObject is ignored. This does not affect the features in genomicRegions.

dropEmpty

When set to 'TRUE', the transcripts with no signal in any of their sub-regions will be discarded. When set to 'FALSE', all values of these regions will be set to 0.

normType

A character string indicating which region normalising method to use. One of 'density' (default), 'max', 'none': can be abbreviated. Depending on the chosen method the values of each region are normalised using the sum ('density'), the maximum ('max') of the values across the region, or not normalised at all ('none').

collapse

When set to 'TRUE', the profiles are collapsed into a single profile.

verbose

When set to 'TRUE', the function prints diagnostic messages.

Value

A data.table of the normalised binned coverage across the genomic features. Column names are determined by collapse.

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
library("TxDb.Dmelanogaster.UCSC.dm3.ensGene")
TxDb = TxDb.Dmelanogaster.UCSC.dm3.ensGene

query = extractGenomicFeatures(TxDb)

library("pasillaBamSubset")
library("GenomicAlignments")

fl1 <- untreated1_chr4()
subject = readGAlignments(fl1)

profile = profileGenomicFeatures(genomicRegions=query, sampleObject=subject, TxDb=TxDb)

library("ggplot2")

ggplot(profile, aes(x=bin, y=Mean, colour=region_id)) + 
  geom_line() +
  geom_vline(xintercept=c(100.5, 200.5), linetype="dashed", colour="grey30") +
  scale_x_continuous("Relative position",
       breaks=c(1, 100.5, 200.5, 300), label=c("-1000", "TSS", "TES", "1000")) +
  scale_y_continuous("Average normalised signal") +
  coord_cartesian(xlim=c(0, 300)) +
  theme_bw() +
  theme(legend.position=c(0.9, 0.8), legend.background=element_blank()) +
  guides(colour=guide_legend(title=""))

fagostini/Mimir documentation built on Dec. 3, 2019, 7:53 p.m.