annotate segmentation_sequenza.R @ 1:d2833cfb3f08 draft

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