Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addressing issues due to nan values, causing need finite 'ylim' value… #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions scripts/makeGraph2.0.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,23 @@ if (ratioFileInd) {

#Plotting in the log scale:
offset = 0.01

ratio$log2ratio <- log2(ratio$Ratio+offset) #added calculated column to main table so that the operation is only done once

png(filename = paste(args[ratioFileInd],".log2.png",sep = ""), width = 1180, height = 1180,
units = "px", pointsize = 20, bg = "white", res = NA)
plot(1:10)
op <- par(mfrow = c(5,5))

for (i in c(1:22,'X','Y')) {
tt <- which(ratio$Chromosome==i)
tt <- which(ratio$Chromosome==i & is.na(ratio$log2ratio)==FALSE) #filtering rows with na values in log2ratio and it uses the calculated column instead of calculating it every time
if (length(tt)>0) {
plot(ratio$Start[tt],log2(ratio$Ratio[tt]+offset),xlab = paste ("position, chr",i),ylab = "normalized copy number profile (log2)",pch = ".",col = colors()[88])
tt <- which(ratio$Chromosome==i & ratio$CopyNumber>ploidy )
points(ratio$Start[tt],log2(ratio$Ratio[tt]+offset),pch = ".",col = colors()[136])
plot(ratio$Start[tt],ratio$log2ratio[tt],xlab = paste ("position, chr",i),ylab = "normalized copy number profile (log2)",pch = ".",col = colors()[88]) #it uses the calculated log2 column
tt <- which(ratio$Chromosome==i & ratio$CopyNumber>ploidy & is.na(ratio$log2ratio)==FALSE) #added the na filter to the points too and it uses the calculated column
points(ratio$Start[tt],ratio$log2ratio[tt],pch = ".",col = colors()[136])


tt <- which(ratio$Chromosome==i & ratio$CopyNumber<ploidy & ratio$CopyNumber!= -1)
points(ratio$Start[tt],log2(ratio$Ratio[tt]+offset),pch = ".",col = colors()[461])
tt <- which(ratio$Chromosome==i & ratio$CopyNumber<ploidy & ratio$CopyNumber!= -1 & is.na(ratio$log2ratio)==FALSE) #added the na filter to the points too and it uses the calculated column
points(ratio$Start[tt],ratio$log2ratio[tt],pch = ".",col = colors()[461])
tt <- which(ratio$Chromosome==i)

#UNCOMMENT HERE TO SEE THE PREDICTED COPY NUMBER LEVEL:
Expand All @@ -66,7 +67,7 @@ if (ratioFileInd) {

}
dev.off()

#------------------------------------------------------
#Plotting in raw ratio values:
png(filename = paste(args[ratioFileInd],".png",sep = ""), width = 1180, height = 1180,
Expand All @@ -77,12 +78,12 @@ if (ratioFileInd) {
#replace high values of ratio with value "maxLevelToPlot":
maxLevelToPlot <- 3
ratio$Ratio[ratio$Ratio>maxLevelToPlot]=maxLevelToPlot

for (i in c(1:22,'X','Y')) {
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])
tt <- which(ratio$Chromosome==i & ratio$CopyNumber>ploidy )
tt <- which(ratio$Chromosome==i & ratio$CopyNumber>ploidy)
points(ratio$Start[tt],ratio$Ratio[tt]*ploidy,pch = ".",col = colors()[136])

tt <- which(ratio$Chromosome==i & ratio$Ratio==maxLevelToPlot & ratio$CopyNumber>ploidy)
Expand Down Expand Up @@ -161,4 +162,4 @@ if (BAFfileInd) {
}
dev.off()

} else {cat ("WARNING: To get a .png image with BAF profile, you can provide as input a file with suffix 'BAF.txt'\n")}
} else {cat ("WARNING: To get a .png image with BAF profile, you can provide as input a file with suffix 'BAF.txt'\n")}