Skip to content

Commit d4c2a9f

Browse files
committed
current scripts
1 parent c376126 commit d4c2a9f

4 files changed

Lines changed: 329 additions & 37 deletions

File tree

scripts/_makeGraph_Chromosome.R

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
args <- commandArgs()
2+
3+
dataTable <-read.table(args[6], header=TRUE);
4+
print( paste (args[6],"read"))
5+
ratio<-data.frame(dataTable)
6+
chr <- type.convert(args[4])
7+
#chr <- 'X'
8+
ploidy <- type.convert(args[5])
9+
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+
}
16+
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);
37+
BAF<-data.frame(dataTable)
38+
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])
41+
tt <- which(lBAF$A==0.5)
42+
points(lBAF$Position[tt],lBAF$BAF[tt],pch = ".",col = colors()[92])
43+
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)
46+
points(lBAF$Position[tt],lBAF$BAF[tt],pch = ".",col = colors()[62])
47+
tt <- 1
48+
pres <- 1
49+
for (j in c(2:(length(lBAF$A)-pres-1))) {
50+
if (lBAF$A[j]==lBAF$A[j+pres]) {
51+
tt[length(tt)+1] <- j
52+
}
53+
}
54+
points(lBAF$Position[tt],lBAF$A[tt],pch = ".",col = colors()[24],cex=4)
55+
points(lBAF$Position[tt],lBAF$B[tt],pch = ".",col = colors()[24],cex=4)
56+
print( paste (args[7],"read"))
57+
}
58+
dev.off()
59+

scripts/makeGraph.R

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,38 @@ dataTable <-read.table(args[5], header=TRUE);
55
ratio<-data.frame(dataTable)
66
ploidy <- type.convert(args[4])
77

