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.

98 line
3.6KB

  1. args <- commandArgs(TRUE)
  2. if(length(args)<1){
  3. args <- c("--help")
  4. }
  5. ##help section
  6. if("--help"%in%args){
  7. cat("Arguments:
  8. --out_dir=out_directory The output directory
  9. --Tumor_LogR_file=tumor_LogR The output tumor LogR file from ascatNgs
  10. --Tumor_BAF_file=tumor_BAF The output tumor BAF file from ascatNgs
  11. --Germline_LogR_file=Normal_LogR The output normal LogR file from ascatNgs
  12. --Germline_BAF_file=Normal_BAF The output normal BAF file from ascatNgs
  13. --HRD_file_prefix=prefix The name prefix of HRD score results
  14. These parameters must be set in orders!
  15. ")
  16. q(save = "no")
  17. }
  18. message(paste0("\n\nYou have the Rights to copy, edit, send and distribute this files,",
  19. " but not as Commercial activities.\nEnjoy!\n"))
  20. args[[1]] <- gsub("--out_dir=","",args[[1]])
  21. args[[2]] <- gsub("--Tumor_LogR_file=","",args[[2]])
  22. args[[3]] <- gsub("--Tumor_BAF_file=","",args[[3]])
  23. args[[4]] <- gsub("--Germline_LogR_file=","",args[[4]])
  24. args[[5]] <- gsub("--Germline_BAF_file=","",args[[5]])
  25. args[[6]] <- gsub("--HRD_file_prefix=","",args[[6]])
  26. #################################################
  27. #################################################
  28. ######## Deal with ASCAT results ########
  29. ######## Output of ascatNgs ########
  30. #################################################
  31. #################################################
  32. library(ASCAT)
  33. source("f:/choppy_app/HRD_score/HRD_functions.R")
  34. #setwd(args[[1]])
  35. rep_1_ascat.bc <- ascat.loadData(Tumor_LogR_file = args[[2]],
  36. Tumor_BAF_file = args[[3]],
  37. Germline_LogR_file = args[[4]],
  38. Germline_BAF_file = args[[5]],
  39. gender = "XX",
  40. sexchromosomes = c("X","Y"))
  41. #dir.create("../res/")
  42. setwd(args[[1]])
  43. ##no GC content correction here
  44. #rep_1_ascat.bc <- ascat.GCcorrect(rep_1_ascat.bc,GCcontentfile = "../SnpGcCorrections.tsv")
  45. ascat.plotRawData(rep_1_ascat.bc)
  46. rep_1_ascat.bc = ascat.aspcf(rep_1_ascat.bc)
  47. ascat.plotSegmentedData(rep_1_ascat.bc)
  48. rep_1_ascat.output = ascat.runAscat(rep_1_ascat.bc)
  49. #################################################
  50. #################################################
  51. ######## Calculate Three HRD score ########
  52. #################################################
  53. #################################################
  54. rep_1_x <- cbind(rep_1_ascat.output$segments[,1:4],
  55. number_of_propes=count_total_numbers(segment_data = rep_1_ascat.output$segments,
  56. SNP_pos_info = rep_1_ascat.bc$SNPpos)[,1],
  57. total_copy_number=apply(rep_1_ascat.output$segments[,5:6],1,sum),
  58. rep_1_ascat.output$segments[,5:6],
  59. ploidy=rep_1_ascat.output$ploidy,contamination=rep_1_ascat.output$aberrantcellfraction,
  60. stringsAsFactors = FALSE)
  61. ##load chromsome information
  62. load("f:/choppy_app/HRD_score/chrominfo.RData")
  63. ##modify names of chromosomes to match the chromosomes in the chrominfo object
  64. rep_1_x[rep_1_x[,2]=="X",2] <- 23
  65. rep_1_x[rep_1_x[,2]=="Y",2] <- 24
  66. rep_1_ntai <- calc.ai(rep_1_x, chrominfo,check.names = FALSE,return.loc = FALSE)
  67. rep_1_lst <- calc.lst(rep_1_x,chrominfo,check.names = FALSE,return.loc = FALSE)
  68. rep_1_hrd <- calc.hrd(rep_1_x,check.names = FALSE,return.loc = FALSE)
  69. HRD_score <- rep_1_ntai[1,1]+rep_1_lst+rep_1_hrd
  70. names(HRD_score) <- "HRD_score"
  71. write.table(HRD_score,file = paste0(args[[1]],"/",args[[6]],".txt"),col.names = FALSE,quote = FALSE)
  72. q(save="no")