Learn R Programming

EnrichedHeatmap (version 1.2.2)

getSignalsFromList: Get signals from a list

Description

Get signals from a list

Usage

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

Arguments

lt
a list of objects which are returned by normalizeToMatrix. Objects in the list should come from same settings.
fun
a self-defined function which gives mean signals across samples. If we assume the objects in the list correspond to different samples, then different regions in the targets are the first dimension, different positions upstream or downstream of the targets are the second dimension, and different samples are the third dimension. This self-defined function can have one argument which is the vector containing values in different samples in a specific position to a specific target region. Or it can have a second argument which is the index for the current target.

Value

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.

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

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

mat = getSignalsFromList(mat_list) EnrichedHeatmap(mat)

Next let's consider a second scenario: we want to see the correlation between histone modification and gene expression. In this case, fun can have a second argument so that users can correspond histone signals to the expression of the associated gene. In following code, expr is a matrix of expression, columns in expr correspond to elements in hm_gr_list, rows in expr are same as tss.

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

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

EnrichedHeatmap(mat)

Examples

Run this code
NULL

Run the code above in your browser using DataLab