detect.movement: Detect Movements Between Association Matrices using their...

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

View source: R/hbm.R

Description

detect.movement takes a reference and a target association matrices, typically contact maps of chromosomes, and their hierarchical block matrices (computed with hbm) and detects movements between the reference and the target. A detected movement represents a disposition of node in a the reference, that gave rise to its new position in the target.

Usage

1
2
detect.movement(ref, target, ref.res, target.res, 
            motion.prop.thresh = 0.75, siglevel = 0.05, verbose = FALSE)

Arguments

ref

the reference matrix. A numeric association matrix, typically a symmetric chromatin contact map.

target

the target matrix to be compared to ref. A numeric association matrix, typically a symmetric chromatin contact map.

ref.res

the result of calling hbm with ref.

target.res

the result of calling hbm with target.

motion.prop.thresh

numeric giving the threshold for detecting whether a region has moved based on the proportions of changed neighbors in its cluster.

siglevel

numeric giving the threshold for detecting a significant compactness/unfolding in a given cluster, set to 0.05 by default.

verbose

boolean indicating whether to print intermediate results.

Details

detect.movement iterates through the scales of the reference matrix (using its HBM) and through the clusters at each scale and test for movements in the target. For each cluster it further tests for significant differences in association probabilities and for changes in the neighbors of each node.

Value

detect.movement returns a numeric matrix, with the i,j-th entry taking one of the following values:
-1 if i has moved away from j,
1 if i has moved towards j,
0 if there was no movement, and
-0.5 and 0.5 for implicated away and towards movements, respectively.

Author(s)

Yoli Shavit

References

hbm's website: http://www.cl.cam.ac.uk/~ys388/hbm/

See Also

get.movements to summarize the results of detect.movement
hbm to learn how to build hierarchical block matrices
hbm's tutorials at http://www.cl.cam.ac.uk/~ys388/hbm/

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
set.seed(2)
n = 200 # chain size

# control configuration
conf = generate.random.conf(n, sd = 0.5, scale = FALSE)
# condition-1
conf.tr.1 = conf
conf.tr.1[99,] = conf.tr.1[77,]-0.5

# generate contact map-like matrices
control = exp(-1*as.matrix(dist(conf))) 
tr.1 = exp(-1*as.matrix(dist(conf.tr.1))) 

control.res = hbm(control, 2)
tr.1.res = hbm(tr.1, 2)
m1 = detect.movement(control, tr.1, control.res, tr.1.res)
resm = get.movements(m1, control.res$hm)
resm

# compare with configuration
par(mfrow = c(1,2))
cols = rep("black", n)
cols[unique(resm$from)] = "green"
plot(conf, xlab = "X", ylab = "Y", type = 'n', main = "Control")
text(conf[,1:2], labels = 1:n, cex = 0.75, col = cols)
cols = rep("black", n)
cols[unique(resm$from)] = "green"
cols[resm$to[which(resm$type == 0.5)]] = "pink"
cols[resm$to[which(resm$type == 1)]] = "red"
cols[resm$to[which(resm$type == -0.5)]] = "cyan"
cols[resm$to[which(resm$type == -1)]] = "blue"
plot(conf.tr.1, xlab = "X", ylab = "Y", type = 'n', main = "Condition-1", col = cols)
text(conf.tr.1[,1:2], labels = 1:n, cex = 0.75, col = cols)

hbm documentation built on May 1, 2019, 6:32 p.m.