get_AZF_ref.r 558 B

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