Skip to content

Commit

Permalink
add R wrapper dynverse/dynmethods#152
Browse files Browse the repository at this point in the history
  • Loading branch information
zouter committed Apr 10, 2019
1 parent 4085b23 commit 4c4f760
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 172 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ FROM dynverse/dynwrapr:v0.1.0

ARG GITHUB_PAT

RUN R -e 'devtools::install_cran("SCORPIUS")'
COPY definition.yml run.R example.sh package/ /code/

COPY definition.yml run.R example.sh /code/
RUN R -e 'devtools::install("/code/", dependencies = TRUE, quick = TRUE)'

ENTRYPOINT ["/code/run.R"]
103 changes: 0 additions & 103 deletions definition.yml

This file was deleted.

1 change: 1 addition & 0 deletions definition.yml
75 changes: 9 additions & 66 deletions run.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,14 @@
requireNamespace("dyncli", quietly = TRUE)
task <- dyncli::main()

library(dplyr, warn.conflicts = FALSE)
requireNamespace("dynutils", quietly = TRUE)
requireNamespace("dynwrap", quietly = TRUE)
requireNamespace("SCORPIUS", quietly = TRUE)

# ____________________________________________________________________________
# Load data ####

expression <- as.matrix(task$expression)
parameters <- task$parameters

# ____________________________________________________________________________
# Infer trajectory ####


# use k <= 1 to turn off clustering
if (parameters$k <= 1) {
parameters$k <- NULL
}

# TIMING: done with preproc
checkpoints <- list(method_afterpreproc = Sys.time())

space <- SCORPIUS::reduce_dimensionality(
x = expression,
dist_fun = function(x, y = NULL) dynutils::calculate_distance(x = x, y = y, method = parameters$distance_method),
landmark_method = ifelse(parameters$sparse, "naive", "none"),
ndim = parameters$ndim,
num_landmarks = ifelse(nrow(expression) > 500, 500, nrow(expression))
library(tiscorpius, warn.conflicts = FALSE)

output <- tiscorpius::run_fun(
expression = task$expression,
priors = task$priors,
parameters = task$parameters,
seed = task$seed,
verbose = task$verbose
)

# infer a trajectory through the data
traj <- SCORPIUS::infer_trajectory(
space,
k = parameters$k,
thresh = parameters$thresh,
maxit = parameters$maxit,
stretch = parameters$stretch,
smoother = parameters$smoother
)

# TIMING: done with method
checkpoints$method_aftermethod <- Sys.time()

# ____________________________________________________________________________
# Save output ####

output <-
dynwrap::wrap_data(cell_ids = names(traj$time)) %>%
dynwrap::add_linear_trajectory(
pseudotime = traj$time
) %>%
dynwrap::add_timings(timings = checkpoints)

# convert trajectory to segments
dimred_segment_points <- traj$path
dimred_segment_progressions <- output$progressions %>% select(from, to, percentage)

output <-
output %>%
dynwrap::add_dimred(
dimred = space,
dimred_segment_points = dimred_segment_points,
dimred_segment_progressions = dimred_segment_progressions,
connect_segments = TRUE
)

output %>% dyncli::write_output(task$output)
dyncli::write_output(output, task$output)
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=1.0.0.01
VERSION=$(cat package/DESCRIPTION | sed -n 's/.*Version: \(.*\).*/\1/p')

0 comments on commit 4c4f760

Please sign in to comment.