Skip to content

Python

To install the latest release from PyPI:

pip install bedrock-bio

Load package:

import bedrock_bio as bb

List available namespaces and tables:

bb.list_namespaces()
bb.list_tables()

Lazily load a table (returns a DuckDBPyRelation object):

pqtls_tbl = bb.load_table('ukb_ppp.pqtls')

Filter columns and rows of lazy table using the DuckDB Relational API:

pqtls_tbl = (pqtls_tbl
    .filter(
        "ancestry = 'EUR'"
    )
    .filter(
        "protein_id = 'A0FGR8'"
    )
    .filter(
        "neg_log_10_p_value >= 7.30"  # p-value ~5e-8
    )
    .select(
        'chromosome',
        'position_grch38',
        'effect_allele',
        'other_allele',
        'beta',
        'neg_log_10_p_value'
    ))

Convert to Polars DataFrame (triggers data download):

pqtls_df = pqtls_tbl.pl()

Or, convert to Pandas DataFrame (also triggers download):

pqtls_df = pqtls_tbl.df()
Signature Description Returns
list_namespaces() List namespace identifiers. list[str]
`list_tables(namespace: str None = None)` List all tables, filtered to a namespace if specified.
describe_namespace(name: str) Inspect namespace metadata. dict
describe_table(name: str) Inspect table metadata. dict
load_table(name: str) Lazily load the specified table identifier. DuckDBPyRelation