Fast evaluation of SMC' likelihood for population genetic data
Project description
phlashlib
This library computes the log-likelihood of binary heterozygosity sequences under a sequentially Markov coalescent model with recombination.
API
phlashlib.loglik(
data: Int[ArrayLike, "L"],
iicr: IICRCurve,
times: Float[ArrayLike, "T"],
theta: ScalarLike,
rho: ScalarLike,
warmup: int = 500,
chunk_size: int = None,
) -> Scalar
Features
- JAX-compatible:
vmap,jit,grad, etc. - GPU-accelerated via
cuda.core.experimental(fallback to CPU if unavailable)
Example
from phlashlib.iicr import PiecewiseConstant
from phlashlib.loglik import loglik
import jax.numpy as jnp
times = jnp.array([0.0, 0.1, 0.5, 2.0])
rates = jnp.array([100.0, 10.0, 1.0])
iicr = PiecewiseConstant(t=times[:-1], c=rates)
data = jnp.array([0, 1, 1, 0, -1, 1, 0, 0], dtype=jnp.int8)
theta = 1.5
rho = 0.5
ll = loglik(data, iicr, times, theta, rho)
JAX Use
from jax import jit, vmap, grad
# JIT
f = jit(loglik)
# Vectorized over data
batched_ll = vmap(loglik, in_axes=(0, None, None, None, None))(batch_data, iicr, times, theta, rho)
# Gradient w.r.t. theta
dtheta = grad(loglik, argnums=3)(data, iicr, times, theta, rho)
Notes
data: 1Dint8, values in{0, 1, -1}iicr: subclass ofIICRCurve, e.g.PiecewiseConstanttheta,rho: scalar mutation and recombination rates- Internally uses a fused CUDA kernel with
jax.custom_vjpif available - Fallback implementation uses pure JAX
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
phlashlib-0.2.1.tar.gz
(10.3 kB
view details)
Built Distribution
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
phlashlib-0.2.1-py3-none-any.whl
(13.0 kB
view details)
File details
Details for the file phlashlib-0.2.1.tar.gz.
File metadata
- Download URL: phlashlib-0.2.1.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c3428f04557aec06ec49663d2e65d3ed695b60fc3d41920998b351c13dc214e
|
|
| MD5 |
9dbbafc3ae43e0ae308d42140d4f36b1
|
|
| BLAKE2b-256 |
468d698a0b15e60404e4446e8a4108f2e677010a96fe895a4f8b06599bf99e62
|
File details
Details for the file phlashlib-0.2.1-py3-none-any.whl.
File metadata
- Download URL: phlashlib-0.2.1-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","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":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
028e57dbfffedc64eb58654d637e3257ebea6b7e24fa18ef5ea260b39f1b6f9f
|
|
| MD5 |
d9adca44ddb459a7d7bef1974d01745c
|
|
| BLAKE2b-256 |
1fc3ee8d7ba2bb29e66d986b74234bab992061e4faf8b2d006aef5fa90eff330
|