annotate lineagespot_verbose.R @ 1:99494998688a draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
author iuc
date Sun, 25 Feb 2024 09:49:20 +0000
parents 6ddf5a9ce4a5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
1 ## How to execute this tool
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
2
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
3 # A command-line interface to lineagespot for use with Galaxy
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
4 #
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
5 # The following arguments are required:
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
6 #
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
7 # 'in_vcf' a character vector of paths to VCF files object from Galaxy lineagespot/test-data
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
8 # 'in_gff3' a character vector of path to GFF3 file containing SARS-CoV-2 gene coordinates object from Galaxy lineagespot/test-data
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
9 # 'in_ref' a character vector of path to a folder containing lineage reports object from Galaxy lineagespot/test-data
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
10 # 'in_voc' a character vector containing the names of the lineages of interest
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
11 # 'in_threshold' a parameter indicating the AF threshold for identifying variants per sample
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
12 #
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
13 # Rscript ${__tool_directory__}/lineagespot_verbose.R --in_vcf ${__tool_directory__}/test-data/extdata/vcf-files --in_gff3 ${__tool_directory__}/test-data/extdata/NC_045512.2_annot.gff3 --in_ref ${__tool_directory__}/test-data/extdata/ref --in_voc "B.1.617.2, B.1.1.7, B.1.351, P.1" --in_threshold 0.8
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
14 # Set up R error handling to go to stderr
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
15 options(show.error.messages = FALSE, error = function() {
1
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
16 cat(geterrmessage(), file = stderr())
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
17 q("no", 1, FALSE)
0
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
18 })
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
19
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
20 # Import required libraries
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
21
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
22 library_path <- .libPaths()
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
23
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
24 suppressPackageStartupMessages({
1
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
25 library("getopt", lib.loc = library_path)
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
26 library("data.table", lib.loc = library_path)
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
27 library("lineagespot", lib.loc = library_path)
0
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
28 })
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
29
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
30
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
31 options(stringAsfactors = FALSE, useFancyQuotes = FALSE)
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
32
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
33 # Take in trailing command line arguments
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
34 args <- commandArgs(trailingOnly = TRUE)
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
35
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
36 # Get options using the spec as defined by the enclosed list
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
37 # Read the options from the default: commandArgs(TRUE)
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
38 option_specification <- matrix(c(
1
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
39 "in_vcf", "vcf", 1, "character",
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
40 "in_gff3", "gff3", 1, "character",
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
41 "in_ref", "ref", 1, "character",
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
42 "in_voc", "voc", 2, "character",
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
43 "in_threshold", "thr", 2, "double"
0
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
44 ), byrow = TRUE, ncol = 4)
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
45
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
46 options <- getopt(option_specification)
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
47
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
48 if (!is.null(options$in_voc) && is.character(options$in_voc)) {
1
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
49 options$in_voc <- unlist(strsplit(options$in_voc, split = ","))
0
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
50 }
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
51
1
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
52 result <- lineagespot(
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
53 vcf_folder = options$in_vcf,
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
54 ref_folder = options$in_ref,
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
55 gff3_path = options$in_gff3,
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
56 voc = options$in_voc,
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
57 AF_threshold = options$in_threshold
99494998688a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 6a6a37f2574954dae65f9ec407fe38594ed37659
iuc
parents: 0
diff changeset
58 )
0
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
59
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
60
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
61 # Write output to new file which will be recognized by Galaxy
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
62 fwrite(result$variants.table, sep = "\t", file = "variants_table.txt", row.names = FALSE)
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
63 fwrite(result$lineage.hits, sep = "\t", file = "lineage_hits.txt", row.names = FALSE)
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
64 fwrite(result$lineage.report, sep = "\t", file = "lineage_report.txt", row.names = FALSE)
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
65
6ddf5a9ce4a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/lineagespot commit 0bc6ed15054577af1089d55ef9aa1071d122eb6b
iuc
parents:
diff changeset
66 cat("\n Process has been completed !\n")