Skip to content

Commit 89836f2

Browse files
committed
restore old makeGraph_Chromosome.R
1 parent ad8fa4e commit 89836f2

File tree

1 file changed

+33
-106
lines changed

1 file changed

+33
-106
lines changed

scripts/makeGraph_Chromosome.R

Lines changed: 33 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,48 @@
1-
<<<<<<< HEAD
2-
path = "/data/tmp/cgurjao/Graphical_outputs/R\ scripts/FREEC_7.4/Single-end"
3-
setwd(path)
4-
5-
args = c()
6-
args[8] = 0
7-
args[7] = 0
8-
args[6] = "ratios_0.txt"
9-
args[5] = 2
10-
args[4] = 1
11-
12-
dataTable <-read.table(args[6], header=T, na.strings="NA");
13-
print(paste (args[6],"read"))
14-
=======
15-
#!/usr/bin/env Rscript
16-
171
args <- commandArgs()
182

193
dataTable <-read.table(args[6], header=TRUE);
204
print( paste (args[6],"read"))
21-
>>>>>>> 76030ffbfebd715b07a1c240056a37cb02bbb1ff
225
ratio<-data.frame(dataTable)
236
chr <- type.convert(args[4])
24-
ploidy <- type.convert(args[5])
25-
CN_subc = ratio$Subclones
26-
27-
max_value = 10#max(ratio$CopyNumber)
7+
#chr <- 'X'
8+
ploidy <- type.convert(args[5])
289

29-
plot(1:10)
30-
even_odd = 0
31-
even_odd2 = 0
32-
par(mfrow = c(2,1))
33-
for (i in c(1:11))
34-
{
35-
png(filename = paste(path, "/Results/","chr", i,".png",sep = ""), width = 1180, height = 1180,
36-
units = "px", pointsize = 20, bg = "white", res = NA)
37-
tt <- which(ratio$Chromosome==i)
38-
if (length(tt)>0) {
39-
tt <- which(ratio$Chromosome==i & ratio$CopyNumber==ploidy )
40-
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)
41-
tt <- which(ratio$Chromosome==i & ratio$CopyNumber>ploidy )
42-
points(ratio$Start[tt],ratio$Ratio[tt]*ploidy,pch = ".",col = rgb(1,0,0, alpha = 0.2),cex=8)
43-
tt <- which(ratio$Chromosome==i & ratio$CopyNumber<ploidy )
44-
points(ratio$Start[tt],ratio$Ratio[tt]*ploidy,pch = ".",col = rgb(0,0,1, alpha = 0.2),cex=8)
45-
tt <- which(ratio$Chromosome==i)
46-
points(ratio$Start[tt],ratio$CopyNumber[tt], pch = ".", col = colors()[24],cex=8)
47-
tt <- which(ratio$Chromosome==i)
48-
for (k in c(1:length(levels(CN_subc))))
49-
{
50-
if (levels(CN_subc)[k] != "0/0" && length(CN_subc) > 0)
51-
{
52-
ttt <- which(ratio$Subclones == levels(CN_subc)[k] & ratio$Chromosome==i)
53-
if (length(ttt)>0)
54-
{
55-
j = 1
56-
CN = ''
57-
pop = ''
58-
while (substr(as.character(ratio$Subclones[ttt]),j,j)[1] != "/")
59-
{
60-
CN = paste(CN,substr(as.character(ratio$Subclones[ttt]),j,j))
61-
j = j+1
62-
}
63-
j = 9
64-
while (substr(as.character(ratio$Subclones[ttt]),j,j)[1] != "/" )
65-
{
66-
pop[j] = paste(pop,substr(as.character(ratio$Subclones[ttt]),j,j))
67-
j = j-1
68-
}
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+
}
6916

70-
x = NA
71-
y = NA
72-
if (round(length(ttt)/2) > 0 && (-ratio$Start[ttt[1]] + ratio$Start[ttt[length(ttt)-1]]) > 10000000 )
73-
{
74-
if (even_odd %% 2 == 0) #(ratio$CopyNumber[ttt][round(length(ttt)/2)] > as.numeric(gsub(" ", "",CN[1])))
75-
{
76-
points(ratio$Start[ttt],CN, pch = ".", col = colors()[99],cex=8)
77-
if (even_odd2 %% 2 == 0)
78-
{x = as.numeric(ratio$Start[ttt][round(length(ttt)/3)])
79-
y = as.numeric(CN[1]) - 0.25
80-
even_odd2 = even_odd2 + 1}
81-
else
82-
{x = as.numeric(ratio$Start[ttt][round(length(ttt)/3)])
83-
y = as.numeric(CN[1]) + 0.25
84-
even_odd2 = even_odd2 + 1}
85-
even_odd = even_odd +1
86-
}
87-
else
88-
{
89-
points(ratio$Start[ttt],CN, pch = ".", col = colors()[96],cex=8)
90-
if (even_odd2 %% 2 != 0)
91-
{
92-
x = as.numeric(ratio$Start[ttt][round(length(ttt)/3)])
93-
y = as.numeric(CN[1]) + 0.25
94-
even_odd2 = even_odd2 + 1}
95-
else
96-
{x = as.numeric(ratio$Start[ttt][round(length(ttt)/3)])
97-
y = as.numeric(CN[1]) - 0.25
98-
even_odd2 = even_odd2 + 1}
99-
even_odd = even_odd +1
100-
}
101-
}
102-
pop = as.numeric(gsub("NA", "",gsub(",","",gsub(' ',"", toString(pop))))) * 100;
103-
pop = paste(as.character(as.integer(pop)),"%")
104-
text(x, y, as.character(pop), cex = 0.8, col = 'black')
105-
}
106-
}
107-
}
108-
}
109-
110-
if (args[7] != 0) {
111-
dataTable <-read.table(args[7], header=TRUE);
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);
11237
BAF<-data.frame(dataTable)
11338
tt <- which(BAF$Chromosome==i)
114-
lBAF <-BAF[tt,]
115-
plot(lBAF$Position,lBAF$BAF, ylim = c(-0.1,1.1),xlab = paste ("position, chr",i),ylab = "BAF",pch = ".",col = colors()[1])
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])
11641
tt <- which(lBAF$A==0.5)
11742
points(lBAF$Position[tt],lBAF$BAF[tt],pch = ".",col = colors()[92])
11843
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)
11946
points(lBAF$Position[tt],lBAF$BAF[tt],pch = ".",col = colors()[62])
12047
tt <- 1
12148
pres <- 1
@@ -129,4 +56,4 @@ for (i in c(1:11))
12956
print( paste (args[7],"read"))
13057
}
13158
dev.off()
132-
}
59+

0 commit comments

Comments
 (0)