Download tasks/cell_geometry/solution/reference/method.py from Tokenwave-AI/REE: direct link, hf CLI and curl.
- Browser
- Download file 734 Bytes
-
https://huggingface.co/datasets/Tokenwave-AI/REE/resolve/main/tasks/cell_geometry/solution/reference/method.py
- Command line
-
hf download hf://datasets/Tokenwave-AI/REE/tasks/cell_geometry/solution/reference/method.py
-
curl -L -o method.py https://huggingface.co/datasets/Tokenwave-AI/REE/resolve/main/tasks/cell_geometry/solution/reference/method.py
734 Bytes
| """Open Problems v1.0.0 densMAP PCA (logCP10k), with task I/O.""" | |
| import os | |
| import sys | |
| from importlib.util import module_from_spec, spec_from_file_location | |
| from pathlib import Path | |
| import scanpy as sc | |
| from umap import UMAP | |
| spec = spec_from_file_location( | |
| "embedding_io", Path(os.environ["CORE_DIR"]) / "interface/io.py" | |
| ) | |
| io = module_from_spec(spec) | |
| spec.loader.exec_module(io) | |
| adata = io.read_data(sys.argv[1]) | |
| # X already contains the source normalizer's log-CP10k expression. | |
| # These calls are the published _umap(adata, densmap=True, n_comps=50). | |
| sc.tl.pca(adata, n_comps=50, svd_solver="arpack") | |
| embedding = UMAP(densmap=True, random_state=42).fit_transform(adata.obsm["X_pca"]) | |
| io.write_embedding(sys.argv[2], embedding) | |