discretize: Discretize a Continuous Matrix to a Discrete Matrix

Description Usage Arguments Details Author(s) Examples

View source: R/normalize.R

Description

Discretize a Continuous Matrix to a Discrete Matrix

Usage

1
discretize(mat, rule, right_closed = FALSE)

Arguments

mat

A normalize matrix from normalizeToMatrix.

rule

A list of intervals which provide mapping between continuous values to discrete values. Note the order of intervals determines the order of corresponding discrete levels.

right_closed

Is the interval right closed?

Details

Assuming we have a normalized matrix with both positive values and negative values, we only want to see the enrichment of the windows/regions showing significant positive values and negative values and we are only interested in the direction of the values while not the value itself, then we can define the rule as:

1
2
3
4
    rule = list(
        "positive" = c(0.5, Inf),
        "negative" = c(-Inf, -0.5)
    )  

And we can convert the continuous matrix to a discrete matrix and visualize it:

1
2
    mat2 = discretize(mat, rule)
    EnrichedHeatmap(mat2, col = c("positive" = "red", "negative" = "green"))  

Another example is to discretize the signals to discrete levels according to the intensities:

1
2
3
4
5
6
    rule = list(
        "very_high" = c(100, Inf),
        "high" = c(50, 100),
        "intermediate" = c(25, 50),
        "low" = c(1e-6, 25)
    )  

Author(s)

Zuguang Gu <z.gu@dkfz.de>

Examples

1
2
# There is no example
NULL

Example output

Loading required package: grid
Loading required package: ComplexHeatmap
Loading required package: GenomicRanges
Loading required package: stats4
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, basename, cbind, colMeans, colSums, colnames,
    dirname, do.call, duplicated, eval, evalq, get, grep, grepl,
    intersect, is.unsorted, lapply, lengths, mapply, match, mget,
    order, paste, pmax, pmax.int, pmin, pmin.int, rank, rbind,
    rowMeans, rowSums, rownames, sapply, setdiff, sort, table, tapply,
    union, unique, unsplit, which, which.max, which.min

Loading required package: S4Vectors

Attaching package: 'S4Vectors'

The following object is masked from 'package:base':

    expand.grid

Loading required package: IRanges
Loading required package: GenomeInfoDb
Loading required package: locfit
locfit 1.5-9.1 	 2013-03-22

Attaching package: 'EnrichedHeatmap'

The following object is masked from 'package:ComplexHeatmap':

    +.AdditiveUnit

NULL

EnrichedHeatmap documentation built on Nov. 8, 2020, 8:20 p.m.