Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.


PyPI Docs DOI License: MIT

seminal is a Python library of published risk equations in andrology and male reproductive health, implemented with the coefficients exactly as printed in the source papers and checked against the authors' own validation data.

It currently covers:

  • Azoospermia probability from Tradewell et al. (World J Mens Health 2022): a quadratic in serum FSH alone, and a logistic regression on age, FSH, LH, total testosterone and mean testis volume. Both estimate the probability that a man presenting for infertility evaluation has no sperm in the ejaculate, without a semen analysis.
  • WHO 2021 semen reference distributions from Campbell et al. (Andrology 2021), the fertile-man centiles adopted by the 6th edition of the WHO laboratory manual: where a semen parameter sits among fertile men, and whether it falls below the lower reference limit.

Not affiliated with the original authors. This is an independent implementation of published equations, intended for research use. It is not a medical device and should not be used to make clinical decisions.

Installation

pip install seminal

Requires Python 3.8+, numpy 1.20+ and pandas 1.3+. Full documentation: datasciencedynamics.com/seminal.

Usage

FSH alone

from seminal import azoospermia_fsh

azoospermia_fsh(20)
# 0.439

The published curve is U-shaped: 10.1% at undetectable FSH, a minimum of about 8.4% at FSH 3.6 IU/L, and 100% from about 30 IU/L. Output is clipped to [0, 1]; pass clip=False to reproduce the paper's unbounded quadratic.

Full logistic model

from seminal import azoospermia_lr

azoospermia_lr(age=36, fsh=5.7, lh=4.5, testosterone=429, testis_volume=15)
# 0.086

Pass explain=True to also get the linear predictor and each input's contribution to the log-odds, largest first.

A whole cohort

from seminal import add_azoospermia_risk_cols

scored = add_azoospermia_risk_cols(
    df, age_col="age", fsh_col="fsh", lh_col="lh",
    testosterone_col="testosterone", testis_volume_col="testis_volume",
)
scored[["azoo_fsh", "azoo_lr"]]

Rows missing any logistic-model input get NaN in azoo_lr; azoo_fsh needs only FSH.

Semen parameters against the WHO reference distribution

from seminal import semen_percentile, lower_reference_limit, below_reference

semen_percentile("concentration", 36)      # 25.0  (25th centile of fertile men)
lower_reference_limit("progressive_motility")   # 30  (WHO 2021; 32 under edition="who2010")
below_reference("normal_forms", 3)         # True

semen_reference() returns the full published table (2.5th to 97.5th centiles, with the 95% CI of the 5th), and add_semen_percentile_cols(df, {"concentration": "conc", ...}) adds a percentile and a below-limit flag per parameter for a cohort. Percentiles are interpolated between the nine published centiles and clipped to [2.5, 97.5].

The equations

FSH-only quadratic (Fig. 1): p(%) = 0.133·FSH² − 0.965·FSH + 10.1, fit to binned Miami probabilities, R² = 0.95.

Logistic regression (Table 3): p = 1 / (1 + exp(−η)) where

Term Units Coefficient
Intercept −1.9
Age years 0.02
FSH IU/L 0.13
LH IU/L 0.03
Total testosterone ng/dL −0.002
Mean testis volume cm³ (Prader orchidometer) −0.08

The paper prints the model form as 1/exp[−(b₀ + bᵢXᵢ)], which is a typesetting error (it exceeds 1); the standard logistic form is used here.

WHO 2021 reference distribution (Campbell et al. 2021, Table 3; 5th centile with 95% CI):

Parameter n 5th 50th 95th
Semen volume (mL) 3,586 1.4 (1.3 to 1.5) 3.0 6.2
Sperm concentration (10⁶/mL) 3,587 16 (15 to 18) 66 208
Total sperm number (10⁶) 3,584 39 (35 to 40) 210 701
Total motility (%) 3,488 42 (40 to 43) 64 90
Progressive motility (%) 3,389 30 (29 to 31) 55 77
Vitality (%) 1,337 54 (50 to 56) 78 97
Normal forms (%) 3,335 4 (3.9 to 4.0) 14 39

All nine centiles for all nine parameters are in the package, as printed, for both the combined WHO 2020 table and the 2010 to 2020 studies alone.

Validation against the authors' data

The study data are public under CC0 on Harvard Dataverse. make data_gen preprocess downloads them into data/ (gitignored) and the test suite then checks the implementation against the paper's external validation:

Site n AUC, logistic (paper) AUC, FSH-only (paper)
Milan 1,955 0.786 (0.79) 0.786 (0.78)
Chicago 596 0.718 (0.72) 0.707 (0.71)

