@@ -121,7 +121,6 @@ makeQCplots_chip_PE <- function(bam.file, outplot, pe.param){
121121 }
122122 collected <- plotwc(bam.file )
123123 xranged <- as.integer(names(collected ))
124-
125124 # # plot
126125 message(" Plotting" )
127126 pdf(outplot )
@@ -136,12 +135,13 @@ makeQCplots_chip_PE <- function(bam.file, outplot, pe.param){
136135
137136 # cross correlation
138137 plot(0 : max.delay , CCF , type = " l" , ylab = " CCF" , xlab = " Delay (bp)" , main = " PE-Cross-correlation" )
139-
138+ print(str(collected ))
139+ if ( any(is.null(collected )) | any(is.na(collected ))){message(" Skipping plotting cross correlation." )}else {
140140 # coverage in windows
141141 plot(xranged , collected , type = " l" , col = " blue" , xlim = c(- 1000 , 1000 ), lwd = 2 ,
142- xlab = " Distance (bp)" , ylab = " Relative coverage per base" )
142+ xlab = " Distance (bp)" , ylab = " Relative coverage per base" )
143143 abline(v = c(- 150 ,200 ), col = " dodgerblue" , lty = 2 )
144- legend(" topright" , col = " dodgerblue" , legend = " specified window size" )
144+ legend(" topright" , col = " dodgerblue" , legend = " specified window size" )}
145145
146146 dev.off()
147147
@@ -204,7 +204,11 @@ tmmNormalize_chip <- function(chipCountObject, binsize, plotfile){
204204 wider <- csaw :: windowCounts(bam.files , bin = TRUE , width = binsize , param = chipCountObject $ pe.param )
205205 if (useSpikeInForNorm ){
206206 tab <- read.table(scale_factors ,sep = " \t " ,header = TRUE ,as.is = TRUE ,quote = " " )
207- normfacs <- 1 / (tab $ scalingFactor [match(colnames(chipCountObject $ windowCounts ),tab $ sample )]) }else {
207+ if (! allelic_info ){
208+ normfacs <- 1 / (tab $ scalingFactor [match(colnames(chipCountObject $ windowCounts ),tab $ sample )])}else {
209+ normfacs <- 1 / (tab $ scalingFactor [match(gsub(" .genome[1-2]" ," " ,colnames(chipCountObject $ windowCounts )),tab $ sample )])
210+ }
211+ }else {
208212 normfacs <- csaw :: normFactors(wider , se.out = FALSE )}
209213
210214 chipCountObject $ normFactors <- normfacs
0 commit comments