Skip to content

Commit

Permalink
add singler
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood committed Sep 3, 2024
1 parent 115c158 commit 2d85a7b
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/methods/singler/config.vsh.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
__merge__: /src/api/comp_method.yaml
name: "singler"
label: SingleR
summary: Reference-Based Single-Cell RNA-Seq Annotation
description: |
Performs unbiased cell type recognition from single-cell RNA sequencing data,
by leveraging reference transcriptomic datasets of pure cell types to infer the
cell of origin of each single cell independently.
references:
doi:
- 10.1038/s41590-018-0276-y
links:
repository: https://www.bioconductor.org/packages/release/bioc/html/SingleR.html
documentation: https://www.bioconductor.org/packages/release/bioc/vignettes/SingleR/inst/doc/SingleR.html
info:
preferred_normalization: log_cp10k
variants:
seurat:
resources:
- type: r_script
path: script.R
engines:
- type: docker
image: openproblems/base_r:1.0.0
setup:
- type: r
bioc: [SingleR]
runners:
- type: executable
- type: nextflow
directives:
label: [midtime, highmem, highcpu]
43 changes: 43 additions & 0 deletions src/methods/singler/script.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
cat(">> Loading dependencies\n")
library(anndata, warn.conflicts = FALSE)
requireNamespace("SingleR", quietly = TRUE)
library(Matrix, warn.conflicts = FALSE)

## VIASH START
par <- list(
input_train = "resources_test/task_label_projection/pancreas/train.h5ad",
input_test = "resources_test/task_label_projection/pancreas/test.h5ad",
output = "output.h5ad"
)
meta <- list(
name = "seurat_transferdata"
)
## VIASH END

cat(">> Load input data\n")
input_train <- read_h5ad(par$input_train)
input_test <- read_h5ad(par$input_test)

cat(">> Run method\n")
pred <- SingleR::SingleR(
test = t(input_test$layers[["normalized"]]),
ref = t(input_train$layers[["normalized"]]),
labels = input_train$obs$label
)

cat(">> Create output data\n")
output <- anndata::AnnData(
obs = data.frame(
row.names = input_test$obs_names,
label_pred = pred$labels
),
uns = list(
method_id = meta$name,
dataset_id = input_test$uns[["dataset_id"]],
normalization_id = input_test$uns[["normalization_id"]]
),
shape = c(input_test$n_obs, 0L)
)

cat(">> Write output to file\n")
output$write_h5ad(par$output, compression = "gzip")
1 change: 1 addition & 0 deletions src/workflows/run_benchmark/config.vsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ dependencies:
- name: methods/scanvi
- name: methods/scanvi_scarches
- name: methods/seurat_transferdata
- name: methods/singler
- name: methods/xgboost
- name: metrics/accuracy
- name: metrics/f1
Expand Down
1 change: 1 addition & 0 deletions src/workflows/run_benchmark/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ methods = [
scanvi,
scanvi_scarches,
seurat_transferdata,
singler,
xgboost
]

Expand Down

0 comments on commit 2d85a7b

Please sign in to comment.