Skip to content

Commit ded8477

Browse files
authored
Add negative control method that uses normally distributed data (#5)
* add a negative normal method * fix normal method; rename folder * make negative values positive * rename variables
1 parent 0159cd5 commit ded8477

File tree

7 files changed

+87
-33
lines changed

7 files changed

+87
-33
lines changed

src/control_methods/negative/config.vsh.yaml

-30
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
__merge__: ../../api/comp_control_method.yaml
2+
3+
name: negative_normal
4+
label: negative_normal
5+
summary: A negative control which generates normal distributed data.
6+
description: |
7+
This control method generates normal distributed data as a negative control.
8+
The mean and the sd are defined by the mean and sd of the input data.
9+
10+
resources:
11+
- type: r_script
12+
path: script.R
13+
14+
engines:
15+
- type: docker
16+
image: openproblems/base_r:1.0.0
17+
18+
runners:
19+
- type: executable
20+
- type: nextflow
21+
directives:
22+
label: [midtime, midmem, midcpu]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## VIASH START
2+
par <- list(
3+
input = "resources_test/spatialsimbench_mobnew/dataset_sp.h5ad",
4+
output = "simulated_dataset.h5ad"
5+
)
6+
meta <- list(
7+
name = "negative_normal"
8+
)
9+
## VIASH END
10+
11+
cat("Reading input files\n")
12+
input <- anndata::read_h5ad(par$input)
13+
14+
# generate random values
15+
n_rows <- nrow(input)
16+
n_cols <- ncol(input)
17+
18+
values <- rnorm(n = n_rows * n_cols, mean = 3, sd = 1)
19+
20+
# make sure all values are positive
21+
values[values < 0] <- abs(values[values < 0])
22+
23+
cat("Generate outoput file\n")
24+
output <- anndata::AnnData(
25+
layers = list(
26+
counts = matrix(values, nrow = n_rows, ncol = n_cols)
27+
),
28+
obs = input$obs[c("row", "col")],
29+
var = input$var,
30+
uns = c(
31+
input$uns,
32+
list(
33+
method_id = meta$name
34+
)
35+
)
36+
)
37+
38+
cat("Write output files\n")
39+
output$write_h5ad(par$output, compression = "gzip")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
__merge__: ../../api/comp_control_method.yaml
2+
3+
name: negative_shuffle
4+
label: negative_shuffle
5+
summary: A negative control method which shuffles the input data.
6+
description: |
7+
This control method shuffles the input data as a negative control.
8+
9+
resources:
10+
- type: r_script
11+
path: script.R
12+
13+
engines:
14+
- type: docker
15+
image: openproblems/base_r:1.0.0
16+
17+
runners:
18+
- type: executable
19+
- type: nextflow
20+
directives:
21+
label: [midtime, midmem, midcpu]

src/control_methods/negative/script.R renamed to src/control_methods/negative_shuffle/script.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ par <- list(
44
output = "simulated_dataset.h5ad"
55
)
66
meta <- list(
7-
name = "negative"
7+
name = "negative_shuffle"
88
)
99
## VIASH END
1010

src/workflows/run_benchmark/config.vsh.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ dependencies:
5757
- name: methods/symsim
5858
- name: methods/zinbwave
5959
- name: control_methods/positive
60-
- name: control_methods/negative
60+
- name: control_methods/negative_shuffle
61+
- name: control_methods/negative_normal
6162
- name: metrics/downstream
6263
- name: metrics/ks_statistic_gene_cell
6364
- name: metrics/ks_statistic_sc_features

src/workflows/run_benchmark/main.nf

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ methods = [
1616
symsim,
1717
zinbwave,
1818
positive,
19-
negative
19+
negative_shuffle,
20+
negative_normal
2021
]
2122

2223
// construct list of metrics

0 commit comments

Comments
 (0)