Mercurial > repos > artbio > snvtocnv
comparison segmentation_sequenza.R @ 0:b77d7a0a45e8 draft
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/snvtocnv commit 10ad3a0ca7cd23ad1e0940844147e1d1b3d069f0"
author | artbio |
---|---|
date | Sun, 07 Mar 2021 23:19:59 +0000 |
parents | |
children | d2833cfb3f08 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:b77d7a0a45e8 |
---|---|
1 options(show.error.messages = F, error = function() { | |
2 cat(geterrmessage(), file = stderr()); q("no", 1, F) }) | |
3 | |
4 # load packages that are provided in the conda env | |
5 library(optparse) | |
6 library(sequenza) | |
7 library(BiocParallel) | |
8 library(tidyverse) | |
9 library(readr) | |
10 | |
11 option_list <- list( | |
12 make_option( | |
13 c("-i", "--input"), | |
14 default = NA, | |
15 type = "character", | |
16 help = "Path to Sequenza seqz processed segments file" | |
17 ), | |
18 make_option( | |
19 c("-O", "--output_dir"), | |
20 default = NA, | |
21 type = "character", | |
22 help = "Output directory" | |
23 ), | |
24 make_option( | |
25 c("-s", "--sample_name"), | |
26 default = NA, | |
27 type = "character", | |
28 help = "Sample name" | |
29 ) | |
30 ) | |
31 | |
32 opt <- parse_args(OptionParser(option_list = option_list), | |
33 args = commandArgs(trailingOnly = TRUE)) | |
34 | |
35 data_file <- opt$input | |
36 output_dir <- opt$output_dir | |
37 sample_name <- opt$sample_name | |
38 | |
39 | |
40 ## Processing seqz files : normalisation and segmentation for chromosomes 1 to 22 | |
41 message(sprintf("\nExtraction step for %s", data_file)) | |
42 | |
43 chrom_list <- c("chr1", "chr2", "chr3", "chr4", "chr5", "chr6", "chr7", "chr8", "chr9", | |
44 "chr10", "chr11", "chr12", "chr13", "chr14", "chr15", "chr16", "chr17", | |
45 "chr18", "chr19", "chr20", "chr21", "chr22") | |
46 | |
47 Sys.setenv(TZDIR = "/usr/share/zoneinfo/") | |
48 Sys.setenv(TZ = "US/Eastern") | |
49 options(tz = "US/Eastern") | |
50 Sys.timezone(location = TRUE) | |
51 | |
52 | |
53 segfile <- sequenza.extract(data_file, | |
54 verbose = FALSE, | |
55 chromosome.list = chrom_list) | |
56 | |
57 ## Estimation of cellularity and ploidy | |
58 | |
59 segfile_cp <- sequenza.fit(segfile) | |
60 message(sprintf("\nEstimation step for %s\n", data_file)) | |
61 | |
62 ## writing files and plots using default parameters | |
63 message(sprintf("\nWriting files and plots for %s\n", data_file)) | |
64 | |
65 sequenza.results(sequenza.extract = segfile, | |
66 cp.table = segfile_cp, | |
67 sample.id = sample_name, | |
68 out.dir = output_dir) | |
69 message(sprintf("\nOutput written to %s\n", output_dir)) |