123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- args<- commandArgs(TRUE)
- sam <- args[1]
- sam_data <- read.table(file=paste(sam,".cov",sep=""),header = TRUE,sep="\t",as.is=TRUE)
- sam_data <- sam_data[,c(1,5)]
- names(sam_data) <- c('contig',sam)
- sam_m <- mean(sam_data[,2])
- sam_sd<- sd(sam_data[,2])
- vals<-sam_data[,sam]
- vals=vals/sam_m
- vals[vals < 0.07] <- 0.07
- sam_data$Mean <- vals
- fivenum(sam_data[sam_data$contig=='Y',sam])
- y_mean <- mean(sam_data[sam_data$contig=='Y','Mean'])
- sex <- 'F'
- if(y_mean > 0.2){
- sex <- 'M'
- }
- pdf(file=paste(sam,sex,"QC_plot.pdf",sep="_"),width = 10)
- hist(sam_data[,sam],breaks=1000,xlim=c(0,1500),col='lightblue',
- xlab='Counts',main=paste(sam,' Counts/Bin. Mean= ',
- round(sam_m,0),' SD=',round(sam_sd,0),sep=''),freq = F)
- hist(sam_data[,'Mean'],breaks=1000,xlim=c(0,3),col='lightblue',
- xlab='Copy-Ratio',main=paste(sam,' Bin Copy-Ratio Distributions',sep=''),freq = F)
- hist(sam_data[sam_data$contig =='X' |sam_data$contig =='Y',sam],breaks=1000,xlim=c(0,1500),col='lightblue',
- xlab='Counts',main=paste(sam,' XY Counts/Bin. Mean= ',
- round(sam_m,0),' SD=',round(sam_sd,0),sep=''),freq = F)
- hist(sam_data[sam_data$contig =='X' |sam_data$contig =='Y','Mean'],breaks=1000,xlim=c(0,3),col='lightblue',
- xlab='Copy-Ratio',main=paste(sam,' XY Bin Copy-Ratio Distributions',sep=''),freq = F)
- boxplot(sam_data[,sam] ~ ordered(sam_data$contig,levels=c(1:22,'X','Y')),ylim=c(0,1500),
- main=paste(sam,'-Boxplot of Counts/Bin. Mean=',round(sam_m,0),
- 'SD/Mean=',round(sam_sd/sam_m,2),sep=' ') )
- lines(rep(sam_m,24),col='red')
- boxplot(sam_data[,'Mean'] ~ ordered(sam_data$contig,levels=c(1:22,'X','Y')),ylim=c(0,3),
- main=paste(sam,'-Boxplot of Copy-Ratio.',sep=' '))
- lines(rep(1,24),col='red')
- dev.off()
|