8+
9+
png(filename = paste(args[5],".log2.png",sep = ""), width = 1180, height = 1180,
10+
units = "px", pointsize = 20, bg = "white", res = NA)
11+
plot(1:10)
12+
op <- par(mfrow = c(5,5))
13+
14+
for (i in c(1:22,'X','Y')) {
15+
tt <- which(ratio$Chromosome==i)
16+
if (length(tt)>0) {
17+
plot(ratio$Start[tt],log2(ratio$Ratio[tt]),xlab = paste ("position, chr",i),ylab = "normalized copy number profile (log2)",pch = ".",col = colors()[88])
18+
tt <- which(ratio$Chromosome==i & ratio$CopyNumber>ploidy )
19+
points(ratio$Start[tt],log2(ratio$Ratio[tt]),pch = ".",col = colors()[136])
20+
21+
22+
tt <- which(ratio$Chromosome==i & ratio$CopyNumber<ploidy & ratio$CopyNumber!= -1)
23+
points(ratio$Start[tt],log2(ratio$Ratio[tt]),pch = ".",col = colors()[461])
24+
tt <- which(ratio$Chromosome==i)
25+
26+
#UNCOMMENT HERE TO SEE THE PREDICTED COPY NUMBER LEVEL:
27+
#points(ratio$Start[tt],log2(ratio$CopyNumber[tt]/ploidy), pch = ".", col = colors()[24],cex=4)
28+
29+
}
30+
tt <- which(ratio$Chromosome==i)
31+
32+
#UNCOMMENT HERE TO SEE THE EVALUATED MEDIAN LEVEL PER SEGMENT:
33+
#points(ratio$Start[tt],log2(ratio$MedianRatio[tt]), pch = ".", col = colors()[463],cex=4)
34+
35+
}
36+
37+
dev.off()
38+
39+
840
png(filename = paste(args[5],".png",sep = ""), width = 1180, height = 1180,
941
units = "px", pointsize = 20, bg = "white", res = NA)
1042
plot(1:10)
@@ -45,6 +77,9 @@ for (i in c(1:22,'X','Y')) {
4577

4678
dev.off()
4779

80+
81+
82+
4883
if (length(args)>5) {
4984
dataTable <-read.table(args[6], header=TRUE);
5085
BAF<-data.frame(dataTable)

scripts/makeGraph.R~

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
args <- commandArgs()
2+
3+
dataTable <-read.table(args[5], header=TRUE);
4+
5+
ratio<-data.frame(dataTable)
6+
ploidy <- type.convert(args[4])
7+
8+
9+
png(filename = paste(args[5],".log2.png",sep = ""), width = 1180, height = 1180,
10+
units = "px", pointsize = 20, bg = "white", res = NA)
11+
plot(1:10)
12+
op <- par(mfrow = c(5,5))
13+
14+
for (i in c(1:22,'X','Y')) {
15+
tt <- which(ratio$Chromosome==i)
16+
if (length(tt)>0) {
17+
plot(ratio$Start[tt],log2(ratio$Ratio[tt]),xlab = paste ("position, chr",i),ylab = "normalized copy number profile (log2)",pch = ".",col = colors()[88])
18+
tt <- which(ratio$Chromosome==i & ratio$CopyNumber>ploidy )
19+
points(ratio$Start[tt],log2(ratio$Ratio[tt]),pch = ".",col = colors()[136])
20+
21+
tt <- which(ratio$Chromosome==i & ratio$Ratio==maxLevelToPlot & ratio$CopyNumber>ploidy)
22+
points(ratio$Start[tt],log2(ratio$Ratio[tt]),pch = ".",col = colors()[136],cex=4)
23+
24+
tt <- which(ratio$Chromosome==i & ratio$CopyNumber<ploidy & ratio$CopyNumber!= -1)
25+
points(ratio$Start[tt],log2(ratio$Ratio[tt]),pch = ".",col = colors()[461])
26+
tt <- which(ratio$Chromosome==i)
27+
28+
#UNCOMMENT HERE TO SEE THE PREDICTED COPY NUMBER LEVEL:
29+
#points(ratio$Start[tt],log2(ratio$CopyNumber[tt]/ploidy), pch = ".", col = colors()[24],cex=4)
30+
31+
}
32+
tt <- which(ratio$Chromosome==i)
33+
34+
#UNCOMMENT HERE TO SEE THE EVALUATED MEDIAN LEVEL PER SEGMENT:
35+
#points(ratio$Start[tt],log2(ratio$MedianRatio[tt]), pch = ".", col = colors()[463],cex=4)
36+
37+
}
38+
39+
dev.off()
40+
41+
42+
png(filename = paste(args[5],".png",sep = ""), width = 1180, height = 1180,
43+
units = "px", pointsize = 20, bg = "white", res = NA)
44+
plot(1:10)
45+
op <- par(mfrow = c(5,5))
46+
47+
maxLevelToPlot <- 3
48+
for (i in c(1:length(ratio$Ratio))) {
49+
if (ratio$Ratio[i]>maxLevelToPlot) {
50+
ratio$Ratio[i]=maxLevelToPlot;
51+
}
52+
}
53+
54+
55+
for (i in c(1:22,'X','Y')) {
56+
tt <- which(ratio$Chromosome==i)
57+
if (length(tt)>0) {
58+
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])
59+
tt <- which(ratio$Chromosome==i & ratio$CopyNumber>ploidy )
60+
points(ratio$Start[tt],ratio$Ratio[tt]*ploidy,pch = ".",col = colors()[136])
61+
62+
tt <- which(ratio$Chromosome==i & ratio$Ratio==maxLevelToPlot & ratio$CopyNumber>ploidy)
63+
points(ratio$Start[tt],ratio$Ratio[tt]*ploidy,pch = ".",col = colors()[136],cex=4)
64+
65+
tt <- which(ratio$Chromosome==i & ratio$CopyNumber<ploidy & ratio$CopyNumber!= -1)
66+
points(ratio$Start[tt],ratio$Ratio[tt]*ploidy,pch = ".",col = colors()[461])
67+
tt <- which(ratio$Chromosome==i)
68+
69+
#UNCOMMENT HERE TO SEE THE PREDICTED COPY NUMBER LEVEL:
70+
#points(ratio$Start[tt],ratio$CopyNumber[tt], pch = ".", col = colors()[24],cex=4)
71+
72+
}
73+
tt <- which(ratio$Chromosome==i)
74+
75+
#UNCOMMENT HERE TO SEE THE EVALUATED MEDIAN LEVEL PER SEGMENT:
76+
#points(ratio$Start[tt],ratio$MedianRatio[tt]*ploidy, pch = ".", col = colors()[463],cex=4)
77+
78+
}
79+
80+
dev.off()
81+
82+
83+
84+
85+
if (length(args)>5) {
86+
dataTable <-read.table(args[6], header=TRUE);
87+
BAF<-data.frame(dataTable)
88+
89+
png(filename = paste(args[6],".png",sep = ""), width = 1180, height = 1180,
90+
units = "px", pointsize = 20, bg = "white", res = NA)
91+
plot(1:10)
92+
op <- par(mfrow = c(5,5))
93+
94+
for (i in c(1:22,'X','Y')) {
95+
tt <- which(BAF$Chromosome==i)
96+
if (length(tt)>0){
97+
lBAF <-BAF[tt,]
98+
plot(lBAF$Position,lBAF$BAF,ylim = c(-0.1,1.1),xlab = paste ("position, chr",i),ylab = "BAF",pch = ".",col = colors()[1])
99+
100+
tt <- which(lBAF$A==0.5)
101+
points(lBAF$Position[tt],lBAF$BAF[tt],pch = ".",col = colors()[92])
102+
tt <- which(lBAF$A!=0.5 & lBAF$A>=0)
103+
points(lBAF$Position[tt],lBAF$BAF[tt],pch = ".",col = colors()[62])
104+
tt <- 1
105+
pres <- 1
106+
107+
if (length(lBAF$A)>4) {
108+
for (j in c(2:(length(lBAF$A)-pres-1))) {
109+
if (lBAF$A[j]==lBAF$A[j+pres]) {
110+
tt[length(tt)+1] <- j
111+
}
112+
}
113+
points(lBAF$Position[tt],lBAF$A[tt],pch = ".",col = colors()[24],cex=4)
114+
points(lBAF$Position[tt],lBAF$B[tt],pch = ".",col = colors()[24],cex=4)
115+
}
116+
117+
tt <- 1
118+
pres <- 1
119+
if (length(lBAF$FittedA)>4) {
120+
for (j in c(2:(length(lBAF$FittedA)-pres-1))) {
121+
if (lBAF$FittedA[j]==lBAF$FittedA[j+pres]) {
122+
tt[length(tt)+1] <- j
123+
}
124+
}
125+
points(lBAF$Position[tt],lBAF$FittedA[tt],pch = ".",col = colors()[463],cex=4)
126+
points(lBAF$Position[tt],lBAF$FittedB[tt],pch = ".",col = colors()[463],cex=4)
127+
}
128+
129+
}
130+
131+
}
132+
dev.off()
133+
134+
}

scripts/makeGraph_Chromosome.R

Lines changed: 101 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,112 @@
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"))
513
ratio<-data.frame(dataTable)
614
chr <- 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
}
58122
dev.off()
59-
123+
}

0 commit comments

Comments
 (0)