12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- args<- commandArgs(TRUE)
- sam <- args[1]
- sam_data <- read.table(file=paste(sam,".cov",sep=""),header = TRUE,sep="\t",as.is=TRUE)
- ncols<-dim(sam_data)[2]
- if (ncols ==5 ) {
- sam_data <- sam_data[,c(1,5)]
- }else if (ncols ==10 ) {
- sam_data <- sam_data[,c(1,7)]
- }else{
- q(save = FALSE)
- }
- 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
- Y_median<-fivenum(sam_data[sam_data$contig=='Y',sam])[3]
- fivenum(sam_data[sam_data$contig=='Y',sam])
- y_mean <- mean(sam_data[sam_data$contig=='Y','Mean'])
- y_mean
- sex <- 'F'
- if(y_mean > 0.5){
- sex <- 'M'
- }
- pdf(file=paste(sam,sex,"QC_plot.pdf",sep="_"),width = 10)
- hist(sam_data[,sam],breaks=1000,xlim=c(0,500),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,500),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,500),
- 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()
|