comparison scripts/trajectoryinspect.R @ 9:a6821f856a1e draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/raceid3 commit 82a18e57158136e265a26f27feb40f8dc13437bf
author iuc
date Wed, 24 Aug 2022 18:10:56 +0000
parents c8434a623268
children 6e90c8adf84f
comparison
equal deleted inserted replaced
8:df8e4e54d367 9:a6821f856a1e
1 #!/usr/bin/env R 1 #!/usr/bin/env R
2 VERSION <- "0.2" # nolint 2 VERSION <- "0.2" # nolint
3 3
4 args <- commandArgs(trailingOnly = T) 4 args <- commandArgs(trailingOnly = TRUE)
5 5
6 if (length(args) != 1) { 6 if (length(args) != 1) {
7 message(paste("VERSION:", VERSION)) 7 message(paste("VERSION:", VERSION))
8 stop("Please provide the config file") 8 stop("Please provide the config file")
9 } 9 }
17 test$line <- 2.5 17 test$line <- 2.5
18 second <- test 18 second <- test
19 second$cex <- 0.5 19 second$cex <- 0.5
20 second$line <- 2.5 20 second$line <- 2.5
21 21
22 do.trajectoryinspection.stemID <- function(ltr) { # nolint 22 do.trajectoryinspection.stemid <- function(ltr) { # nolint
23 makeBranchLink <- function(i, j, k) { # nolint 23 makeBranchLink <- function(i, j, k) { # nolint
24 ingoing <- paste(sort(c(i, j)), collapse = ".") 24 ingoing <- paste(sort(c(i, j)), collapse = ".")
25 outgoing <- paste(sort(c(j, k)), collapse = ".") 25 outgoing <- paste(sort(c(j, k)), collapse = ".")
26 messed <- sort(c(ingoing, outgoing)) 26 messed <- sort(c(ingoing, outgoing))
27 return(list(messed[[1]], messed[[2]])) 27 return(list(messed[[1]], messed[[2]]))
49 print(do.call(mtext, c("Initial Clusters (F-R)", test))) 49 print(do.call(mtext, c("Initial Clusters (F-R)", test)))
50 print(do.call(plotmap, c(bra$scl, final = TRUE, fr = TRUE))) 50 print(do.call(plotmap, c(bra$scl, final = TRUE, fr = TRUE)))
51 print(do.call(mtext, c("Final Clusters (F-R)", test))) 51 print(do.call(mtext, c("Final Clusters (F-R)", test)))
52 } 52 }
53 53
54 do.trajectoryinspection.fateID <- function(ltr) { # nolint 54 do.trajectoryinspection.fateid <- function(ltr) { # nolint
55 n <- do.call(cellsfromtree, c(ltr, trjfid.cellsfrom)) 55 n <- do.call(cellsfromtree, c(ltr, trjfid_cellsfrom))
56 x <- getfdata(ltr@sc) 56 x <- getfdata(ltr@sc)
57 57
58 trjfid.filterset$x <- x 58 trjfid_filterset$x <- x
59 trjfid.filterset$n <- n$f 59 trjfid_filterset$n <- n$f
60 fs <- do.call(filterset, c(trjfid.filterset)) 60 fs <- do.call(filterset, c(trjfid_filterset))
61 trjfid.getsom$x <- fs 61 trjfid_getsom$x <- fs
62 s1d <- do.call(getsom, c(trjfid.getsom)) 62 s1d <- do.call(getsom, c(trjfid_getsom))
63 trjfid.procsom$s1d <- s1d 63 trjfid_procsom$s1d <- s1d
64 ps <- do.call(procsom, c(trjfid.procsom)) 64 ps <- do.call(procsom, c(trjfid_procsom))
65 65
66 y <- ltr@sc@cpart[n$f] 66 y <- ltr@sc@cpart[n$f]
67 fcol <- ltr@sc@fcol 67 fcol <- ltr@sc@fcol
68 68
69 trjfid.plotheat$xpart <- y 69 trjfid_plotheat$xpart <- y
70 trjfid.plotheat$xcol <- fcol 70 trjfid_plotheat$xcol <- fcol
71 71
72 test$side <- 3 72 test$side <- 3
73 test$line <- 3 73 test$line <- 3
74 74
75 ##Plot average z-score for all modules derived from the SOM: 75 ##Plot average z-score for all modules derived from the SOM:
76 trjfid.plotheat$x <- ps$nodes.z 76 trjfid_plotheat$x <- ps$nodes.z
77 trjfid.plotheat$ypart <- unique(ps$nodes) 77 trjfid_plotheat$ypart <- unique(ps$nodes)
78 print(do.call(plotheatmap, c(trjfid.plotheat))) 78 print(do.call(plotheatmap, c(trjfid_plotheat)))
79 print(do.call(mtext, c("Average z-score for all modules derived from SOM", 79 print(do.call(mtext, c("Average z-score for all modules derived from SOM",
80 test))) 80 test)))
81 ##Plot z-score profile of each gene ordered by SOM modules: 81 ##Plot z-score profile of each gene ordered by SOM modules:
82 trjfid.plotheat$x <- ps$all.z 82 trjfid_plotheat$x <- ps$all.z
83 trjfid.plotheat$ypart <- ps$nodes 83 trjfid_plotheat$ypart <- ps$nodes
84 print(do.call(plotheatmap, c(trjfid.plotheat))) 84 print(do.call(plotheatmap, c(trjfid_plotheat)))
85 print(do.call(mtext, c(paste0("z-score profile of each gene", 85 print(do.call(mtext, c(paste0("z-score profile of each gene",
86 "ordered by SOM modules"), test))) 86 "ordered by SOM modules"), test)))
87 ##Plot normalized expression profile of each gene ordered by SOM modules: 87 ##Plot normalized expression profile of each gene ordered by SOM modules:
88 trjfid.plotheat$x <- ps$all.e 88 trjfid_plotheat$x <- ps$all.e
89 trjfid.plotheat$ypart <- ps$nodes 89 trjfid_plotheat$ypart <- ps$nodes
90 print(do.call(plotheatmap, c(trjfid.plotheat))) 90 print(do.call(plotheatmap, c(trjfid_plotheat)))
91 print(do.call(mtext, c(paste0("Normalized expression profile of each", 91 print(do.call(mtext, c(paste0("Normalized expression profile of each",
92 "gene ordered by SOM modules"), test))) 92 "gene ordered by SOM modules"), test)))
93 ##Plot binarized expression profile of each gene 93 ##Plot binarized expression profile of each gene
94 ##(z-score < -1, -1 < z-score < 1, z-score > 1) 94 ##(z-score < -1, -1 < z-score < 1, z-score > 1)
95 trjfid.plotheat$x <- ps$all.b 95 trjfid_plotheat$x <- ps$all.b
96 trjfid.plotheat$ypart <- ps$nodes 96 trjfid_plotheat$ypart <- ps$nodes
97 print(do.call(plotheatmap, c(trjfid.plotheat))) 97 print(do.call(plotheatmap, c(trjfid_plotheat)))
98 print(do.call(mtext, c("Binarized expression profile of each gene", test))) 98 print(do.call(mtext, c("Binarized expression profile of each gene", test)))
99 ## This should be written out, and passed back into the tool 99 ## This should be written out, and passed back into the tool
100 ## to perform sominspect 100 ## to perform sominspect
101 return(list(fs = fs, ps = ps, y = y, fcol = fcol, nf = n$f)) 101 return(list(fs = fs, ps = ps, y = y, fcol = fcol, nf = n$f))
102 } 102 }
103 103
104 do.trajectoryinspection.fateID.sominspect <- function(domo) { # nolint 104 do.trajectoryinspection.fateid.sominspect <- function(domo) { # nolint
105 g <- trjfidsomi.use.genes 105 g <- trjfidsomi.use.genes
106 if (class(g) == "numeric") { 106 if (class(g) == "numeric") {
107 g <- names(ps$nodes)[ps$nodes %in% g] 107 g <- names(ps$nodes)[ps$nodes %in% g]
108 } 108 }
109 109
133 } 133 }
134 134
135 ltr <- in.rdat 135 ltr <- in.rdat
136 136
137 pdf(out.pdf) 137 pdf(out.pdf)
138 if (perform.stemID) do.trajectoryinspection.stemID(ltr) 138 if (perform.stemid) do.trajectoryinspection.stemid(ltr)
139 if (perform.fateID) { 139 if (perform.fateid) {
140 domo <- do.trajectoryinspection.fateID(ltr) 140 domo <- do.trajectoryinspection.fateid(ltr)
141 if (perform.fateID.sominspect) { 141 if (perform.fateid.sominspect) {
142 do.trajectoryinspection.fateID.sominspect(domo) 142 do.trajectoryinspection.fateid.sominspect(domo)
143 } 143 }
144 } 144 }
145 dev.off() 145 dev.off()