make_transition_matrix_from_chromHMM: Generate transition matrix from chromHMM results

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/chromatin_states_transitions.R

Description

Generate transition matrix from chromHMM results

Usage

1
2
make_transition_matrix_from_chromHMM(gr_list_1, gr_list_2, sample_id_1, sample_id_2,
    window = NULL, min_1 = 0.5, min_2 = 0.5, meth_diff = 0, chromosome = paste0("chr", 1:22))

Arguments

gr_list_1

a list of GRanges objects which contain chromatin states in group 1. The first column in meta columns should be the states. Be careful when importing bed files to GRanges objects (start positions in bed files are 0-based while 1-based in GRanges objects).

gr_list_2

a list of GRanges objects which contains chromatin states in group 2.

sample_id_1

if gr_list_1 is not set, internally, it can be generated by setting this option which is a vector of sample IDs in subgroup 1. The chromatin states data will be retrieved by calling get_chromHMM_list (of course, you need to set chipseq_hooks$chromHMM hook first).

sample_id_2

similar as sample_id_1.

window

window size which was used to do chromHMM states segmentation If it is not specified, the greatest common divisor of the width of all regions is used.

min_1

If there are multiple samples in the group, it is possible that a segment has more than one states asigned to it. If the recurrency of each state is relatively low, it means there is no one dominant state for this segment and it should be removed. This argument controls the minimal value for the recurrency of states in a given segment. The value is a percent.

min_2

same as min_1, but for samples in group 2.

meth_diff

If methylation dataset is provided, the segments for which the methylation difference between two groups is less than this value are removed.

chromosome

subset of chromosomes

Details

For a segment in the genome, the chromatin state may be different in different subgroups. This is called chromatin state transistion. This function visualize such kind of genome-wide transitions.

The whole genome is segmentated by window and states with highest occurence among samples (and pass min_1 and min_2) are assigned to segments.

To make the function run successfully, number of segments (after binned by window) in all samples should be all the same and there should be no gaps between segments. If the segmentation data is directly imported from chromHMM results, you dont need to worry anything.

Value

A transition matrix in which values represent total width of segments that transite from one state to the other in the two groups. Rows correspond to group 1 and columns correspond to group 2.

If methylation dataset is provided, the mean methylation for each state in each group is attached, which will be used to calculate mean methylation difference in chromatin_states_transition_chord_diagram.

Subsetting and transpotation can be applied on the matrix so that the order of chromatin states can be adjusted to the matrix. If methylation data is provided, corresponding methylation difference matrix will be adjusted as well.

Author(s)

Zuguang Gu <z.gu@dkfz.de>

See Also

The matrix can be sent to chromatin_states_transition_chord_diagram to visualize.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
set.seed(123)
gr_list_1 = lapply(1:5, function(i) {
	pos = sort(c(0, sample(1:9999, 99), 10000))*200
	GRanges(seqnames = "chr1", ranges = IRanges(pos[-101] + 1, pos[-1]), 
	    states = paste0("state_", sample(1:9, 100, replace = TRUE)))
})
gr_list_2 = lapply(1:5, function(i) {
	pos = sort(c(0, sample(1:9999, 99), 10000))*200
	GRanges(seqnames = "chr1", ranges = IRanges(pos[-101] + 1, pos[-1]), 
	    states = paste0("state_", sample(1:9, 100, replace = TRUE)))
})
mat = make_transition_matrix_from_chromHMM(gr_list_1, gr_list_2)

jokergoo/epik documentation built on Sept. 28, 2019, 9:20 a.m.