Skip to content

Commit 93ac1f7

Browse files
committed
do not remove short segment when entire chrom is short...
1 parent 9e82039 commit 93ac1f7

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

R/cbs_segment.R

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,13 @@ cbs_segment_varbin <- function(bin_mat, alpha=0.05, nperm=1000, undo.SD=1.0, min
6868
discardSegments <- TRUE
6969
while (discardSegments) {
7070
orderShort <- workShort[order(workShort$num.mark, abs(workShort$seg.mean)), ]
71-
if (orderShort[1, "num.mark"] < min.width) {
72-
workShort <- remove_segment(workShort, orderShort[1, "segnum"], bin_mat, undo.SD)
73-
} else {
71+
for(i in 1:nrow(orderShort)) {
72+
if(sum(workShort[workShort[, "chrom"] == orderShort[i, "chrom"], "num.mark"]) >= min.width) {
73+
if(orderShort[i, "num.mark"] < min.width) {
74+
workShort <- remove_segment(workShort, orderShort[i, "segnum"], bin_mat, undo.SD)
75+
break
76+
}
77+
}
7478
discardSegments <- FALSE
7579
}
7680
}

0 commit comments

Comments
 (0)