diff mutational_patterns.R @ 11:7995a949189f draft

"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 94919d0f442fe7059afa2e07898c149b126a5460"
author artbio
date Thu, 22 Oct 2020 00:18:38 +0000
parents 59c0e2a7965c
children 7954f0d3517f
line wrap: on
line diff
--- a/mutational_patterns.R	Mon Oct 19 23:34:58 2020 +0000
+++ b/mutational_patterns.R	Thu Oct 22 00:18:38 2020 +0000
@@ -85,6 +85,12 @@
     help = "path to output dataset"
   ),
   make_option(
+    "--sig_contrib_matrix",
+    default = NA,
+    type = 'character',
+    help = "path to signature contribution matrix"
+  ),
+  make_option(
     c("-r", "--rdata"),
     type="character",
     default=NULL,
@@ -343,6 +349,14 @@
         grid.arrange(p8)
     }
     
+    # export relative contribution matrix
+    if (!is.na(opt$sig_contrib_matrix)) {
+        output_table <- t(fit_res$contribution)/rowSums(t(fit_res$contribution))
+        colnames(output_table) <- paste0("s", colnames(output_table))
+        output_table <- data.frame(sample=rownames(output_table), output_table)
+        write.table(output_table, file = opt$sig_contrib_matrix, sep = "\t", quote = F, row.names = F)
+    }
+
     # calculate all pairwise cosine similarities
     cos_sim_ori_rec <- cos_sim_matrix(pseudo_mut_mat, fit_res$reconstructed)
     # extract cosine similarities per sample between original and reconstructed