metagene_profiles: Calculate metagene profiles

Description Usage Arguments Details Value See Also

View source: R/metagene.R

Description

Calculates a metagene profile from the full data set as well as bootstrapping samples (sampling genes). Profiles are calculated separately for each experiment and replicate.

Usage

 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
metagene_profiles(data, ...)

## S3 method for class 'serp_data'
metagene_profiles(
  data,
  profilefun,
  len,
  bin,
  filter = NULL,
  binwidth = 1,
  binmethod = c("sum", "mean"),
  normalizefun = NULL,
  align = "start",
  nboot = 100,
  bpparam = BiocParallel::bpparam()
)

## S3 method for class 'serp_features'
metagene_profiles(
  data,
  profilefun,
  len,
  bin,
  filter = NULL,
  binwidth = 1,
  binmethod = c("sum", "mean"),
  normalizefun = NULL,
  align = "start",
  nboot = 100,
  bpparam = BiocParallel::bpparam()
)

Arguments

data

The data.

profilefun

Function that calculates a profile. Must accept named arguments for all sample types present in the data set (matrices with genes in rows cropped to the profile region. Missing values, e.g. if a gene ends within the profile region, are encoded as NA.) as well as exp (experiment name), rep (replicate name), binwidth (bin width), binmethod (binning method), align (alignment), lengths (named vector of gene lengths). Must return either a single numeric vector or a named list of numeric vectors.

len

Length of the profile.

bin

Bin level (bynuc or byaa). If missing, the default binning level of the data set will be used

filter

List of genes to include. Defaults to all genes.

binwidth

Bin width.

binmethod

How to bin the data. sum: Sums all read counts, mean: Averages read counts

normalizefun

Function that normalizes the data pefore binning and profile calculation. Must accept the same arguments as profilefun. Data matrices will contain data for entire genes. The lengths argument is guaranteed to contain only genes present in the data matrices in the same order. Must return a named list of matrices.

align

Alignment of the metagene profile, one of start (5' end) or stop (3' end). Alternatively, a named numeric vector of alignment positions for each gene in filter can be given. In this case, names must correspond to gene names and genes will be aligned to the given positions and the profile will be centered at 0, spanning len positions in either direction.

nboot

Number of bootstrap samples.

bpparam

A BiocParallelParam-class object.

Details

Data matrices are first filtered to contain the same set of genes (i.e. only the intersection of genes contained in all matrices is retained). For serp_data objects, this filtering is performed separately for each experiment and replicate. Data matrices are the filtered to contain only genes in filter, if filter is given. Matrices are then passed to normalizefun as named arguments, with names corresponding to sample type. If align is one of start or stop, normalized data matrices are first aligned, then binned and trimmed to len columns. If align is a vector of positions, data matrices are centered using make_aligned_mats without binning for performance reasons, binning is performed on the final profiles. The centered and trimmed data matrices are passed as named arguments to profilefun, which calculates the final profiles. profilefun can return either a single numeric vector, representing a single profile calculated from all data matrices, or a named list of numeric vectors.

Value

A tibble with the following columns:

id

ID of the bootstrap sample

pos

Distance from the align position. If bin == 'byaa' this is measured in codons, otherwise in nucleotides.

boot

Logical, indicates whether this profile was generated from a bootstrap sample or from the complete data set.

type

Only if profilefun returns a list. Corresponds to the name of the list element containing the profile.

summary

The value returned by profilefun.

See Also

defaults, make_average_profilefun, make_enrichment_profilefun, make_expression_normalizefun


ilia-kats/RiboSeqTools documentation built on Oct. 5, 2020, 7:41 p.m.