Delete 03_add_features.py
Browse files- 03_add_features.py +0 -105
03_add_features.py
DELETED
|
@@ -1,105 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""
|
| 3 |
-
Materialize a small example feature set from a locally generated DRMHB AnnData.
|
| 4 |
-
|
| 5 |
-
This does NOT reopen the VibFrame archive. Features are derived from the raw
|
| 6 |
-
waveform/spectrum representation already stored in the featureless .h5ad.
|
| 7 |
-
|
| 8 |
-
Install:
|
| 9 |
-
python -m pip install "vibframe-anndata==0.2.0"
|
| 10 |
-
|
| 11 |
-
Usage:
|
| 12 |
-
python examples/03_add_features.py \
|
| 13 |
-
DRMHB.float32.h5ad \
|
| 14 |
-
DRMHB.example-features.h5ad
|
| 15 |
-
|
| 16 |
-
The example is intentionally small. See the vibframe-anndata documentation for
|
| 17 |
-
the complete catalog/configuration model:
|
| 18 |
-
https://413hq.github.io/vibframe-anndata-docs/latest/
|
| 19 |
-
"""
|
| 20 |
-
|
| 21 |
-
from __future__ import annotations
|
| 22 |
-
|
| 23 |
-
import argparse
|
| 24 |
-
from pathlib import Path
|
| 25 |
-
|
| 26 |
-
from vibframe_anndata import (
|
| 27 |
-
__version__ as vibframe_anndata_version,
|
| 28 |
-
add_features_to_h5ad,
|
| 29 |
-
validate_streamed_h5ad,
|
| 30 |
-
)
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
def parse_args() -> argparse.Namespace:
|
| 34 |
-
parser = argparse.ArgumentParser(
|
| 35 |
-
description="Add a compact demonstration feature set to DRMHB AnnData."
|
| 36 |
-
)
|
| 37 |
-
parser.add_argument(
|
| 38 |
-
"source",
|
| 39 |
-
type=Path,
|
| 40 |
-
help="Featureless DRMHB .h5ad created from the VibFrame archive.",
|
| 41 |
-
)
|
| 42 |
-
parser.add_argument(
|
| 43 |
-
"output",
|
| 44 |
-
type=Path,
|
| 45 |
-
help="Destination enriched .h5ad.",
|
| 46 |
-
)
|
| 47 |
-
parser.add_argument(
|
| 48 |
-
"--block-rows",
|
| 49 |
-
type=int,
|
| 50 |
-
default=256,
|
| 51 |
-
help="Observation block size (default: 256).",
|
| 52 |
-
)
|
| 53 |
-
return parser.parse_args()
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
def main() -> None:
|
| 57 |
-
args = parse_args()
|
| 58 |
-
|
| 59 |
-
if vibframe_anndata_version != "0.2.0":
|
| 60 |
-
raise RuntimeError(
|
| 61 |
-
"This example is validated for vibframe-anndata==0.2.0; "
|
| 62 |
-
f"active version: {vibframe_anndata_version!r}"
|
| 63 |
-
)
|
| 64 |
-
|
| 65 |
-
if not args.source.is_file():
|
| 66 |
-
raise FileNotFoundError(args.source)
|
| 67 |
-
|
| 68 |
-
args.output.parent.mkdir(parents=True, exist_ok=True)
|
| 69 |
-
|
| 70 |
-
# A deliberately compact demonstration spanning spectral and waveform
|
| 71 |
-
# features. Catalog-backed spectral descriptors use the metric metadata
|
| 72 |
-
# persisted in the source AnnData.
|
| 73 |
-
config = {
|
| 74 |
-
"version": 1,
|
| 75 |
-
"output": {"dtype": "float32"},
|
| 76 |
-
"feature_policy": {
|
| 77 |
-
"on_conflict": "error",
|
| 78 |
-
"on_error": "nan",
|
| 79 |
-
},
|
| 80 |
-
"features": [
|
| 81 |
-
{"name": "vel_overall_rms", "source": "spectrum"},
|
| 82 |
-
{"name": "amp_1X", "source": "spectrum"},
|
| 83 |
-
{"name": "amp_BPFO", "source": "spectrum"},
|
| 84 |
-
{"name": "amp_BPFI", "source": "spectrum"},
|
| 85 |
-
{"name": "rms", "source": "waveform"},
|
| 86 |
-
{"name": "kurtosis", "source": "waveform"},
|
| 87 |
-
],
|
| 88 |
-
}
|
| 89 |
-
|
| 90 |
-
output = add_features_to_h5ad(
|
| 91 |
-
args.source,
|
| 92 |
-
config,
|
| 93 |
-
output=args.output,
|
| 94 |
-
block_rows=args.block_rows,
|
| 95 |
-
)
|
| 96 |
-
|
| 97 |
-
validation = validate_streamed_h5ad(output)
|
| 98 |
-
|
| 99 |
-
print(f"Created: {output}")
|
| 100 |
-
print(f"Observations: {validation['n_obs']:,}")
|
| 101 |
-
print(f"Variables/features: {validation['n_vars']:,}")
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
if __name__ == "__main__":
|
| 105 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|