Skip to content

Commit cb86f20

Browse files
authored
A script to create files in ABSOLUTE FORMAT
cat FREEC_ratio2Absolute.R | R --slave --args <*_ratio.txt>
1 parent f89a6e6 commit cb86f20

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

scripts/FREEC_ratio2Absolute.R

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
args <- commandArgs()
2+
3+
#read _ratio.txt:
4+
dataTable <-read.table(args[4], header=TRUE);
5+
6+
ratio<-data.frame(dataTable)
7+
8+
cat ("Chromosome\tStart\tEnd\tNum_Probes\tSegment_Mean")
9+
10+
weirdNum=345
11+
12+
for (i in c(unique(dataTable$Chromosome))) {
13+
tt <- which(ratio$Chromosome==i)
14+
if (length(tt)>0) {
15+
myMedianRatio=weirdNum
16+
mySegNUmber=0
17+
for (j in c(1:length(tt))) {
18+
if (ratio$MedianRatio[tt][j]!=myMedianRatio) {
19+
#print the record if it is not -1 or weirdNum
20+
if (myMedianRatio != -1 & myMedianRatio != weirdNum) {
21+
cat(i,"\t", ratio$Start[tt][j-mySegNumber], "\t", ratio$Start[tt][j]-1,"\t",mySegNumber,"\t",log(myMedianRatio,2),"\n")
22+
}
23+
#update
24+
mySegNumber=1
25+
myMedianRatio=ratio$MedianRatio[tt][j]
26+
}
27+
else {
28+
#update:
29+
mySegNumber = mySegNumber+1
30+
}
31+
}
32+
#print the last segment
33+
if (myMedianRatio != -1 & myMedianRatio != weirdNum) {
34+
cat(i,"\t", ratio$Start[tt][j-mySegNumber], "\t", ratio$Start[tt][j-1],"\t",mySegNumber,"\t",log(myMedianRatio,2),"\n")
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)