comparison R/ltr_utils.R @ 9:1aa578e6c8b3 draft

"planemo upload commit 9488b982bae902f1868785ec4ad47134dac50ff3"
author petr-novak
date Wed, 29 Jun 2022 09:25:54 +0000
parents 9de392f2fc02
children a004cd05177d
comparison
equal deleted inserted replaced
8:9de392f2fc02 9:1aa578e6c8b3
136 S <- sapply(gx, function(x)min(x$start)) 136 S <- sapply(gx, function(x)min(x$start))
137 E <- sapply(gx, function(x)max(x$end)) 137 E <- sapply(gx, function(x)max(x$end))
138 gr <- GRanges(seqnames = sapply(gx, function(x)x$seqnames[1]), IRanges(start = S - offset, end = E + offset)) 138 gr <- GRanges(seqnames = sapply(gx, function(x)x$seqnames[1]), IRanges(start = S - offset, end = E + offset))
139 } 139 }
140 140
141 get_ranges_left <- function(gx, offset = OFFSET, offset2 = 10) { 141 get_ranges_left <- function(gx, offset = OFFSET, offset2 = 300) {
142 ## offset2 - how many nt cen LTR extend to closes protein domain 142 ## offset2 - how many nt cen LTR extend to closes protein domain
143 ## this is necassary as some detected proteins domains does not have correct bopundaries 143 ## this is necassary as some detected proteins domains does not have correct bopundaries
144 ## if LTR retrotransposons insters to other protein domain. 144 ## if LTR retrotransposons insters to other protein domain.
145 S <- sapply(gx, function(x)min(x$start)) 145 S <- sapply(gx, function(x)min(x$start))
146 max_offset <- S - sapply(gx, function(x)min(x$upstream_domain)) + offset2 146 max_offset <- S - sapply(gx, function(x)min(x$upstream_domain)) + 10
147 offset_adjusted <- ifelse(max_offset < offset, max_offset, offset) 147 offset_adjusted <- ifelse(max_offset < offset, max_offset, offset)
148 gr <- GRanges(seqnames = sapply(gx, function(x)x$seqnames[1]), IRanges(start = S - offset_adjusted, end = S + offset2)) 148 gr <- GRanges(seqnames = sapply(gx, function(x)x$seqnames[1]), IRanges(start = S - offset_adjusted, end = S + offset2))
149 return(gr) 149 return(gr)
150 } 150 }
151 151
152 get_ranges_right <- function(gx, offset = OFFSET, offset2 = 10) { 152 get_ranges_right <- function(gx, offset = OFFSET, offset2 = 300) {
153 E <- sapply(gx, function(x)max(x$end)) 153 E <- sapply(gx, function(x)max(x$end))
154 max_offset <- sapply(gx, function(x)max(x$downstream_domain)) - E + offset2 154 max_offset <- sapply(gx, function(x)max(x$downstream_domain)) - E + 10
155 offset_adjusted <- ifelse(max_offset < offset, max_offset, offset) 155 offset_adjusted <- ifelse(max_offset < offset, max_offset, offset)
156 gr <- GRanges(seqnames = sapply(gx, function(x)x$seqnames[1]), IRanges(start = E - offset2, end = E + offset_adjusted)) 156 gr <- GRanges(seqnames = sapply(gx, function(x)x$seqnames[1]), IRanges(start = E - offset2, end = E + offset_adjusted))
157 return(gr) 157 return(gr)
158 } 158 }
159 159