annotate waveica_wrapper.R @ 6:071a424241ec draft

planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
author recetox
date Thu, 30 May 2024 14:54:02 +0000
parents e424fa636281
children 1a2aeb8137bf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
6480c6d5fa36 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 77bea6c84c5a932fa203723d4d5fea6147f06505
recetox
parents: 1
diff changeset
1 read_file <- function(file, metadata, ft_ext, mt_ext, transpose) {
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
2 data <- read_data(file, ft_ext)
1
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
3
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
4 if (transpose) {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
5 col_names <- c("sampleName", data[[1]])
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
6 t_data <- data[-1]
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
7 t_data <- t(t_data)
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
8 data <- data.frame(rownames(t_data), t_data)
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
9 colnames(data) <- col_names
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
10 }
2
6480c6d5fa36 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 77bea6c84c5a932fa203723d4d5fea6147f06505
recetox
parents: 1
diff changeset
11
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
12 if (!is.na(metadata)) {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
13 mt_data <- read_data(metadata, mt_ext)
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
14 data <- merge(mt_data, data, by = "sampleName")
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
15 }
1
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
16
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
17 return(data)
1
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
18 }
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
19
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
20 read_data <- function(file, ext) {
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
21 if (ext == "csv") {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
22 data <- read.csv(file, header = TRUE)
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
23 } else if (ext == "tsv") {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
24 data <- read.csv(file, header = TRUE, sep = "\t")
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
25 } else {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
26 data <- arrow::read_parquet(file)
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
27 }
1
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
28
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
29 return(data)
1
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
30 }
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
31
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
32 waveica <- function(file,
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
33 metadata = NA,
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
34 ext,
2
6480c6d5fa36 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 77bea6c84c5a932fa203723d4d5fea6147f06505
recetox
parents: 1
diff changeset
35 transpose = FALSE,
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
36 wavelet_filter,
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
37 wavelet_length,
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
38 k,
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
39 t,
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
40 t2,
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
41 alpha,
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
42 exclude_blanks) {
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
43 # get input from the Galaxy, preprocess data
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
44 ext <- strsplit(x = ext, split = "\\,")[[1]]
1
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
45
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
46 ft_ext <- ext[1]
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
47 mt_ext <- ext[2]
1
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
48
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
49 data <- read_file(file, metadata, ft_ext, mt_ext, transpose)
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
50
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
51 required_columns <- c(
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
52 "sampleName", "class", "sampleType",
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
53 "injectionOrder", "batch"
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
54 )
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
55 data <- verify_input_dataframe(data, required_columns)
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
56
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
57 data <- sort_by_injection_order(data)
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
58
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
59 # separate data into features, batch and group
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
60 feature_columns <- colnames(data)[!colnames(data) %in% required_columns]
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
61 features <- data[, feature_columns]
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
62 group <- enumerate_groups(as.character(data$sampleType))
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
63 batch <- data$batch
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
64
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
65 # run WaveICA
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
66 features <- recetox.waveica::waveica(
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
67 data = features,
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
68 wf = get_wf(wavelet_filter, wavelet_length),
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
69 batch = batch,
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
70 group = group,
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
71 K = k,
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
72 t = t,
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
73 t2 = t2,
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
74 alpha = alpha
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
75 )
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
76
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
77 data[, feature_columns] <- features
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
78
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
79 # remove blanks from dataset
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
80 if (exclude_blanks) {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
81 data <- exclude_group(data, group)
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
82 }
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
83
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
84 return(data)
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
85 }
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
86
1
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
87 waveica_singlebatch <- function(file,
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
88 metadata = NA,
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
89 ext,
2
6480c6d5fa36 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 77bea6c84c5a932fa203723d4d5fea6147f06505
recetox
parents: 1
diff changeset
90 transpose = FALSE,
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
91 wavelet_filter,
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
92 wavelet_length,
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
93 k,
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
94 alpha,
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
95 cutoff,
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
96 exclude_blanks) {
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
97 # get input from the Galaxy, preprocess data
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
98 ext <- strsplit(x = ext, split = "\\,")[[1]]
1
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
99
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
100 ft_ext <- ext[1]
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
101 mt_ext <- ext[2]
1
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
102
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
103 data <- read_file(file, metadata, ft_ext, mt_ext, transpose)
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
104
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
105 required_columns <- c("sampleName", "class", "sampleType", "injectionOrder")
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
106 optional_columns <- c("batch")
2
6480c6d5fa36 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 77bea6c84c5a932fa203723d4d5fea6147f06505
recetox
parents: 1
diff changeset
107
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
108 data <- verify_input_dataframe(data, required_columns)
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
109
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
110 data <- sort_by_injection_order(data)
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
111
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
112 feature_columns <- colnames(data)[!colnames(data) %in% c(required_columns, optional_columns)]
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
113 features <- data[, feature_columns]
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
114 injection_order <- data$injectionOrder
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
115
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
116 # run WaveICA
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
117 features <- recetox.waveica::waveica_nonbatchwise(
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
118 data = features,
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
119 wf = get_wf(wavelet_filter, wavelet_length),
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
120 injection_order = injection_order,
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
121 K = k,
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
122 alpha = alpha,
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
123 cutoff = cutoff
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
124 )
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
125
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
126 data[, feature_columns] <- features
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
127 group <- enumerate_groups(as.character(data$sampleType))
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
128 # remove blanks from dataset
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
129 if (exclude_blanks) {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
130 data <- exclude_group(data, group)
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
131 }
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
132
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
133 return(data)
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
134 }
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
135
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
136
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
137 sort_by_injection_order <- function(data) {
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
138 if ("batch" %in% colnames(data)) {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
139 data <- data[order(data[, "batch"], data[, "injectionOrder"], decreasing = FALSE), ]
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
140 } else {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
141 data <- data[order(data[, "injectionOrder"], decreasing = FALSE), ]
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
142 }
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
143 return(data)
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
144 }
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
145
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
146
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
147 verify_input_dataframe <- function(data, required_columns) {
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
148 if (anyNA(data)) {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
149 stop("Error: dataframe cannot contain NULL values!
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
150 Make sure that your dataframe does not contain empty cells")
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
151 } else if (!all(required_columns %in% colnames(data))) {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
152 stop(
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
153 "Error: missing metadata!
2
6480c6d5fa36 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 77bea6c84c5a932fa203723d4d5fea6147f06505
recetox
parents: 1
diff changeset
154 Make sure that the following columns are present in your dataframe: ",
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
155 paste(required_columns, collapse = ", ")
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
156 )
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
157 }
2
6480c6d5fa36 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 77bea6c84c5a932fa203723d4d5fea6147f06505
recetox
parents: 1
diff changeset
158
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
159 data <- verify_column_types(data, required_columns)
2
6480c6d5fa36 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 77bea6c84c5a932fa203723d4d5fea6147f06505
recetox
parents: 1
diff changeset
160
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
161 return(data)
2
6480c6d5fa36 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 77bea6c84c5a932fa203723d4d5fea6147f06505
recetox
parents: 1
diff changeset
162 }
6480c6d5fa36 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 77bea6c84c5a932fa203723d4d5fea6147f06505
recetox
parents: 1
diff changeset
163
6480c6d5fa36 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 77bea6c84c5a932fa203723d4d5fea6147f06505
recetox
parents: 1
diff changeset
164 verify_column_types <- function(data, required_columns) {
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
165 # Specify the column names and their expected types
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
166 column_types <- list(
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
167 "sampleName" = c("character", "factor"),
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
168 "class" = c("character", "factor", "integer"),
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
169 "sampleType" = c("character", "factor"),
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
170 "injectionOrder" = "integer",
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
171 "batch" = "integer"
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
172 )
2
6480c6d5fa36 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 77bea6c84c5a932fa203723d4d5fea6147f06505
recetox
parents: 1
diff changeset
173
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
174 column_types <- column_types[required_columns]
2
6480c6d5fa36 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 77bea6c84c5a932fa203723d4d5fea6147f06505
recetox
parents: 1
diff changeset
175
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
176 for (col_name in names(data)) {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
177 actual_type <- class(data[[col_name]])
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
178 if (col_name %in% names(column_types)) {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
179 expected_types <- column_types[[col_name]]
2
6480c6d5fa36 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 77bea6c84c5a932fa203723d4d5fea6147f06505
recetox
parents: 1
diff changeset
180
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
181 if (!actual_type %in% expected_types) {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
182 stop(
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
183 "Column ", col_name, " is of type ", actual_type,
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
184 " but expected type is ",
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
185 paste(expected_types, collapse = " or "), "\n"
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
186 )
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
187 }
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
188 } else {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
189 if (actual_type != "numeric") {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
190 data[[col_name]] <- as.numeric(as.character(data[[col_name]]))
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
191 }
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
192 }
2
6480c6d5fa36 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 77bea6c84c5a932fa203723d4d5fea6147f06505
recetox
parents: 1
diff changeset
193 }
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
194 return(data)
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
195 }
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
196
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
197
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
198 # Match group labels with [blank/sample/qc] and enumerate them
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
199 enumerate_groups <- function(group) {
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
200 group[grepl("blank", tolower(group))] <- 0
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
201 group[grepl("sample", tolower(group))] <- 1
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
202 group[grepl("qc", tolower(group))] <- 2
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
203
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
204 return(group)
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
205 }
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
206
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
207
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
208 # Create appropriate input for R wavelets function
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
209 get_wf <- function(wavelet_filter, wavelet_length) {
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
210 wf <- paste(wavelet_filter, wavelet_length, sep = "")
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
211
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
212 # exception to the wavelet function
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
213 if (wf == "d2") {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
214 wf <- "haar"
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
215 }
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
216
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
217 return(wf)
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
218 }
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
219
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
220
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
221 # Exclude blanks from a dataframe
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
222 exclude_group <- function(data, group) {
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
223 row_idx_to_exclude <- which(group %in% 0)
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
224 if (length(row_idx_to_exclude) > 0) {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
225 data_without_blanks <- data[-c(row_idx_to_exclude), ]
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
226 cat("Blank samples have been excluded from the dataframe.\n")
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
227 return(data_without_blanks)
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
228 } else {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
229 return(data)
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
230 }
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
231 }
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
232
1
b77023c41c76 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit d82e7dad96bebe9424ac7bf490e2786d82c3681a
recetox
parents: 0
diff changeset
233 store_data <- function(data, output, ext) {
6
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
234 if (ext == "parquet") {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
235 arrow::write_parquet(data, output)
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
236 } else {
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
237 write.table(data,
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
238 file = output, sep = "\t",
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
239 row.names = FALSE, quote = FALSE
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
240 )
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
241 }
071a424241ec planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit bc3445f7c41271b0062c7674108f57708d08dd28
recetox
parents: 5
diff changeset
242 cat("Normalization has been completed.\n")
0
328710890963 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit 98e541a75678eee749261630610b946c258fd5f3"
recetox
parents:
diff changeset
243 }