Learn R Programming

metagene (version 2.4.3)

metagene: A class to manage metagene analysis.

Description

This class will allow to load, convert and normalize alignments and regions files/data. Once the data is ready, the user can then chose to produce metagene plots on the data (or a subset of the data).

Usage

metagene

Arguments

Value

metagene$new returns a metagene object which contains the normalized coverage values for every regions and for every BAM files.

Format

A metagene experiment manager

Constructor

mg <- metagene$new(regions, bam_files, padding_size = 0, cores = SerialParam(), verbose = FALSE, force_seqlevels = FALSE)
regions
Either a vector of BED, narrowPeak or broadPeak filenames, a GRanges object or a GRangesList object.
bam_files
A vector of BAM filenames. The BAM files must be indexed. i.e.: if a file is named file.bam, there must be a file named file.bam.bai in the same directory.
padding_size
The regions will be extended on each side by the value of this parameter. The padding_size must be a non-negative integer. Default = 0.
cores
The number of cores available to parallelize the analysis. Either a positive integer or a BiocParallelParam. Default: SerialParam().
verbose
Print progression of the analysis. A logical constant. Default: FALSE.
force_seqlevels
If TRUE, Remove regions that are not found in bam file header. Default: FALSE.
metagene$new returns a metagene object that contains the coverages for every BAM files in the regions from the regions param.

Methods

mg$plot(region_names = NULL, exp_names = NULL, title = NULL, x_label = NULL)
region_names
The names of the regions to extract. If NULL, all the regions are returned. Default: NULL.
exp_names
The names of the experiments to extract. If a design was added to the metagene object, exp_names correspond to the column names in the design, otherwise exp_names corresponds to the BAM name or the BAM filename. If NULL, all the experiments are returned. Default: NULL.
title
A title to add to the graph. If NULL, will be automatically created. Default: NULL
x_label
X-axis label to add to the metagene plot. If NULL, metagene will use generic label. Default: NULL.
mg$produce_matrices(design, bin_count, noise_removal, normalization, flip_regions, bin_size = NULL
design
A data.frame that describe to experiment to plot. see plot function for more details. NA can be used keep previous design value. Default: NA.
bin_count
The number of bin to create. NA can be used to keep previous bin_count value. A bin_count value of 100 will be used if no value is specified. Default: NA.
noise_removal
The algorithm to use to remove control(s). Possible values are NA, NULL or "NCIS". By default, value is NULL. Use NA keep previous noise_removal value (i.e. if produce_matrices was called before). See Liand and Keles 2012 for the NCIS algorithm.
normalization
The algorithm to use to normalize samples. Possible default, value is NULL and no normalization will be performed. Use NA keep previous normalization value (i.e. if produce_matrices was called before).
flip_regions
Should regions on negative strand be flip_regions? Default: FALSE.
bin_size
Deprecated.
mg$produce_data_frame(stat = "bootstrap", range = NULL ...)
stat
The stat to use to calculate the values of the ribbon in the metagene plot. Must be "bootstrap" or "basic". "bootstrap" will estimate the range of average ("mean" or "median") that could have produce the observed distribution of values for each bin. With the "basic" approach, the ribbon will represent the range of the values between 1 - alpha / 2 and alpha / 2 (see ... param.
range
Deprecated.
...
Extra params for the calculation of the ribbon values. See following param descriptions.
alpha
The range of the estimation to be shown with the ribbon. 1 - alpha / 2 and alpha / 2 will be used. Default: 0.05.
average
The function to use to summarize the values of each bins. "mean" or "median". Default: "mean".
sample_count
With "bootstrap" only. The number of draw to do in the bootstrap calculation. Default: 1000.
mg$get_params()
mg$get_design()
mg$get_regions(region_names = NULL)
region_names
The names of the regions to extract. If NULL, all the regions are returned. Default: NULL.
mg$get_matrices(region_names = NULL, exp_name = NULL)
region_names
The names of the regions to extract. If NULL, all the regions are returned. Default: NULL.
exp_names
The names of the experiments to extract. If a design was added to the metagene object, exp_names correspond to the column names in the design, otherwise exp_names corresponds to the BAM name or the BAM filename. If NULL, all the experiments are returned. Default: NULL.
mg$get_data_frame(region_names = NULL, exp_name = NULL)
region_names
The names of the regions to extract. If NULL, all the regions are returned. Default: NULL.
exp_names
The names of the experiments to extract. If a design was added to the metagene object, exp_names correspond to the column names in the design, otherwise exp_names corresponds to the BAM name or the BAM filename. If NULL, all the experiments are returned. Default: NULL.
get_plot = function()
get_raw_coverages = function(filenames)
filenames
The name of the file to extract raw coverages. Can be the filename with the extension of the name of the bam file (if a named bam files was used during the creation of the metagene object). If NULL, returns the coverage of every bam files. Default: NULL.
get_normalized_coverages = function(filenames)
filenames
The name of the file to extract normalized coverages (in RPM). Can be the filename with the extension of the name of the bam file (if a named bam files was used during the creation of the metagene object). If NULL, returns the coverage every bam files. Default: NULL.
mg$export(bam_file, region, file)
bam_file
The name of the bam file to export.
region
The name of the region to export.
file
The name of the ouput file.
mg$add_design(design = NULL, check_bam_files = FALSE)
design
A data.frame that describe to experiment to plot. See plot function for more details. NA can be used keep previous design value. Default: NA.
check_bam_files
Force check that all the bam files from the first columns of the design are present in current metagene object. Default: FALSE
mg$unflip_regions()
mg$flip_regions()
mg$unflip_regions()

Examples

Run this code
region <- get_demo_regions()[1]
bam_file <- get_demo_bam_files()[1]
mg <- metagene$new(regions = region, bam_files = bam_file)
## Not run: 
#     df <- metagene$plot()
# ## End(Not run)

Run the code above in your browser using DataLab