Python wrapper for SauersML/gnomon (high-performance polygenic score engine).
Project description
gnomon (Python)
Python wrapper for the SauersML/gnomon
high-performance polygenic score engine. Each gnomon subcommand is a
typed Python function with kwargs that mirror the CLI flags one-to-one,
plus a parsed-result dataclass.
import gnomon
result = gnomon.score(
"PGS004536,PGS001320,PGS005331",
"/data/aou_array_plink/arrays",
)
result.output_path # PosixPath('.../arrays_pgs3_<hash>.sscore')
result.n_samples # 245678
result.score_names # ('PGS004536', 'PGS001320', 'PGS005331')
# Indexable / queryable:
result.scores["NWD_001"] # {score: {avg, sum, denom}}
result.scores.score_for("NWD_001", "PGS004536") # float
result.scores.to_pandas() # DataFrame
Install
pip install gnomon
cargo install gnomon
Binary located via binary= or PATH. No env-var indirection — pass
binary= explicitly if it isn't on PATH.
Subcommands
gnomon.score(score, input_path, *, keep=None, reference=None, build=None,
panel=None, inferred_sex=None, ...) -> ScoreResult
gnomon.terms(genotype_path, *, sex=True) -> TermsResult
gnomon.run_all(score, input_path, model) -> AllResult
import gnomon.map as gmap
gmap.fit(genotype_path, components=20, ld=True, bp_window=500_000)
gmap.project(genotype_path, model="hwe_1kg_hgdp_gsa_v3")
import gnomon.calibrate as gcal
gcal.train("train.tsv", num_pcs=10, model_family="gam")
gcal.infer("test.tsv", model="model.toml")
Shortcuts: avoid downloads and re-inference
Every kwarg the CLI exposes is on the Python API — none of these overrides require touching the binary directly.
gnomon.score(
"PGS004536,PGS001320",
"/data/cohort/arrays",
reference="/cache/hg38.fa", # skip reference auto-download
build="38", # skip build auto-detection
panel="/cache/1kg_panel.vcf", # supply harmonisation panel
inferred_sex="male", # skip the in-pipeline sex scan
keep="/data/keep.iids.txt", # restrict to a sample subset
)
inferred_sex accepts "male", "female", "unknown", the matching
InferredSex enum members, or any string returned by infer_sex.
ScoreTable
gnomon.read_sscore(path) returns a ScoreTable. The result of
gnomon.score(...) carries one on .scores.
table.iids # tuple of sample IDs
table.score_names # tuple of PGS names (suffix-stripped)
table.fids # tuple of family IDs
table.avg / .sum / .denom # tuple-of-tuples or None per column
# Membership / lookup:
"NWD_001" in table
table.index_of("NWD_001") # int row index
table["NWD_001"] # {score: {avg, sum, denom}}
table.score_for("NWD_001", "PGS004536", kind="avg") # float
# Pandas adapter (optional, requires `pip install gnomon[pandas]`):
table.to_pandas()
Missing columns (e.g. older builds without _SUM / _DENOM) return
None — no fake zeros.
Path inference
Sscore output filenames follow score::main::score_output_path exactly.
For inline PGS arguments the wrapper computes the same
pgs<count>_<fnv1a64_hex8> suffix the Rust binary writes — you don't
have to guess where the file lands.
from gnomon import expected_sscore_path
expected_sscore_path("/data/arrays.vcf.gz", "PGS001,PGS002")
# PosixPath('/data/arrays_pgs2_<hash>.sscore')
Errors
GnomonBinaryNotFound— CLI not installed / not on PATH.InvalidConfig— argument combination rejected before launching.GnomonFailed— CLI exited non-zero. The exception preservesstdout,stderr,returncode. Includes the last non-empty stderr line in the message so the failure mode is obvious without spelunking.SscoreParseError— corrupt or unexpectedly-shaped.sscoreoutput.
All subclass GnomonError.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gnomon_pgs-0.1.0.tar.gz.
File metadata
- Download URL: gnomon_pgs-0.1.0.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c828c66273746d86d34f1957c8d6754e644bd6188d54187aa9813c7cf570ccfa
|
|
| MD5 |
11ffac27f73790f7accd8aa489efa49d
|
|
| BLAKE2b-256 |
797f4c0cd382fade9fea482c246e3628f83be26ddc639758b73007c42fb792bb
|
File details
Details for the file gnomon_pgs-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gnomon_pgs-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
713f59109b463b312f95597fbda711d8db45b7d9be0fa5bf99d939e51405335e
|
|
| MD5 |
3cc74a1614c8761270949ffa675d8cfe
|
|
| BLAKE2b-256 |
6461f816207e4e0461b1651f5a83042d2d5187ed8283be7cfbaf05046bb57c25
|
File details
Details for the file gnomon_pgs-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: gnomon_pgs-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 9.5 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b4eefe5e8ac5084dfe9536a10cb1eb9be9fc80581c7ebe97537bff55f73b152
|
|
| MD5 |
db89fbe5a4680f33d335f8c455a4ce27
|
|
| BLAKE2b-256 |
2f89e021eb86702d90fe3ebea9558653f3b32733cdb18eea3072bcb5047f5a77
|
File details
Details for the file gnomon_pgs-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: gnomon_pgs-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 9.2 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06417d7c93b4a3dd818268aa3c75e2661a33f03a961760a57a3a254aac5a7b6b
|
|
| MD5 |
71a74763aabb362d9c7157f654dac213
|
|
| BLAKE2b-256 |
22747b996fa1c2688d5623920b76e1ad945db995d9e2f7ceece3b1a930df7685
|
File details
Details for the file gnomon_pgs-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: gnomon_pgs-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 6.1 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00aa5135a4bec6aaf97d4f2a05c91403eb3a822c7bc27c9bf93e4fb3ce149696
|
|
| MD5 |
0a6097381bf50356f43018798ffc4d5e
|
|
| BLAKE2b-256 |
dda63107edbc25c6eaac3ca6e7ffccb6db638e44cacc5e93848253b96c5d29bd
|
File details
Details for the file gnomon_pgs-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: gnomon_pgs-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 6.6 MB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96b7af66a67b803b133b4e44c5cb88d3b980a19ce1adf79e6c9b5979931126de
|
|
| MD5 |
18f7a6d0be72e375f99b18fbfb4127cb
|
|
| BLAKE2b-256 |
fd9b52893890310ca4e4897d556d1506b714687c54b2113d6107443b27d5a233
|