-
Notifications
You must be signed in to change notification settings - Fork 0
/
TADmetric.Rmd
57 lines (45 loc) · 1.26 KB
/
TADmetric.Rmd
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
title: "TADs"
author: "M.Munn"
date: "July 5, 2016"
output: html_document
---
```{r}
rawESCdata <- read.csv("~/Dropbox/DS/wTrush/rawESCdata.csv", header=TRUE, stringsAsFactors = FALSE)
A = rawESCdata[2:length(rawESCdata[,2]), 2:4]
str(A)
dim(A)
```
Convert from character to numeric
```{r}
A = transform(A, X = as.numeric(X), X.1 = as.numeric(X.1), X.2 = as.numeric(X.2))
names(A) = c("startTAD", "endTAD", "interaction")
dim(A)
str(A)
```
Distance should be inversely proportional to interaction. There is room to change this along the way. Perhaps we can make this adjustable? some Shiny app.
```{r}
A$distance = 1/A$interaction
```
Also, we set up the distance metric.
```{r}
dist = matrix(, length(A[,1]), length(A[,1]))
dist = data.frame(dist)
for(i in 1:length(A[,1])){
dist[A[i,1],A[i,2]] = A[i,4]
}
for(i in 1:dim(dist)[1]){
for(j in 1:dim(dist)[2]){
if(is.na(dist[i,j])){
dist[i,j] = dist[j,i]
}
}
}
for(i in 1:dim(dist)[1]){dist[i,i] = 0}
sum(is.na(dist))
```
There are a LOT of NA values out of 393*393 - sum(is.na(dist)) = 384/2 = 192 actual values. We can just assume that distances beyond those values are irrelevant. That is,
```{r}
min(dist, na.rm=TRUE)
max(dist,na.rm = TRUE)
```