-
Notifications
You must be signed in to change notification settings - Fork 0
/
seg_stats.r
30 lines (29 loc) · 882 Bytes
/
seg_stats.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
stepwiseDifference <- function(gapSize,segmentFile){
seg <- read.table(segmentFile,stringsAsFactors = F,header = T)
print(nrow(seg))
accumulatePos <- 0
newseg <-data.frame()
for (row in 1:nrow(seg)){
segLen <- seg[row,4]-seg[row,3]
if ( segLen> gapSize) {
accumulatePos <- accumulatePos + segLen
newseg<-rbind(newseg,cbind(accumulatePos,seg[row,c(1:6)]))
}
}
return(newseg)
}
statsSmallSeg <- function(gapSizes,segmentFile){
seg <- read.table(segmentFile,stringsAsFactors = F,header = T)
smallSeg <- lapply(gapSizes, function(gapSize){
newseg <-data.frame()
for (row in 1:nrow(seg)){
segLen <- seg[row,4]-seg[row,3]
if ( segLen< gapSize) {
newseg<-rbind(newseg,data.frame(length=seg[row,4]-seg[row,3],probes=seg[row,5]))
}
}
return (newseg)
})
names(smallSeg) <- gapSizes
return(smallSeg)
}