Mercurial > repos > artbio > cnv_facets
annotate facets_analysis.R @ 2:66a56502199d draft
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
| author | artbio |
|---|---|
| date | Fri, 03 Oct 2025 23:59:36 +0000 |
| parents | |
| children | d1914f4d9daf |
| rev | line source |
|---|---|
|
2
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
1 #!/usr/bin/env Rscript |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
2 |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
3 # Description: |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
4 # This script serves as the backend for the Galaxy FACETS Analysis tool. |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
5 # It takes a SNP pileup file as input and performs allele-specific copy |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
6 # number analysis using the R package 'facets'. |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
7 # ============================================================================== |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
8 |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
9 # --- 1. Load Libraries --- |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
10 suppressPackageStartupMessages(library(argparse)) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
11 suppressPackageStartupMessages(library(facets)) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
12 |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
13 # --- 2. Define and Parse Arguments --- |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
14 |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
15 # Create the parser |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
16 parser <- ArgumentParser(description = "Run FACETS algorithm on a SNP pileup file.") |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
17 |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
18 # Define arguments |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
19 parser$add_argument("--pileup", |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
20 type = "character", required = TRUE, |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
21 help = "Path to the gzipped pileup CSV file." |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
22 ) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
23 parser$add_argument("--sample_id", |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
24 type = "character", required = TRUE, |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
25 help = "Sample ID used for plot titles and metadata." |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
26 ) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
27 |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
28 parser$add_argument("--output_seg", |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
29 type = "character", required = TRUE, |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
30 help = "Path for the output segmentation file (TSV)." |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
31 ) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
32 parser$add_argument("--output_summary", |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
33 type = "character", required = TRUE, |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
34 help = "Path for the output summary file (TSV)." |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
35 ) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
36 parser$add_argument("--output_plots", |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
37 type = "character", required = TRUE, |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
38 help = "Path for the output plots file (PDF)." |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
39 ) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
40 |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
41 parser$add_argument("--cval", |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
42 type = "double", default = 150, |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
43 help = "Critical value for segmentation." |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
44 ) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
45 parser$add_argument("--min_nhet", |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
46 type = "integer", default = 25, |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
47 help = "Minimum number of heterozygous SNPs per segment." |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
48 ) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
49 parser$add_argument("--snp_nbhd", |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
50 type = "integer", default = 300, |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
51 help = "SNP neighborhood size for pre-processing. Crucial for sparse VCFs." |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
52 ) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
53 parser$add_argument("--gbuild", |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
54 type = "character", default = "hg38", |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
55 choices = c("hg19", "hg38", "hg18", "mm9", "mm10"), |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
56 help = "Genome build used for alignment." |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
57 ) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
58 |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
59 # --- 3. Main Analysis Function --- |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
60 main <- function(args) { |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
61 # Set seed for reproducibility |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
62 set.seed(1965) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
63 |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
64 # --- Read the data with readSnpMatrix() from facets --- |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
65 rcmat <- readSnpMatrix(args$pileup) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
66 |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
67 # --- Pre-process sample --- |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
68 xx <- preProcSample(rcmat, gbuild = args$gbuild, snp.nbhd = args$snp_nbhd) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
69 |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
70 # --- Process sample (segmentation) --- |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
71 oo <- procSample(xx, cval = args$cval, min.nhet = args$min_nhet) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
72 |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
73 # --- Estimate ploidy/purity --- |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
74 fit <- emcncf(oo) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
75 |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
76 # Write the main segmentation file |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
77 cncf_output <- fit$cncf |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
78 if (nrow(cncf_output) > 0) { |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
79 cncf_output$purity <- fit$purity |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
80 cncf_output$ploidy <- fit$ploidy |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
81 # Reorder columns to have purity/ploidy first for clarity |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
82 cncf_output <- cncf_output[, c("purity", "ploidy", setdiff(names(cncf_output), c("purity", "ploidy")))] |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
83 } |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
84 write.table(cncf_output, file = args$output_seg, sep = "\t", quote = FALSE, row.names = FALSE) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
85 |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
86 # Write a key-value summary file |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
87 # A NULL value is replaced by NA to preserve vector length. |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
88 summary_df <- data.frame( |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
89 Parameter = c( |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
90 "sample_id", "purity", "ploidy", "dipLogR", "loglik", |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
91 "cval_param", "min_nhet_param", "snp_nbhd_param", "gbuild_param" |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
92 ), |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
93 Value = c( |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
94 args$sample_id, |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
95 ifelse(is.null(fit$purity), NA, fit$purity), |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
96 ifelse(is.null(fit$ploidy), NA, fit$ploidy), |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
97 ifelse(is.null(fit$dipLogR), NA, fit$dipLogR), |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
98 ifelse(is.null(fit$loglik), NA, fit$loglik), |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
99 args$cval, |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
100 args$min_nhet, |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
101 args$snp_nbhd, |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
102 args$gbuild |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
103 ) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
104 ) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
105 write.table(summary_df, file = args$output_summary, sep = "\t", quote = FALSE, row.names = FALSE) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
106 |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
107 # Generate the plots PDF |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
108 pdf(file = args$output_plots, width = 12, height = 8) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
109 plotSample(x = oo, emfit = fit, sname = args$sample_id) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
110 dev.off() |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
111 } |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
112 |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
113 # --- 4. Execution Block --- |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
114 if (!interactive()) { |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
115 args <- parser$parse_args() |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
116 main(args) |
|
66a56502199d
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/facets commit 0176d2cc4f1caf0ab948ef72efb25ccce735461e
artbio
parents:
diff
changeset
|
117 } |
