Skip to main content

KASM

The Kernel Allelic Series Model (KASM) integrates functional annotations to form a covariance kernel describing how allelic effects within a gene covary. Using data from exome association studies, KASM estimates the heritability of rare protein coding variants, its enrichment in structural and functional annotations, and the concordance of effects between pairs of variants. Our paper describes the methodology and applications in detail.

KASM can be installed with pip install kasm-pkg or uv add kasm-pkg.

Documentation · Quick start · Development

Quick start

Here is an example of using KASM to estimate heritability from exome-wide association statistics. KASM takes variant-level association statistics: one row per variant, with a canonical chr:pos:ref:alt ID, its gene, the effect estimate and SE, allele frequency, and annotations used as burden weights. Within-gene LD comes from an LD matrix file passed to Dataset as ldm; without one, as in this toy example, KASM assumes no LD between variants.

import kasm
import polars as pl

variant_df = pl.DataFrame(
    {
        "variant": [f"1:{pos}:A:G" for pos in range(100, 1000, 100)],
        "gene": ["G1"] * 3 + ["G2"] * 3 + ["G3"] * 3,
        "beta": [-0.12, 0.19, -0.15, 0.01, 0.17, -0.05, 0.15, 0.25, 0.22],
        "se": [0.10, 0.12, 0.09, 0.11, 0.10, 0.13, 0.08, 0.10, 0.12],
        "af": [2e-4, 5e-5, 3e-4, 1e-4, 2e-4, 4e-5, 5e-4, 2e-4, 6e-5],
        "constant": 1.0,
        "score1": [0.9, 0.1, 0.0, 0.9, 0.1, 0.0, 0.1, 0.8, 0.9],
        "score2": [0.8, 0.3, 0.1, 0.7, 0.2, 0.0, 0.3, 0.6, 0.9],
    }
)
print(variant_df)

dataset = kasm.Dataset(variant_df, beta_col="beta", se_col="se", sample_size=300_000)
model = kasm.Model(
    dataset,
    kasm.KernelOptions(
        maf_col="af",
        burden_cols=["constant", "score1", "score2"],
        overdispersion_cols=["constant"],
    ),
).compute_suffstats()
fit = kasm.fit_random_effects(model, exclude_genes=[], n_jk_blocks=3)
print(f"heritability: {fit.hsq:.2e} (SE {fit.hsq_se:.2e})")
print(fit.components.select("kernel", "kernel_coef", "kernel_coef_se"))

See more examples in the documentation.

Development

Development uses uv:

uv run --extra dev pytest
uv run --extra dev pytest --full
uv run --extra dev pre-commit install

Metadata

Release files for kasm-pkg 0.1.0

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

Source distribution (sdist)

Source distribution for kasm-pkg 0.1.0
File Size Uploaded Provenance
kasm_pkg-0.1.0.tar.gz 86.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for kasm-pkg 0.1.0
File Interpreter ABI Platform
kasm_pkg-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 179.8 kB

Release files / kasm_pkg-0.1.0.tar.gz

Download URL kasm_pkg-0.1.0.tar.gz
Size 86.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7e1dc3798b6aeaa32fe4a49808806a3b1cb8914595c0da3f85e8686189bcbbc1
BLAKE2b-256 checksum
How to use checksums
5321069c7cd1c57b555ef9c6f214829a5f4c640907b621cad2f722664a09101a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / kasm_pkg-0.1.0-py3-none-any.whl

Download URL kasm_pkg-0.1.0-py3-none-any.whl
Size 93.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16ffffe1468191b9ffa21241f0bdd5ec8fce91d668830d1dd79bd8421ebdc0e2
BLAKE2b-256 checksum
How to use checksums
1dfdbeb2538286a9839dd0023e9f540a922ebe44c84feba4002e2898c1c7d223
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for kasm-pkg 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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