-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.R
executable file
·51 lines (40 loc) · 1.22 KB
/
run.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env Rscript
requireNamespace("dyncli", quietly = TRUE)
task <- dyncli::main()
requireNamespace("dyndimred", quietly = TRUE)
library(purrr, warn.conflicts = FALSE)
library(dynwrap, warn.conflicts = FALSE)
#####################################
### LOAD DATA ###
#####################################
parameters <- task$parameters
expression <- task$expression
# TIMING: done with preproc
timings <- list(method_afterpreproc = Sys.time())
#####################################
### INFER TRAJECTORY ###
#####################################
# perform PCA dimred
dimred <- dyndimred::dimred(expression, method = parameters$dimred, ndim = 2)
# transform to pseudotime using atan2
pseudotime <- atan2(dimred[,2], dimred[,1]) / 2 / pi + .5
# TIMING: done with method
timings$method_aftermethod <- Sys.time()
#####################################
### SAVE OUTPUT TRAJECTORY ###
#####################################
output <-
wrap_data(
cell_ids = rownames(expression)
) %>%
add_cyclic_trajectory(
pseudotime = pseudotime,
do_scale_minmax = FALSE
) %>%
add_dimred(
dimred = dimred
) %>%
add_timings(
timings = timings
)
dyncli::write_output(output, task$output)