Skip to main content

prs-ui

PyPI version

Reusable Reflex UI components for Polygenic Risk Score (PRS) computation using the PGS Catalog.

Built on top of just-prs for the computation engine and reflex-mui-datagrid for data grid display.

Installation

pip install prs-ui

Running the Standalone App

uv run start

The launcher reads .env, resolves both the Reflex frontend port (PRS_UI_PORT, default 3000) and backend port (PRS_UI_BACKEND_PORT, default 8000), and passes the resolved pair explicitly to Reflex so another running Reflex app cannot shift only one side. Runtime uploads go under PRS_UI_DATA_DIR/input/ (default: ./data/input/ from the directory where the launcher was invoked), which keeps uvx runs from writing into the installed package.

Quick Start

import polars as pl
import reflex as rx
from reflex_mui_datagrid import LazyFrameGridMixin
from prs_ui import PRSComputeStateMixin, prs_section


class MyAppState(rx.State):
    genome_build: str = "GRCh38"
    cache_dir: str = ""
    status_message: str = ""


class PRSState(PRSComputeStateMixin, LazyFrameGridMixin, MyAppState):
    def load_genotypes(self, parquet_path: str) -> None:
        lf = pl.scan_parquet(parquet_path)
        self.set_prs_genotypes_lf(lf)  # preferred: provide a LazyFrame
        self.prs_genotypes_path = parquet_path


def prs_page() -> rx.Component:
    return prs_section(PRSState)

Components

Component Description
prs_workbench(source_section, prs_state, trait_state, mode_state, trait_selector, ...) Unified single-tab layout: one shared genotype source + Select by PRS / Select by Trait sub-tabs, per-mode controls, compute button, and per-mode results
vcf_source_section(source_state) Reference detachable genotype source: compact VCF upload + build detection + collapsed normalized preview. Swap it for your own source in a host app
prs_shared_build_bar(source_state) Single genome-build selector that fans the build out to all consumer states
prs_section(state) Older single-state section: build selector + score grid + compute button + progress + results
prs_build_selector(state) Genome build dropdown (GRCh37/GRCh38)
prs_scores_selector(state) MUI DataGrid for score selection. Selection (checkboxes + Select/Clear) is read-only and dimmed until genotypes are loaded, with an "upload a VCF" callout
prs_compute_button(state) Compute button with disclaimer callout
prs_progress_section(state) Progress bar and status text during computation
prs_results_table(state) Results table with quality badges, interpretation cards, and CSV download

The genotype source is loosely coupled to the PRS logic: a source pushes a normalized genotypes parquet into each consumer via the additive load_genotypes(path) hook (and optionally set_genome_build(build)), so a host app can replace vcf_source_section / GenomicGridState with its own source (public genome, consumer-array file, pre-normalized parquet) without touching PRSComputeStateMixin. VCF normalization (not upload) is the slow step; it is content-aware cached (a fresh normalized parquet is reused) and shown via an indeterminate progress bar.

State Mixin

PRSComputeStateMixin provides all PRS computation logic as a Reflex state mixin. Mix it into your concrete state class alongside LazyFrameGridMixin to get the full PRS workflow.

The preferred input method is a polars LazyFrame via set_prs_genotypes_lf() -- memory-efficient and avoids re-reading VCF files on each computation. A parquet path (prs_genotypes_path) is supported as a fallback.

Documentation

See the just-prs documentation for the full Python API, CLI reference, and integration guide.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prs_ui-0.3.13.tar.gz (153.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prs_ui-0.3.13-py3-none-any.whl (86.2 kB view details)

Uploaded Python 3

File details

Details for the file prs_ui-0.3.13.tar.gz.

File metadata

  • Download URL: prs_ui-0.3.13.tar.gz
  • Upload date:
  • Size: 153.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for prs_ui-0.3.13.tar.gz
Algorithm Hash digest
SHA256 ad8e2e388b0e88a08e97a6da7e97e5dc226fb5a0b43263d5f5dbad67eee0beb0
MD5 5956bb264875d92eff14af307a2a9063
BLAKE2b-256 314067c32cea04b373c8beb3a341f2ef1e9317ae91d6a12e9fcf550bba538801

See more details on using hashes here.

File details

Details for the file prs_ui-0.3.13-py3-none-any.whl.

File metadata

  • Download URL: prs_ui-0.3.13-py3-none-any.whl
  • Upload date:
  • Size: 86.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for prs_ui-0.3.13-py3-none-any.whl
Algorithm Hash digest
SHA256 5f6f548c61dd43742481fa9499a9fcf8a94f4169d0b77e8a90fe20263707a386
MD5 027b32adc62e2e04869dbf3b92731c13
BLAKE2b-256 76d7d301f0c24540d03d603fc34b3a8563c84a9ae504537a71ac63ff19240392

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page