Skip to contents

This function will take a SummarizedExperiment object with read-level footprinting data (e.g. returned by readModkitExtract or readModBam) and summarize reads in each sample, for instance to generate modified and total counts at each position for each sample.

Usage

flattenReadLevelAssay(
  se,
  assayName = "mod_prob",
  statistics = c("Nmod", "Nvalid", "FracMod"),
  keepReads = TRUE,
  replaceExisting = TRUE,
  verbose = FALSE
)

Arguments

se

SummarizedExperiment object with read-level footprinting data. Rows should correspond to positions and columns to samples.

assayName

A character scalar specifying the assay of se containing the read-level data to be summarized. Typically, this assay contains modification probabilities.

statistics

Character vector specifying the type of statistics to be computed. Currently supported values are "Nmod" (number of modification probabilities greater or equal to 0.5), "Nvalid" (number of overlapping reads), "FracMod" (Nmod/Nvalid fraction), "Pmod" (average modification probability), "AvgConf" (average confidence of (non-)modification probabilities).

keepReads

A logical scalar. If TRUE (the default), the read-level data from assayName will be retained in an assay of the same name.

replaceExisting

A logical scalar. If TRUE (the default), any existing assays with the same name as the ones requested will be overwritten. Otherwise, existing assays will be retained and the corresponding summary statistic(s) will not be recalculated.

verbose

If TRUE, report on progress.

Value

A SummarizedExperiment object with the same dimensions as se (positions in rows and samples in columns), and added assays corresponding to the requested statistics.

See also

SummarizedExperiment for the returned object type, readModkitExtract for the function used to read the input files.

Author

Charlotte Soneson, Michael Stadler

Examples

exfile <- system.file("extdata", "modkit_extract_rc_6mA_1.tsv.gz", package = "footprintR")
se <- readModkitExtract(exfile, modbase = "a")
se
#> class: RangedSummarizedExperiment 
#> dim: 8344 1 
#> metadata(3): modkit_threshold filter_threshold readLevelData
#> assays(1): mod_prob
#> rownames(8344): chr1:6929104:+ chr1:6929106:+ ... chr1:6941530:-
#>   chr1:6941531:-
#> rowData names(0):
#> colnames(1): s1
#> colData names(2): sample modbase

se_summary <- flattenReadLevelAssay(se)
se_summary
#> class: RangedSummarizedExperiment 
#> dim: 8344 1 
#> metadata(3): modkit_threshold filter_threshold readLevelData
#> assays(4): mod_prob Nmod Nvalid FracMod
#> rownames(8344): chr1:6929104:+ chr1:6929106:+ ... chr1:6941530:-
#>   chr1:6941531:-
#> rowData names(0):
#> colnames(1): s1
#> colData names(2): sample modbase