From 89836f24950f6ccc0a78ba7ad5308c01a7b807c9 Mon Sep 17 00:00:00 2001 From: Valentina Boeva Date: Mon, 26 Jun 2017 13:44:13 +0200 Subject: [PATCH] restore old makeGraph_Chromosome.R --- scripts/makeGraph_Chromosome.R | 139 ++++++++------------------------- 1 file changed, 33 insertions(+), 106 deletions(-) diff --git a/scripts/makeGraph_Chromosome.R b/scripts/makeGraph_Chromosome.R index 8bd2dcb..1c45aed 100644 --- a/scripts/makeGraph_Chromosome.R +++ b/scripts/makeGraph_Chromosome.R @@ -1,121 +1,48 @@ -<<<<<<< HEAD -path = "/data/tmp/cgurjao/Graphical_outputs/R\ scripts/FREEC_7.4/Single-end" -setwd(path) - -args = c() -args[8] = 0 -args[7] = 0 -args[6] = "ratios_0.txt" -args[5] = 2 -args[4] = 1 - -dataTable <-read.table(args[6], header=T, na.strings="NA"); -print(paste (args[6],"read")) -======= -#!/usr/bin/env Rscript - args <- commandArgs() dataTable <-read.table(args[6], header=TRUE); print( paste (args[6],"read")) ->>>>>>> 76030ffbfebd715b07a1c240056a37cb02bbb1ff ratio<-data.frame(dataTable) chr <- type.convert(args[4]) -ploidy <- type.convert(args[5]) -CN_subc = ratio$Subclones - -max_value = 10#max(ratio$CopyNumber) +#chr <- 'X' +ploidy <- type.convert(args[5]) -plot(1:10) -even_odd = 0 -even_odd2 = 0 -par(mfrow = c(2,1)) -for (i in c(1:11)) -{ - png(filename = paste(path, "/Results/","chr", i,".png",sep = ""), width = 1180, height = 1180, - units = "px", pointsize = 20, bg = "white", res = NA) - tt <- which(ratio$Chromosome==i) - if (length(tt)>0) { - tt <- which(ratio$Chromosome==i & ratio$CopyNumber==ploidy ) - 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) - tt <- which(ratio$Chromosome==i & ratio$CopyNumber>ploidy ) - points(ratio$Start[tt],ratio$Ratio[tt]*ploidy,pch = ".",col = rgb(1,0,0, alpha = 0.2),cex=8) - tt <- which(ratio$Chromosome==i & ratio$CopyNumber 0) - { - ttt <- which(ratio$Subclones == levels(CN_subc)[k] & ratio$Chromosome==i) - if (length(ttt)>0) - { - j = 1 - CN = '' - pop = '' - while (substr(as.character(ratio$Subclones[ttt]),j,j)[1] != "/") - { - CN = paste(CN,substr(as.character(ratio$Subclones[ttt]),j,j)) - j = j+1 - } - j = 9 - while (substr(as.character(ratio$Subclones[ttt]),j,j)[1] != "/" ) - { - pop[j] = paste(pop,substr(as.character(ratio$Subclones[ttt]),j,j)) - j = j-1 - } +maxLevelToPlot <- 3 +for (i in c(1:length(ratio$Ratio))) { + if (ratio$Ratio[i]>maxLevelToPlot) { + ratio$Ratio[i]=maxLevelToPlot; + } +} - x = NA - y = NA - if (round(length(ttt)/2) > 0 && (-ratio$Start[ttt[1]] + ratio$Start[ttt[length(ttt)-1]]) > 10000000 ) - { - if (even_odd %% 2 == 0) #(ratio$CopyNumber[ttt][round(length(ttt)/2)] > as.numeric(gsub(" ", "",CN[1]))) - { - points(ratio$Start[ttt],CN, pch = ".", col = colors()[99],cex=8) - if (even_odd2 %% 2 == 0) - {x = as.numeric(ratio$Start[ttt][round(length(ttt)/3)]) - y = as.numeric(CN[1]) - 0.25 - even_odd2 = even_odd2 + 1} - else - {x = as.numeric(ratio$Start[ttt][round(length(ttt)/3)]) - y = as.numeric(CN[1]) + 0.25 - even_odd2 = even_odd2 + 1} - even_odd = even_odd +1 - } - else - { - points(ratio$Start[ttt],CN, pch = ".", col = colors()[96],cex=8) - if (even_odd2 %% 2 != 0) - { - x = as.numeric(ratio$Start[ttt][round(length(ttt)/3)]) - y = as.numeric(CN[1]) + 0.25 - even_odd2 = even_odd2 + 1} - else - {x = as.numeric(ratio$Start[ttt][round(length(ttt)/3)]) - y = as.numeric(CN[1]) - 0.25 - even_odd2 = even_odd2 + 1} - even_odd = even_odd +1 - } - } - pop = as.numeric(gsub("NA", "",gsub(",","",gsub(' ',"", toString(pop))))) * 100; - pop = paste(as.character(as.integer(pop)),"%") - text(x, y, as.character(pop), cex = 0.8, col = 'black') - } - } - } - } - - if (args[7] != 0) { - dataTable <-read.table(args[7], header=TRUE); +png(filename = paste(args[6],".png",sep = ""), width = 1180, height = 1180, + units = "px", pointsize = 20, bg = "white", res = NA) +plot(1:10) +op <- par(mfrow = c(2,1)) +i <- chr + tt <- which(ratio$Chromosome == i) + if (length(tt)>0) { + 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) + tt <- which(ratio$Chromosome==i & ratio$CopyNumber>ploidy ) + points(ratio$Start[tt],ratio$Ratio[tt]*ploidy,pch = ".",col = colors()[136],cex=2) + tt <- which(ratio$Chromosome==i & ratio$Ratio==maxLevelToPlot) + points(ratio$Start[tt],ratio$Ratio[tt]*ploidy,pch = ".",col = colors()[136],cex=4) + tt <- which(ratio$Chromosome==i & ratio$CopyNumber=7) { + dataTable <-read.table(args[7], header=TRUE); BAF<-data.frame(dataTable) tt <- which(BAF$Chromosome==i) - lBAF <-BAF[tt,] - plot(lBAF$Position,lBAF$BAF, ylim = c(-0.1,1.1),xlab = paste ("position, chr",i),ylab = "BAF",pch = ".",col = colors()[1]) + lBAF <-BAF[tt,] + plot(lBAF$Position,lBAF$BAF,ylim = c(-0.1,1.1),xlab = paste ("position, chr",i),ylab = "BAF",pch = ".",col = colors()[1]) tt <- which(lBAF$A==0.5) points(lBAF$Position[tt],lBAF$BAF[tt],pch = ".",col = colors()[92]) tt <- which(lBAF$A!=0.5 & lBAF$A>=0) + points(lBAF$Position[tt],lBAF$BAF[tt],pch = ".",col = colors()[450]) + tt <- which(lBAF$B==1) points(lBAF$Position[tt],lBAF$BAF[tt],pch = ".",col = colors()[62]) tt <- 1 pres <- 1 @@ -129,4 +56,4 @@ for (i in c(1:11)) print( paste (args[7],"read")) } dev.off() -} +