1- args <- commandArgs()
2-
3- dataTable <- read.table(args [6 ], header = TRUE );
4- print( paste (args [6 ]," read" ))
1+ path = " /data/tmp/cgurjao/Graphical_outputs/R\ scripts/FREEC_7.4/Single-end"
2+ setwd(path )
3+
4+ args = c()
5+ args [8 ] = 0
6+ args [7 ] = 0
7+ args [6 ] = " ratios_0.txt"
8+ args [5 ] = 2
9+ args [4 ] = 1
10+
11+ dataTable <- read.table(args [6 ], header = T , na.strings = " NA" );
12+ print(paste (args [6 ]," read" ))
513ratio <- data.frame (dataTable )
614chr <- type.convert(args [4 ])
7- # chr <- 'X'
8- ploidy <- type.convert( args [ 5 ])
15+ ploidy <- type.convert( args [ 5 ])
16+ CN_subc = ratio $ Subclones
917
10- maxLevelToPlot <- 3
11- for (i in c(1 : length(ratio $ Ratio ))) {
12- if (ratio $ Ratio [i ]> maxLevelToPlot ) {
13- ratio $ Ratio [i ]= maxLevelToPlot ;
14- }
15- }
18+ max_value = 10 # max(ratio$CopyNumber)
1619
17- png(filename = paste(args [6 ]," .png" ,sep = " " ), width = 1180 , height = 1180 ,
18- units = " px" , pointsize = 20 , bg = " white" , res = NA )
19- plot(1 : 10 )
20- op <- par(mfrow = c(2 ,1 ))
21- i <- chr
22- tt <- which(ratio $ Chromosome == i )
23- if (length(tt )> 0 ) {
24- plot(ratio $ Start [tt ],ratio $ Ratio [tt ]* ploidy ,ylim = c(0 ,maxLevelToPlot * ploidy ),xlab = paste (" position, chr" ,i ),ylab = " normalized copy number profile" ,pch = " ." ,col = colors()[88 ],cex = 2 )
25- tt <- which(ratio $ Chromosome == i & ratio $ CopyNumber > ploidy )
26- points(ratio $ Start [tt ],ratio $ Ratio [tt ]* ploidy ,pch = " ." ,col = colors()[136 ],cex = 2 )
27- tt <- which(ratio $ Chromosome == i & ratio $ Ratio == maxLevelToPlot )
28- points(ratio $ Start [tt ],ratio $ Ratio [tt ]* ploidy ,pch = " ." ,col = colors()[136 ],cex = 4 )
29- tt <- which(ratio $ Chromosome == i & ratio $ CopyNumber < ploidy )
30- points(ratio $ Start [tt ],ratio $ Ratio [tt ]* ploidy ,pch = " ." ,col = colors()[461 ],cex = 2 )
31- tt <- which(ratio $ Chromosome == i )
32- points(ratio $ Start [tt ],ratio $ CopyNumber [tt ], pch = " ." , col = colors()[24 ],cex = 2 )
33- points(ratio $ Start [tt ],ratio $ MedianRatio [tt ]* ploidy , pch = " ." , col = colors()[98 ],cex = 4 )
34- }
35- if (length(args )> = 7 ) {
36- dataTable <- read.table(args [7 ], header = TRUE );
20+ plot(1 : 10 )
21+ even_odd = 0
22+ even_odd2 = 0
23+ par(mfrow = c(2 ,1 ))
24+ for (i in c(1 : 11 ))
25+ {
26+ png(filename = paste(path , " /Results/" ," chr" , i ," .png" ,sep = " " ), width = 1180 , height = 1180 ,
27+ units = " px" , pointsize = 20 , bg = " white" , res = NA )
28+ tt <- which(ratio $ Chromosome == i )
29+ if (length(tt )> 0 ) {
30+ tt <- which(ratio $ Chromosome == i & ratio $ CopyNumber == ploidy )
31+ plot(ratio $ Start [tt ],ratio $ Ratio [tt ]* ploidy ,ylim = c(0 ,max_value ),xlab = paste (" position, chr" ,i ),ylab = " normalized copy number profile" ,pch = " ." ,col = rgb(0 ,1 ,0 , alpha = 0.2 ),cex = 8 )
32+ tt <- which(ratio $ Chromosome == i & ratio $ CopyNumber > ploidy )
33+ points(ratio $ Start [tt ],ratio $ Ratio [tt ]* ploidy ,pch = " ." ,col = rgb(1 ,0 ,0 , alpha = 0.2 ),cex = 8 )
34+ tt <- which(ratio $ Chromosome == i & ratio $ CopyNumber < ploidy )
35+ points(ratio $ Start [tt ],ratio $ Ratio [tt ]* ploidy ,pch = " ." ,col = rgb(0 ,0 ,1 , alpha = 0.2 ),cex = 8 )
36+ tt <- which(ratio $ Chromosome == i )
37+ points(ratio $ Start [tt ],ratio $ CopyNumber [tt ], pch = " ." , col = colors()[24 ],cex = 8 )
38+ tt <- which(ratio $ Chromosome == i )
39+ for (k in c(1 : length(levels(CN_subc ))))
40+ {
41+ if (levels(CN_subc )[k ] != " 0/0" && length(CN_subc ) > 0 )
42+ {
43+ ttt <- which(ratio $ Subclones == levels(CN_subc )[k ] & ratio $ Chromosome == i )
44+ if (length(ttt )> 0 )
45+ {
46+ j = 1
47+ CN = ' '
48+ pop = ' '
49+ while (substr(as.character(ratio $ Subclones [ttt ]),j ,j )[1 ] != " /" )
50+ {
51+ CN = paste(CN ,substr(as.character(ratio $ Subclones [ttt ]),j ,j ))
52+ j = j + 1
53+ }
54+ j = 9
55+ while (substr(as.character(ratio $ Subclones [ttt ]),j ,j )[1 ] != " /" )
56+ {
57+ pop [j ] = paste(pop ,substr(as.character(ratio $ Subclones [ttt ]),j ,j ))
58+ j = j - 1
59+ }
60+
61+ x = NA
62+ y = NA
63+ if (round(length(ttt )/ 2 ) > 0 && (- ratio $ Start [ttt [1 ]] + ratio $ Start [ttt [length(ttt )- 1 ]]) > 10000000 )
64+ {
65+ if (even_odd %% 2 == 0 ) # (ratio$CopyNumber[ttt][round(length(ttt)/2)] > as.numeric(gsub(" ", "",CN[1])))
66+ {
67+ points(ratio $ Start [ttt ],CN , pch = " ." , col = colors()[99 ],cex = 8 )
68+ if (even_odd2 %% 2 == 0 )
69+ {x = as.numeric(ratio $ Start [ttt ][round(length(ttt )/ 3 )])
70+ y = as.numeric(CN [1 ]) - 0.25
71+ even_odd2 = even_odd2 + 1 }
72+ else
73+ {x = as.numeric(ratio $ Start [ttt ][round(length(ttt )/ 3 )])
74+ y = as.numeric(CN [1 ]) + 0.25
75+ even_odd2 = even_odd2 + 1 }
76+ even_odd = even_odd + 1
77+ }
78+ else
79+ {
80+ points(ratio $ Start [ttt ],CN , pch = " ." , col = colors()[96 ],cex = 8 )
81+ if (even_odd2 %% 2 != 0 )
82+ {
83+ x = as.numeric(ratio $ Start [ttt ][round(length(ttt )/ 3 )])
84+ y = as.numeric(CN [1 ]) + 0.25
85+ even_odd2 = even_odd2 + 1 }
86+ else
87+ {x = as.numeric(ratio $ Start [ttt ][round(length(ttt )/ 3 )])
88+ y = as.numeric(CN [1 ]) - 0.25
89+ even_odd2 = even_odd2 + 1 }
90+ even_odd = even_odd + 1
91+ }
92+ }
93+ pop = as.numeric(gsub(" NA" , " " ,gsub(" ," ," " ,gsub(' ' ," " , toString(pop ))))) * 100 ;
94+ pop = paste(as.character(as.integer(pop ))," %" )
95+ text(x , y , as.character(pop ), cex = 0.8 , col = ' black' )
96+ }
97+ }
98+ }
99+ }
100+
101+ if (args [7 ] != 0 ) {
102+ dataTable <- read.table(args [7 ], header = TRUE );
37103 BAF <- data.frame (dataTable )
38104 tt <- which(BAF $ Chromosome == i )
39- lBAF <- BAF [tt ,]
40- plot(lBAF $ Position ,lBAF $ BAF ,ylim = c(- 0.1 ,1.1 ),xlab = paste (" position, chr" ,i ),ylab = " BAF" ,pch = " ." ,col = colors()[1 ])
105+ lBAF <- BAF [tt ,]
106+ plot(lBAF $ Position ,lBAF $ BAF , ylim = c(- 0.1 ,1.1 ),xlab = paste (" position, chr" ,i ),ylab = " BAF" ,pch = " ." ,col = colors()[1 ])
41107 tt <- which(lBAF $ A == 0.5 )
42108 points(lBAF $ Position [tt ],lBAF $ BAF [tt ],pch = " ." ,col = colors()[92 ])
43109 tt <- which(lBAF $ A != 0.5 & lBAF $ A > = 0 )
44- points(lBAF $ Position [tt ],lBAF $ BAF [tt ],pch = " ." ,col = colors()[450 ])
45- tt <- which(lBAF $ B == 1 )
46110 points(lBAF $ Position [tt ],lBAF $ BAF [tt ],pch = " ." ,col = colors()[62 ])
47111 tt <- 1
48112 pres <- 1
@@ -56,4 +120,4 @@ if (length(args)>=7) {
56120 print( paste (args [7 ]," read" ))
57121}
58122dev.off()
59-
123+ }
0 commit comments