RNA-seq下游数据分析-ballgown到报告。 以Rscript为主,对接PGx RNA-seq choppy现有pipeline,到生成RNA-seq分析报告所需的rds和csv文件。
r
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 line
2.2KB

  1. #!/usr/bin/env Rscript
  2. ###Copyright 2019 Ying Yu from Fudan-PGx group
  3. # example:
  4. # Rscript RNAseq_3_cor.R -o /home/yuying/rnaseqreport_test -i ballgown_geneexp_log2fpkm_floor0p01_c3r58395_2019-04-29.txt -g group1.txt -p organoid
  5. suppressPackageStartupMessages(library("optparse"))
  6. suppressPackageStartupMessages(library("data.table"))
  7. # specify our desired options in a list
  8. # by default OptionParser will add an help option equivalent to
  9. # make_option(c("-h", "--help"), action="store_true", default=FALSE,
  10. # help="Show this help message and exit")
  11. option_list <- list(
  12. make_option(c("-o", "--out_dir"), type="character",default="./",
  13. help="The output directory [default ./]"),
  14. make_option(c("-i", "--input"),type="character", default=NULL,
  15. help="The input expression files. required!"),
  16. make_option(c("-g", "--sample_group"),type="character", default=NULL,
  17. help="File in tab-delimited format for sample group infomation. The input file containing sample name and group infomation. note colname must be like: sample group1 group2... "),
  18. make_option(c("-p", "--project_code"), type="character",default="rnaseq",
  19. help="Project code, which is used as prefix of output file. [default: rnaseq]")
  20. )
  21. # get command line options, if help option encountered print help and exit,
  22. # otherwise if options not found on command line then set defaults,
  23. opt <- parse_args(OptionParser(option_list=option_list))
  24. if (is.null(opt$input)){
  25. print_help(opt_parser)
  26. stop("At least one argument must be supplied (input file).", call.=FALSE)
  27. }
  28. ##import exp file
  29. out_dir<-paste(gsub("/$","",opt$out_dir),"/",sep="")
  30. logexpr<-fread(opt$input,header=T,stringsAsFactors=F,row.names=1,check.names=F,data.table=F)
  31. #check exp file is log scale
  32. if(max(logexpr[,1])-min(logexpr[,1])>100){
  33. stop("Correlation anlaysis should be conducted based on expression profile on log scale.", call.=FALSE)
  34. }
  35. #####################
  36. ##########correlation#######
  37. correlation<-cor(logexpr)
  38. ####finished cor
  39. #write output
  40. write.csv(correlation,paste(out_dir,opt$project_code,"_cor.csv",sep=""))
  41. saveRDS(correlation,paste(out_dir,opt$project_code,"_cor.rds",sep=""))
  42. ########