RNA-seq下游数据分析-ballgown到报告。 以Rscript为主,对接PGx RNA-seq choppy现有pipeline,到生成RNA-seq分析报告所需的rds和csv文件。
r
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

51 Zeilen
2.1KB

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