Things to know about the data

  • The deposit contains all three sites as separate sheets. Miami (1,070 rows) and Chicago (643) are pre-exclusion. Applying the exclusions exactly as the paper states them (prior vasectomy, Y microdeletion, solitary testis, testosterone or steroid use) gives 943 and 614, not the paper's 946 and 596. The paper's counts are recovered exactly by not excluding Y microdeletions, reading solitary testis from the absence codes (Miami) or a zero volume (Chicago), and defining azoospermia as concentration below 0.01 M/mL. preprocessing.py applies that reproduced rule by default (--exclusions stated gives the literal one); the choice does not change the AUCs. Milan (1,955) matches either way.
  • Chicago testis volumes are ultrasound long-axis measurements in cm (median 4.5), not orchidometer volumes in mL (median 14 to 15 at Miami and Milan). The paper does not address this; preprocessing.py labels the measurement method per site.
  • The logistic coefficients are printed to one or two significant figures. At the extremes of testosterone and age this rounding alone can move the log-odds by several tenths. A refit on the Miami data recovers full-precision values; that is planned for a later release and kept separate from the as-published model.
  • Azoospermia was confirmed on at least two semen analyses. The outcome in the Miami and Chicago sheets is sperm concentration = 0; Milan carries an explicit flag plus obstructive/non-obstructive type.

Notebooks

  • 00_quickstart.ipynb: one patient, the FSH curve, scoring the validation cohorts, ROC / PR / calibration per site, explaining a prediction.
  • 01_reproduce_tradewell.ipynb: rebuild the paper's cohort and Table 1 from the deposit, refit the logistic model on Miami, calibration-in-the-large and slope per site, decision curves, intercept-only recalibration.

Both run against data/processed/, built by make data_gen preprocess. Notebooks are committed without outputs; the rendered versions are on the documentation site.

Repository layout

seminal/
├── src/seminal/      the package (equations and reference tables; no data)
├── tests/              unit tests plus optional validation against data/
├── data_gen.py         download the Dataverse file into data/raw
├── preprocessing.py    harmonize sites into data/processed
├── notebooks/          quickstart and the reproduction of Tradewell et al.
└── Makefile            venv, install, test, data_gen, preprocess, build

Citation

If you use seminal, please cite the software and the original paper.

@software{shpaner_2026_24411154,
   author       = {Shpaner, Leonid},
   title        = {seminal: published risk equations in andrology and male reproductive health},
   month        = nov,
   year         = 2026,
   publisher    = {Zenodo},
   version      = {0.0.1a1},
   doi          = {10.5281/zenodo.24411154},
   url          = {https://doi.org/10.5281/zenodo.24411154}
}

CITATION.cff carries the same metadata (GitHub shows it as "Cite this repository"). The original paper:

Tradewell MB, Cazzaniga W, Pagani RL, et al. Algorithms for Predicting the Probability of Azoospermia from Follicle Stimulating Hormone: Design and Multi-Institutional External Validation. World J Mens Health. 2022;40(4):600-607. doi:10.5534/wjmh.210138

Campbell MJ, Lotti F, Baldi E, et al. Distribution of semen examination results 2020 - A follow up of data collated for the WHO semen analysis manual 2010. Andrology. 2021;9(4):817-822. doi:10.1111/andr.12983

License

MIT. The study data on Dataverse are CC0.

Author

Leonid Shpaner, University of San Diego and Data Science Dynamics. leonshpaner.com

Metadata

Release files for seminal 0.0.1a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for seminal 0.0.1a1
File Size Uploaded Provenance Actions
seminal-0.0.1a1.tar.gz 19.9 kB With provenance Details for seminal-0.0.1a1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for seminal 0.0.1a1
File Interpreter ABI Platform Actions
seminal-0.0.1a1-py3-none-any.whl Python 3 none any Details for seminal-0.0.1a1-py3-none-any.whl

Total release size: 34.3 kB

Release files / seminal-0.0.1a1.tar.gz

Download URL seminal-0.0.1a1.tar.gz
Size 19.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b43b5491f2a49c5a30506094d850842436c138e5e0157a9a1a5b109e37563c21
BLAKE2b-256 checksum
How to use checksums
90571d3ab08d34c3fa0cda0108d2bf7ee0e19ac750c5ff3b907f963390a17d1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Release files / seminal-0.0.1a1-py3-none-any.whl

Download URL seminal-0.0.1a1-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12cd57fd66bc9500290b6a8d8622328c813a4466cab6decdbebd9e05f5451311
BLAKE2b-256 checksum
How to use checksums
1e8fc2565102ffc450f833a1dfabb96ff500d18422c65581521dd131c5ca229f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Security for seminal 0.0.1a1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for seminal-0.0.1a1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page