comparison sleuth.R @ 1:d3e447dd52c8 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/sleuth commit 6fbf73689708cfbdf3d9d783af4988bad7137f93
author iuc
date Wed, 07 Jun 2023 11:47:30 +0000
parents 5f1cb4c28d73
children d6b5fc94062c
comparison
equal deleted inserted replaced
0:5f1cb4c28d73 1:d3e447dd52c8
24 24
25 25
26 # Collect arguments from command line 26 # Collect arguments from command line
27 parser <- ArgumentParser(description = "Sleuth R script") 27 parser <- ArgumentParser(description = "Sleuth R script")
28 28
29 parser$add_argument("--factorLevel", action = "append", required = TRUE) 29 parser$add_argument("--factorLevel", action = "append", required = FALSE)
30 parser$add_argument("--factorLevel_counts", 30 parser$add_argument("--factorLevel_counts",
31 action = "append", 31 action = "append",
32 required = TRUE) 32 required = FALSE)
33 parser$add_argument("--factorLevel_n", action = "append", required = TRUE) 33 parser$add_argument("--factorLevel_n", action = "append", required = FALSE)
34 parser$add_argument("--cores", type = "integer", required = TRUE) 34 parser$add_argument("--cores", type = "integer", required = FALSE)
35 parser$add_argument("--normalize", action = "store_true", required = FALSE) 35 parser$add_argument("--normalize", action = "store_true", required = FALSE)
36 parser$add_argument("--nbins", type = "integer", required = TRUE) 36 parser$add_argument("--nbins", type = "integer", required = FALSE)
37 parser$add_argument("--lwr", type = "numeric", required = TRUE) 37 parser$add_argument("--lwr", type = "numeric", required = FALSE)
38 parser$add_argument("--upr", type = "numeric", required = TRUE) 38 parser$add_argument("--upr", type = "numeric", required = FALSE)
39 parser$add_argument("--metadata_file",
40 action = "append",
41 required = FALSE)
42 parser$add_argument("--experiment_design", required = FALSE)
39 43
40 args <- parser$parse_args() 44 args <- parser$parse_args()
41 45
42 all_files <- args$factorLevel_counts 46 if (args$experiment_design == "complex") {
47 ## Complex experiment design
48 ############################
43 49
44 conditions <- c() 50 s2c <-
45 for (x in seq_along(args$factorLevel)) { 51 read.table(file = args$metadata_file,
46 temp <- append(conditions, rep(args$factorLevel[[x]])) 52 header = TRUE,
47 conditions <- temp 53 sep = "\t")
54 paths <- c()
55 for (x in s2c$data_filename) {
56 paths <- c(paths, paste("./kallisto_outputs/", x, sep = ""))
57 }
58 for (f in paths) {
59 file.rename(f, gsub(".fastq.*", "", f))
60 file.rename(f, paste(gsub(".fastq.*", "", f), ".h5", sep = ""))
61 }
62 s2c$path <- paste(gsub(".fastq.*", ".h5", paths), ".h5", sep = "")
63
64 so <- sleuth_prep(s2c, full_model = ~ condition, num_cores = 1)
65 so <- sleuth_fit(so)
66
67 } else {
68 ## Simple experiment design
69 ###########################
70
71 conditions <- c()
72 for (x in seq_along(args$factorLevel)) {
73 temp <- append(conditions, rep(args$factorLevel[[x]]))
74 conditions <- temp
75 }
76
77 sample_names <-
78 gsub(".fastq.+", "", basename(args$factorLevel_counts))
79
80 design <-
81 data.frame(list(
82 sample = sample_names,
83 condition = conditions,
84 path = args$factorLevel_counts
85 ))
86 so <- sleuth_prep(design,
87 cores = args$cores,
88 normalize = args$normalize)
48 } 89 }
49
50 sample_names <- all_files %>%
51 str_replace(pattern = "\\.tab", "")
52
53 design <-
54 data.frame(list(
55 sample = sample_names,
56 condition = conditions,
57 path = all_files
58 ))
59 so <- sleuth_prep(design,
60 cores = args$cores,
61 normalize = args$normalize)
62 90
63 so <- sleuth_fit( 91 so <- sleuth_fit(
64 so, 92 so,
65 ~ condition, 93 ~ condition,
66 "full", 94 "full",