1234567891011121314151617181920 |
- rm(list=ls())
- args<- commandArgs(TRUE)
- cov.file <- args[1]
- out.file <- args[2]
- num<- 10
- num<- ifelse(is.na(args[3]),num,as.numeric(args[3]) )
- dat <-read.table(file=cov.file,sep = "\t",as.is=TRUE,header=TRUE,check.names=FALSE)
- ncol<-dim(dat)[2]
- Y.dat<-dat[dat$chrom=="chrY" | dat$chrom=="Y",c(5:ncol)]
- Y.ndat<-Y.dat/rowMeans(Y.dat)
- n.sam<-dim(Y.dat)[2]
- n.sam
- num<- ifelse(num<n.sam, num, n.sam)
- num
- Y.mad <- apply(Y.ndat,MARGIN = 2,mad)
- ref.sam<-names(sort(Y.mad))[1:num]
- ref.sam
- write.table(ref.sam,file=out.file,sep="\t",quote=F,row.names=F,col.names=F)
|