graphld.parquet_io¶
I/O functions for Parquet format summary statistics.
Supports multi-trait parquet files with per-trait columns stored as {trait}_BETA and {trait}_SE.
For broader loading workflows, see the I/O and Merging guide.
parquet_io
¶
Functions for reading parquet summary statistics files.
This module supports the parquet format produced by linear_dag's GWAS pipeline, which stores summary statistics with columns like {trait}_BETA and {trait}_SE. Multiple traits can be stored in a single file.
get_parquet_traits
¶
Get list of trait names from a parquet summary statistics file.
A trait name is recognized if EITHER its _BETA or _SE column is present;
this is a discovery helper and does not guarantee the trait is complete.
read_parquet_sumstats is responsible for raising when a requested trait
lacks one of its halves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
Union[str, Path]
|
Path to parquet file |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of trait names found in the file |
Source code in src/graphld/parquet_io.py
read_parquet_sumstats
¶
read_parquet_sumstats(file: Union[str, Path], trait: Optional[str] = None, maximum_missingness: float = 1.0) -> pl.DataFrame
Read parquet summary statistics file and return a single-trait DataFrame.
The parquet format stores per-trait columns as {trait}_BETA and {trait}_SE.
This function extracts a single trait, computes Z = BETA / SE, and maps
recognized variant-info columns to the standard names used elsewhere in
GraphLD.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
Union[str, Path]
|
Path to parquet file. |
required |
trait
|
Optional[str]
|
Name of trait to extract. If None, uses the first trait found (after sorting trait names alphabetically). |
None
|
maximum_missingness
|
float
|
Maximum fraction of missing samples allowed, applied
as a per-row filter against the maximum observed |
1.0
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Polars DataFrame containing:
* |
DataFrame
|
Recognized input column aliases (case-sensitive): SNP via |
DataFrame
|
|
DataFrame
|
position via |
DataFrame
|
|
DataFrame
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file contains no |
Source code in src/graphld/parquet_io.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
read_parquet_sumstats_multi
¶
read_parquet_sumstats_multi(file: Union[str, Path], traits: Optional[list[str]] = None, maximum_missingness: float = 1.0) -> dict[str, pl.DataFrame]
Read multiple traits from a parquet summary statistics file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
Union[str, Path]
|
Path to parquet file. |
required |
traits
|
Optional[list[str]]
|
List of trait names to extract. If None, extracts every trait
discovered by |
None
|
maximum_missingness
|
float
|
Forwarded to |
1.0
|
Returns:
| Type | Description |
|---|---|
dict[str, DataFrame]
|
Dictionary mapping trait names to DataFrames produced by |
dict[str, DataFrame]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If any explicitly requested trait is not in the discovered
trait list, or if any selected trait is incomplete or the file
lacks a usable variant identifier (propagated from
|