Skip to content

Commit 9fa0e89

Browse files
Update sRNACharP.nf
Changes were made in process createAttributeTable to handle BEDtools returning -1 as distance when no feature is found close by.
1 parent 3471780 commit 9fa0e89

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

sRNACharP.nf

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,15 @@ process createAttributeTable{
337337
#!/usr/bin/env Rscript
338338
339339
selectClosestORF <- function(m, up = TRUE){
340-
# if there is only one close ORF, return it
340+
# There is only one close ORF
341341
if (nrow(m) < 2) {
342-
return(m)
342+
if (m[,"Distance"] == -1 && m[,7] == ".") { ## there is no close Feature Replicon == . and BedTools has returned -1 as distance, then make distance 1000
343+
tmp <-m
344+
tmp[,"Distance"] <- 1000
345+
return(tmp)
346+
} else {
347+
return(m)
348+
}
343349
}
344350
#order by distance
345351
o <- order(abs(m[,"Distance"]), decreasing = FALSE)
@@ -430,12 +436,8 @@ colnames(sRNA_closestTerm) <- c("Replicon","Start", "End", "ID", "Score", "Stra
430436
sRNA_closestTerm <- by(sRNA_closestTerm, sRNA_closestTerm[,"ID"], selectClosestORF, FALSE, simplify = FALSE)
431437
sRNA_closestTerm <- do.call("rbind", sRNA_closestTerm)
432438
433-
434439
#Cap distance to terminator to 1000. Erik experiments show that having very large distances to terminator decrease the performance of the classifiers
435440
sRNA_closestTerm[["Distance"]] <- ifelse(sRNA_closestTerm[["Distance"]]>1000, 1000, sRNA_closestTerm[["Distance"]])
436-
#Make negative distance to terminator 1000. BEDTools returns -1 if not terminator is found
437-
sRNA_closestTerm[["Distance"]] <- ifelse(sRNA_closestTerm[["Distance"]] < 0, 1000, sRNA_closestTerm[["Distance"]])
438-
439441
440442
#Create dataset
441443
Data <- cbind(sRNAs[,"Strand"], sRNA_E[row.names(sRNAs), "Energy"], sRNA_bprom[row.names(sRNAs), "Pos10wrtsRNAStart"], sRNA_closestTerm[row.names(sRNAs),"Distance"],

0 commit comments

Comments
 (0)