getSignalsFromList: Get Signals from a List

Description Usage Arguments Details Value Author(s) Examples

View source: R/normalize.R

Description

Get Signals from a List

Usage

1
getSignalsFromList(lt, fun = function(x) mean(x, na.rm = TRUE))

Arguments

lt

A list of normalized matrices which are returned by normalizeToMatrix. Matrices in the list should be generated with same settings (e.g. they should use same target regions, same extension to targets and same number of windows).

fun

A user-defined function to summarize signals.

Details

Let's assume you have a list of histone modification signals for different samples and you want to visualize the mean pattern across samples. You can first normalize histone mark signals for each sample and then calculate means values across all samples. In following example code, hm_gr_list is a list of GRanges objects which contain positions of histone modifications, tss is a GRanges object containing positions of gene TSS.

1
2
3
4
    mat_list = NULL
    for(i in seq_along(hm_gr_list)) {
        mat_list[[i]] = normalizeToMatrix(hm_gr_list[[i]], tss, value_column = "density")
    }  

If we compress the list of matrices as a three-dimension array where the first dimension corresponds to genes, the second dimension corresponds to windows and the third dimension corresponds to samples, the mean signal across all sample can be calculated on the third dimension. Here getSignalsFromList simplifies this job.

Applying getSignalsFromList() to mat_list, it gives a new normalized matrix which contains mean signals across all samples and can be directly used in EnrichedHeatmap().

1
2
    mat_mean = getSignalsFromList(mat_list)
    EnrichedHeatmap(mat_mean)  

The correlation between histone modification and gene expression can also be calculated on the third dimension of the array. In the user-defined function fun, x is the vector for gene i and window j in the array, and i is the index of current gene.

1
2
    mat_corr = getSignalsFromList(mat_list, 
        fun = function(x, i) cor(x, expr[i, ], method = "spearman"))  

Then mat_corr here can be used to visualize how gene expression is correlated to histone modification around TSS.

1
    EnrichedHeatmap(mat_corr)  

Value

A normalizeToMatrix object which can be directly used for EnrichedHeatmap.

Author(s)

Zuguang Gu <z.gu@dkfz.de>

Examples

1

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