generated from openproblems-bio/task_template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
__merge__: ../../api/comp_control_method.yaml | ||
name: "random_features" | ||
label: Random Features | ||
summary: "Negative control by randomly embedding into a 2D space." | ||
description: "This method serves as a negative control, where the data is randomly embedded into a two-dimensional space, with no attempt to preserve the original structure." | ||
info: | ||
v1: | ||
path: openproblems/tasks/dimensionality_reduction/methods/baseline.py | ||
commit: 80b37e7a6aa27df4436f400397564c01276817e0 | ||
preferred_normalization: counts | ||
variants: | ||
random_features: | ||
resources: | ||
- type: python_script | ||
path: script.py | ||
engines: | ||
- type: docker | ||
image: openproblems/base_python:1.0.0 | ||
runners: | ||
- type: executable | ||
- type: nextflow | ||
directives: | ||
label: [midtime, highmem, highcpu] |
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,34 @@ | ||
import anndata as ad | ||
import numpy as np | ||
|
||
## VIASH START | ||
par = { | ||
"input": "resources_test/dimensionality_reduction/pancreas/test.h5ad", | ||
"output": "reduced.h5ad", | ||
} | ||
meta = { | ||
"functionality_name": "random_features", | ||
} | ||
## VIASH END | ||
|
||
print("Load input data", flush=True) | ||
input = ad.read_h5ad(par["input"]) | ||
|
||
print("Create random embedding", flush=True) | ||
X_emb = np.random.normal(0, 1, (input.shape[0], 2)) | ||
|
||
print("Create output AnnData", flush=True) | ||
output = ad.AnnData( | ||
obs=input.obs[[]], | ||
obsm={ | ||
"X_emb": X_emb | ||
}, | ||
uns={ | ||
"dataset_id": input.uns["dataset_id"], | ||
"normalization_id": input.uns["normalization_id"], | ||
"method_id": meta["functionality_name"] | ||
} | ||
) | ||
|
||
print("Write output to file", flush=True) | ||
output.write_h5ad(par["output"], compression="gzip") |