Skip to content

Commit

Permalink
upload control methods
Browse files Browse the repository at this point in the history
  • Loading branch information
littlecabiria committed Aug 30, 2024
1 parent b8996bd commit e5a5b10
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/control_methods/negative/config.vsh.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
__merge__: ../../api/comp_control_method.yaml

name: negative
label: negative
summary: A negative control method.
description: |
A negative control method.
# references:
# doi:

# info:
# documentation_url: https://xzhoulab.github.io/SRTsim
# repository_url: https://github.com/xzhoulab/srtsim

resources:
- type: r_script
path: script.R

engines:
- type: docker
image: openproblems/base_r:1.0.0
setup:
- type: r
cran: SRTsim

runners:
- type: executable
- type: nextflow
directives:
label: [midtime, midmem, midcpu]
38 changes: 38 additions & 0 deletions src/control_methods/negative/script.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## VIASH START
par <- list(
input = "resources_test/datasets/MOBNEW/dataset_sp.h5ad",
output = "simulated_dataset.h5ad",
)
meta <- list(
name = "negative"
)
## VIASH END

cat("Reading input files\n")
input <- anndata::read_h5ad(par$input)

count_matrix <- as.matrix(input$layers[['counts']])

n_rows <- nrow(count_matrix)
n_cols <- ncol(count_matrix)

random_matrix_uniform <- matrix(runif(n_rows * n_cols), nrow = n_rows, ncol = n_cols)
rownames(random_matrix_uniform) <- rownames(count_matrix)

cat("Generate outoput file\n")
output <- anndata::AnnData(
layers = list(
counts = random_matrix_uniform
),
obs = input$obs[c("row", "col")],
var = input$var,
uns = c(
input$uns,
list(
method_id = meta$name
)
)
)

cat("Write output files\n")
output$write_h5ad(par$output, compression = "gzip")
30 changes: 30 additions & 0 deletions src/control_methods/positive/config.vsh.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
__merge__: ../../api/comp_control_method.yaml

name: positive
label: positive
summary: A positive control method.
description: |
A positive control method.
# references:
# doi:

# info:
# documentation_url: https://xzhoulab.github.io/SRTsim
# repository_url: https://github.com/xzhoulab/srtsim

resources:
- type: r_script
path: script.R

engines:
- type: docker
image: openproblems/base_r:1.0.0
setup:
- type: r
cran: SRTsim

runners:
- type: executable
- type: nextflow
directives:
label: [midtime, midmem, midcpu]
17 changes: 17 additions & 0 deletions src/control_methods/positive/script.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## VIASH START
par <- list(
input = "resources_test/datasets/MOBNEW/dataset_sp.h5ad",
output = "simulated_dataset.h5ad"
)
meta <- list(
name = "positive"
)
## VIASH END

cat("Reading input files\n")
input <- anndata::read_h5ad(par$input)

input$uns$method_id <- meta$name

cat("Write output files\n")
input$write_h5ad(par$output, compression = "gzip")

0 comments on commit e5a5b10

Please sign in to comment.