comparison R/ltr_utils.R @ 12:ff01d4263391 draft

"planemo upload commit 414119ad7c44562d2e956b765e97ca113bc35b2b-dirty"
author petr-novak
date Thu, 21 Jul 2022 08:23:15 +0000
parents a004cd05177d
children
comparison
equal deleted inserted replaced
11:54bd36973253 12:ff01d4263391
1 add_coordinates_of_closest_neighbor <- function(gff) { 1 add_coordinates_of_closest_neighbor <- function(gff) {
2 gff <- gff[order(seqnames(gff), as.vector(start(gff)))] 2 gff <- gff[order(seqnames(gff), as.vector(start(gff)))]
3 # split to chromosomes: 3 # split to chromosomes:
4 gff_parts <- split(gff, seqnames(gff)) 4 gff_parts <- split(gff, as.vector(seqnames(gff)))
5 upstreams <- c(sapply(gff_parts, function(x) c(1, head(end(x), -1)))) 5 upstreams <- c(sapply(gff_parts, function(x) c(1, head(end(x), -1))))
6 downstreams <- c(sapply(gff_parts, function(x) c(start(x)[-1], seqlengths(x)[runValue(seqnames(x[1]))]))) 6 downstreams <- c(sapply(gff_parts, function(x) c(start(x)[-1], seqlengths(x)[runValue(seqnames(x[1]))])))
7 gff_updated <- unlist(gff_parts) 7 gff_updated <- unlist(gff_parts)
8 gff_updated$upstream_domain <- unlist(upstreams) 8 gff_updated$upstream_domain <- unlist(upstreams)
9 gff_updated$downstream_domain <- unlist(downstreams) 9 gff_updated$downstream_domain <- unlist(downstreams)