-
Notifications
You must be signed in to change notification settings - Fork 3
/
CBS_data.R
58 lines (40 loc) · 1.36 KB
/
CBS_data.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
library(DNAcopy)
"CBS_data"<-function(data,path){
#data = read.table("/mnt/hgfs/2020.06.08--CNV_LOF/scalRD")
#data = matrix(data[,1],ncol=96,byrow=F)
#print(data)
#data = data[-1, -(1:2)]
#data = log2(data/2)
head = matrix(0, nrow(data), 3)
head[,1] = 1
head[,2] = 1:nrow(data)
head[,3] = 1:nrow(data)
chrom <- rep(1, nrow(data))
maploc <- 1:nrow(data)
seg.file_g = matrix(0,1,6)
seg.file_g_one = matrix(0,1,6)
seg.file = matrix(0, nrow(data), 1)
stac_amp = matrix(0, 1, nrow(data))
stac_amp[1,] = 1:nrow(data)
stac_amp_one = matrix(0, 1, nrow(data))
stac_del = matrix(0, 1, nrow(data))
stac_del[1,] = 1:nrow(data)
stac_del_one = matrix(0, 1, nrow(data))
for (j in 1:ncol(data)){
#cat("sampl No,",j,"\n")
#data <- CNA(data[,j],chrom,maploc)
seg<- segment(CNA(data[,j],chrom,maploc))
for (k in 1:length(seg$output$loc.start)){
seg.file_g_one[1,1]=j
seg.file_g_one[1,2]=1
seg.file_g_one[1,3]=seg$output$loc.start[k]
seg.file_g_one[1,4]=seg$output$loc.end[k]
seg.file_g_one[1,5]=seg$output$num.mark[k]
seg.file_g_one[1,6]=seg$output$seg.mean[k]
seg.file_g=rbind(seg.file_g,seg.file_g_one)
seg.file_g_one=matrix(0,1,6)
}
}
seg.file_g = seg.file_g[-1,]
write.table(seg.file_g,file=path,row.names=F,col.names=F,quote=F,sep="\t")
}