Transfrom a full Hi-C contact matrix to a sparse upper triangular matrix

full2sparse(mat)

Arguments

mat

A matrix. Must have column names equal to the start location for each bin. i.e. for a 6x6 Hi-C matrix where the first region starts at 0 kb and the final region starts at 500KB and the resolution is 100kb, the column names of the matrix should be as follows: colnames(mat) = c(0, 100000, 200000, 300000, 400000, 500000)

Value

A sparse upper triangular matrix.

Examples

m <- matrix(1:100, 10, 10) colnames(m) <- 1:10 sparse <- full2sparse(m) sparse
#> region1 region2 IF #> 1: 1 1 1 #> 2: 1 2 11 #> 3: 2 2 12 #> 4: 1 3 21 #> 5: 2 3 22 #> 6: 3 3 23 #> 7: 1 4 31 #> 8: 2 4 32 #> 9: 3 4 33 #> 10: 4 4 34 #> 11: 1 5 41 #> 12: 2 5 42 #> 13: 3 5 43 #> 14: 4 5 44 #> 15: 5 5 45 #> 16: 1 6 51 #> 17: 2 6 52 #> 18: 3 6 53 #> 19: 4 6 54 #> 20: 5 6 55 #> 21: 6 6 56 #> 22: 1 7 61 #> 23: 2 7 62 #> 24: 3 7 63 #> 25: 4 7 64 #> 26: 5 7 65 #> 27: 6 7 66 #> 28: 7 7 67 #> 29: 1 8 71 #> 30: 2 8 72 #> 31: 3 8 73 #> 32: 4 8 74 #> 33: 5 8 75 #> 34: 6 8 76 #> 35: 7 8 77 #> 36: 8 8 78 #> 37: 1 9 81 #> 38: 2 9 82 #> 39: 3 9 83 #> 40: 4 9 84 #> 41: 5 9 85 #> 42: 6 9 86 #> 43: 7 9 87 #> 44: 8 9 88 #> 45: 9 9 89 #> 46: 1 10 91 #> 47: 2 10 92 #> 48: 3 10 93 #> 49: 4 10 94 #> 50: 5 10 95 #> 51: 6 10 96 #> 52: 7 10 97 #> 53: 8 10 98 #> 54: 9 10 99 #> 55: 10 10 100 #> region1 region2 IF