ExprAnalysis.snake 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. TRINITY_HOME = config["TRINITY_HOME"]
  2. SAMPLES_FILE = config["SAMPLES_FILE"]
  3. ExprAnalysis_Dir = config["ExprAnalysis_Dir"]
  4. pc_num = config["pc_num"]
  5. de_method = config["de_method"]
  6. localrules: enrich
  7. rule expr_stat:
  8. input:
  9. config["Quantification_Dir"] + "/my.gene.TMM.EXPR.matrix"
  10. output:
  11. config["Quantification_Dir"] + "/my.gene.TMM.EXPR.matrix.boxplot.pdf",
  12. config["Quantification_Dir"] + "/my.gene.TMM.EXPR.matrix.density.pdf",
  13. config["Quantification_Dir"] + "/my.gene.TMM.EXPR.matrix.stat.txt"
  14. shell:
  15. "Rscript script/expressionStats.R -d {input} -o {input}"
  16. rule sample_cor:
  17. input:
  18. config["Quantification_Dir"] + "/my.gene.TMM.EXPR.matrix"
  19. output:
  20. ExprAnalysis_Dir + "/sample_cor/my.minRow10.sample_cor.dat",
  21. ExprAnalysis_Dir + "/sample_cor/my.minRow10.sample_cor_matrix.pdf"
  22. shell:
  23. "mkdir -p {ExprAnalysis_Dir}/sample_cor;"
  24. "{TRINITY_HOME}/Analysis/DifferentialExpression/PtR"
  25. " --matrix {input}"
  26. " --samples {SAMPLES_FILE}"
  27. " --min_rowSums 10"
  28. " --sample_cor_matrix"
  29. " --output {ExprAnalysis_Dir}/sample_cor/my"
  30. rule pca:
  31. input:
  32. config["Quantification_Dir"] + "/my.gene.TMM.EXPR.matrix"
  33. output:
  34. ExprAnalysis_Dir + "/pca/my.minRow10.PCA.prcomp.scores",
  35. ExprAnalysis_Dir + "/pca/my.minRow10.prcomp.principal_components.pdf"
  36. shell:
  37. "mkdir -p {ExprAnalysis_Dir}/pca;"
  38. "{TRINITY_HOME}/Analysis/DifferentialExpression/PtR"
  39. " --matrix {input}"
  40. " --samples {SAMPLES_FILE}"
  41. " --min_rowSums 10"
  42. " --prin_comp {pc_num}"
  43. " --add_prin_comp_heatmaps 10"
  44. " --output {ExprAnalysis_Dir}/pca/my"
  45. contrasts = config["contrasts"]
  46. f = open(contrasts, 'r')
  47. CONTRASTS = [i.strip().replace('\t', '_vs_') for i in f.readlines()]
  48. rule deg:
  49. input:
  50. config["Quantification_Dir"] + "/my.gene.counts.matrix"
  51. output:
  52. expand(ExprAnalysis_Dir + "/deg/my.gene.counts.matrix.{vs}.DESeq2.DE_results", vs = CONTRASTS)
  53. shell:
  54. "perl {TRINITY_HOME}/Analysis/DifferentialExpression/run_DE_analysis.pl"
  55. " --matrix {input} --method {de_method}"
  56. " --samples_file {SAMPLES_FILE}"
  57. " --contrasts {contrasts}"
  58. " --output {ExprAnalysis_Dir}/deg"
  59. de_log2FoldChange = config["de_log2FoldChange"]
  60. de_padj = config["de_padj"]
  61. ExprAnalysis_Dir = config["ExprAnalysis_Dir"]
  62. rule enrich:
  63. input:
  64. config["Annotation_Dir"] + "/anno_stat.txt",
  65. des = expand(ExprAnalysis_Dir + "/deg/my.gene.counts.matrix.{vs}.DESeq2.DE_results", vs = CONTRASTS)
  66. output:
  67. expand(ExprAnalysis_Dir + "/deg/my.gene.counts.matrix.{vs}.DESeq2.DE_results.ekp_results.txt", vs = CONTRASTS),
  68. expand(ExprAnalysis_Dir + "/deg/my.gene.counts.matrix.{vs}.DESeq2.DE_results.ego_results.txt", vs = CONTRASTS)
  69. run:
  70. for i in input.des:
  71. shell("cd " + config["Annotation_Dir"] + "; Rscript ../tools/emcp/enrich.R -d ../{i} --de_log2FoldChange {de_log2FoldChange} --de_padj {de_padj}; cd ..")