makeGRBs returns the coordinates of CNEs as a meta data column
... | ... |
@@ -94,9 +94,22 @@ makeGRBs <- function(x, winSize=NULL, genes=NULL, ratio=1, |
94 | 94 |
for(i in 1:length(xList)){ |
95 | 95 |
hitsCNEs <- findOverlaps(xList[[i]], clusterRanges, |
96 | 96 |
ignore.strand=TRUE, type="within") |
97 |
+ |
|
98 |
+ ## Add the number of CNEs |
|
97 | 99 |
cnes <- lengths(split(queryHits(hitsCNEs), subjectHits(hitsCNEs))) |
98 | 100 |
mcols(clusterRanges)[[names(xList)[i]]] <- 0L |
99 | 101 |
mcols(clusterRanges)[[names(xList)[i]]][as.integer(names(cnes))] <- cnes |
102 |
+ |
|
103 |
+ ## Add the CNE ranges |
|
104 |
+ cnes <- split(xList[[i]][queryHits(hitsCNEs)], subjectHits(hitsCNEs)) |
|
105 |
+ missingCNEs <- setdiff(seq_len(length(clusterRanges)), |
|
106 |
+ subjectHits(hitsCNEs)) |
|
107 |
+ for(j in missingCNEs){ |
|
108 |
+ ## This is really a bad implementation. |
|
109 |
+ cnes[[as.character(j)]] <- GRanges() |
|
110 |
+ } |
|
111 |
+ mcols(clusterRanges)[[paste(names(xList)[i], "CNE")]] <- |
|
112 |
+ cnes[order(as.integer(names(cnes)))] |
|
100 | 113 |
} |
101 | 114 |
|
102 | 115 |
# Filter out the GRBs with few CNEs |