-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add spatial clustering process in simulated dataset
- Loading branch information
1 parent
90bcfbe
commit 97f1e78
Showing
4 changed files
with
98 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/process_datasets/generate_sim_spatialcluster/config.vsh.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: generate_sim_sparialcluster | ||
namespace: process_datasets | ||
description: generate spatial cluster of simulated dataset before run metrics folder | ||
argument_groups: | ||
- name: Inputs | ||
arguments: | ||
- type: file | ||
name: --input_sp | ||
description: Raw spatial dataset | ||
example: resources_test/datasets/MOBNEW/dataset_sp.h5ad | ||
required: true | ||
- type: file | ||
name: --input_sp_sim | ||
description: similated spatial dataset | ||
example: resources_test/datasets/MOBNEW/simulated_dataset.h5ad | ||
required: true | ||
|
||
- name: Outputs | ||
arguments: | ||
- type: file | ||
name: --output_sp | ||
description: Processed simulated spatial dataset | ||
example: simulated_dataset.h5ad | ||
direction: output | ||
required: true | ||
|
||
resources: | ||
- type: r_script | ||
path: script.R | ||
- path: /src/helpers/utils.R | ||
|
||
test_resources: | ||
- path: /resources_test/datasets/MOBNEW | ||
dest: resources_test/datasets/MOBNEW | ||
- type: python_script | ||
path: /common/component_tests/run_and_check_output.py | ||
|
||
engines: | ||
- type: docker | ||
image: openproblems/base_r:1.0.0 | ||
setup: | ||
- type: r | ||
bioc: | ||
- scater | ||
- BayesSpace | ||
- SingleCellExperiment | ||
cran: | ||
- aricode | ||
- anndata | ||
- reshape2 | ||
|
||
|
||
runners: | ||
- type: executable | ||
- type: nextflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
|
||
## VIASH START | ||
par <- list( | ||
# inputs | ||
input_spatial_dataset = "resources_test/datasets/MOBNEW/dataset_sp.h5ad", | ||
input_simulated_dataset = "resources_test/datasets/MOBNEW/simulated_dataset.h5ad", | ||
# outputs | ||
output_sp = "resources_test/datasets/MOBNEW/simulated_dataset.h5ad" | ||
) | ||
meta <- list( | ||
resources_dir = "target/executable/process_datasets/generate_sim_sparialCluster" | ||
) | ||
## VIASH END | ||
source(file.path(meta$resources_dir, "utils.R")) | ||
|
||
cat("Read input files\n") | ||
input_real_sp <- anndata::read_h5ad(par$input_spatial_dataset) | ||
input_simulated_sp <- anndata::read_h5ad(par$input_simulated_dataset) | ||
|
||
sim_sce <- scater::logNormCounts(SingleCellExperiment::SingleCellExperiment( | ||
list(counts = Matrix::t(input_simulated_sp$layers[["counts"]])), | ||
colData = input_simulated_sp$obs, | ||
metadata = input_simulated_sp$obsm | ||
)) | ||
cat("add spatial cluster in simulated dataset:\n") | ||
sim_cluster <- generate_sim_spatialCluster(input_real_sp, input_simulated_sp) | ||
|
||
# need reclassify again | ||
real_cluster <- input_real_sp$obs[,c("spatial_cluster")] | ||
location <- colnames(counts(sim_sce)) | ||
sim_new_cluster <- reclassify_simsce(location, real_cluster, sim_cluster) | ||
|
||
input_simulated_sp$obs$spatial_cluster <- sim_new_cluster | ||
|
||
cat("Writing output to file\n") | ||
input_simulated_sp$write_h5ad(par$output_sp, compression = "gzip") |