Sumstats parsers
COJOSSParser
¶
Bases: SumstatsParser
A specialized class for parsing GWAS summary statistics files generated by the COJO software.
Attributes:
| Name | Type | Description |
|---|---|---|
col_name_converter |
A dictionary mapping column names in the original table to magenpy's column names. |
|
read_csv_kwargs |
Keyword arguments to pass to pandas' |
Source code in magenpy/parsers/sumstats_parsers.py
__init__(col_name_converter=None, **read_csv_kwargs)
¶
Initialize the COJO summary statistics parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
col_name_converter
|
A dictionary/string mapping column names in the original table to magenpy's column names for the various summary statistics. If a string, it should be a comma-separated list of key-value pairs (e.g. 'rsid=SNP,pos=POS'). |
None
|
|
read_csv_kwargs
|
Keyword arguments to pass to pandas' read_csv |
{}
|
Source code in magenpy/parsers/sumstats_parsers.py
FastGWASSParser
¶
Bases: SumstatsParser
A specialized class for parsing GWAS summary statistics files generated by the FastGWA software.
Attributes:
| Name | Type | Description |
|---|---|---|
col_name_converter |
A dictionary mapping column names in the original table to magenpy's column names. |
|
read_csv_kwargs |
Keyword arguments to pass to pandas' |
Source code in magenpy/parsers/sumstats_parsers.py
__init__(col_name_converter=None, **read_csv_kwargs)
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
col_name_converter
|
A dictionary/string mapping column names in the original table to magenpy's column names for the various summary statistics. If a string, it should be a comma-separated list of key-value pairs (e.g. 'rsid=SNP,pos=POS'). |
None
|
|
read_csv_kwargs
|
Keyword arguments to pass to pandas' read_csv |
{}
|
Source code in magenpy/parsers/sumstats_parsers.py
Plink1SSParser
¶
Bases: SumstatsParser
A specialized class for parsing GWAS summary statistics files generated by plink1.9.
Attributes:
| Name | Type | Description |
|---|---|---|
col_name_converter |
A dictionary mapping column names in the original table to magenpy's column names. |
|
read_csv_kwargs |
Keyword arguments to pass to pandas' |
Source code in magenpy/parsers/sumstats_parsers.py
__init__(col_name_converter=None, **read_csv_kwargs)
¶
Initialize the plink1.9 summary statistics parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
col_name_converter
|
A dictionary/string mapping column names in the original table to magenpy's column names for the various summary statistics. If a string, it should be a comma-separated list of key-value pairs (e.g. 'rsid=SNP,pos=POS'). |
None
|
|
read_csv_kwargs
|
Keyword arguments to pass to pandas' read_csv |
{}
|
Source code in magenpy/parsers/sumstats_parsers.py
Plink2SSParser
¶
Bases: SumstatsParser
A specialized class for parsing GWAS summary statistics files generated by plink2.
Attributes:
| Name | Type | Description |
|---|---|---|
col_name_converter |
A dictionary mapping column names in the original table to magenpy's column names. |
|
read_csv_kwargs |
Keyword arguments to pass to pandas' |
Source code in magenpy/parsers/sumstats_parsers.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
__init__(col_name_converter=None, **read_csv_kwargs)
¶
Initialize the plink2 summary statistics parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
col_name_converter
|
A dictionary/string mapping column names in the original table to magenpy's column names for the various summary statistics. If a string, it should be a comma-separated list of key-value pairs (e.g. 'rsid=SNP,pos=POS'). |
None
|
|
read_csv_kwargs
|
Keyword arguments to pass to pandas' read_csv |
{}
|
Source code in magenpy/parsers/sumstats_parsers.py
parse(file_name, drop_na=True)
¶
Parse a summary statistics file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_name
|
The path to the summary statistics file. |
required | |
drop_na
|
Drop any entries with missing values. |
True
|
Returns:
| Type | Description |
|---|---|
|
A pandas DataFrame containing the parsed summary statistics. |
Source code in magenpy/parsers/sumstats_parsers.py
SSFParser
¶
Bases: SumstatsParser
A specialized class for parsing GWAS summary statistics that are formatted according
to the standardized summary statistics format adopted by the GWAS Catalog. This format is
sometimes denoted as GWAS-SSF.
Reference and details: https://github.com/EBISPOT/gwas-summary-statistics-standard
Attributes:
| Name | Type | Description |
|---|---|---|
col_name_converter |
A dictionary mapping column names in the original table to magenpy's column names. |
|
read_csv_kwargs |
Keyword arguments to pass to pandas' |
Source code in magenpy/parsers/sumstats_parsers.py
__init__(col_name_converter=None, **read_csv_kwargs)
¶
Initialize the standardized summary statistics parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
col_name_converter
|
A dictionary/string mapping column names in the original table to magenpy's column names for the various summary statistics. If a string, it should be a comma-separated list of key-value pairs (e.g. 'rsid=SNP,pos=POS'). |
None
|
|
read_csv_kwargs
|
Keyword arguments to pass to pandas' read_csv |
{}
|
Source code in magenpy/parsers/sumstats_parsers.py
SaigeSSParser
¶
Bases: SumstatsParser
A specialized class for parsing GWAS summary statistics files generated by the SAIGE software.
Reference and details:
https://saigegit.github.io/SAIGE-doc/docs/single_step2.html
TODO: Ensure that the column names are correct across different trait types and the inference of the sample size is correct.
Attributes:
| Name | Type | Description |
|---|---|---|
col_name_converter |
A dictionary mapping column names in the original table to magenpy's column names. |
|
read_csv_kwargs |
Keyword arguments to pass to pandas' |
Source code in magenpy/parsers/sumstats_parsers.py
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | |
__init__(col_name_converter=None, **read_csv_kwargs)
¶
Initialize the SAIGE summary statistics parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
col_name_converter
|
A dictionary/string mapping column names in the original table to magenpy's column names for the various summary statistics. If a string, it should be a comma-separated list of key-value pairs (e.g. 'rsid=SNP,pos=POS'). |
None
|
|
read_csv_kwargs
|
Keyword arguments to pass to pandas' read_csv |
{}
|
Source code in magenpy/parsers/sumstats_parsers.py
parse(file_name, drop_na=True)
¶
Parse the summary statistics file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_name
|
The path to the summary statistics file. |
required | |
drop_na
|
Drop any entries with missing values. |
True
|
Returns:
| Type | Description |
|---|---|
|
A pandas DataFrame containing the parsed summary statistics. |
Source code in magenpy/parsers/sumstats_parsers.py
SumstatsParser
¶
Bases: object
A wrapper class for parsing summary statistics files that are written by statistical genetics software for Genome-wide Association testing. A common challenge is the fact that different software tools output summary statistics in different formats and with different column names. Thus, this class provides a common interface for parsing summary statistics files from different software tools and aims to make this process as seamless as possible.
The class is designed to be extensible, so that users can easily add new parsers for different software tools.
Attributes:
| Name | Type | Description |
|---|---|---|
col_name_converter |
A dictionary mapping column names in the original table to magenpy's column names. |
|
read_csv_kwargs |
Keyword arguments to pass to pandas' |
Source code in magenpy/parsers/sumstats_parsers.py
39 40 41 42 43 44 45 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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
__init__(col_name_converter=None, **read_csv_kwargs)
¶
Initialize the summary statistics parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
col_name_converter
|
A dictionary/string mapping column names in the original table to magenpy's column names for the various summary statistics. If a string, it should be a comma-separated list of key-value pairs (e.g. 'rsid=SNP,pos=POS'). |
None
|
|
read_csv_kwargs
|
Keyword arguments to pass to pandas' read_csv |
{}
|
Source code in magenpy/parsers/sumstats_parsers.py
drop_na_from_essential_cols(df)
classmethod
¶
Drop rows with missing values in columns that are essential for variant identity and effect-size interpretation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
A pandas DataFrame containing summary statistics. |
required |
Returns:
| Type | Description |
|---|---|
|
A DataFrame with missing essential values removed. |
Source code in magenpy/parsers/sumstats_parsers.py
format_table(df)
classmethod
¶
Format a magenpy summary statistics table for output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
A pandas DataFrame with magenpy-standard column names. |
required |
Returns:
| Type | Description |
|---|---|
|
A DataFrame with format-specific column names. |
Source code in magenpy/parsers/sumstats_parsers.py
get_essential_col_groups()
classmethod
¶
Essential columns are encoded as groups of alternatives. Each group must be satisfied by at least one of its alternatives.
Returns:
| Type | Description |
|---|---|
|
A tuple of essential column alternative groups. |
Source code in magenpy/parsers/sumstats_parsers.py
get_essential_cols(columns)
classmethod
¶
Resolve the essential column groups against a concrete set of columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
columns
|
The available columns in a summary statistics table. |
required |
Returns:
| Type | Description |
|---|---|
|
A list of essential columns present in the table. |
Source code in magenpy/parsers/sumstats_parsers.py
get_standard_cols()
classmethod
¶
Returns:
| Type | Description |
|---|---|
|
The standard magenpy columns for this summary statistics format. |
parse(file_name, drop_na=True)
¶
Parse a summary statistics file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_name
|
The path to the summary statistics file. |
required | |
drop_na
|
If True, drop any entries with missing values. |
True
|
Returns:
| Type | Description |
|---|---|
|
A pandas DataFrame containing the parsed summary statistics. |
Source code in magenpy/parsers/sumstats_parsers.py
get_sumstats_parser(sumstats_format)
¶
Get the parser class for a supported summary statistics format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sumstats_format
|
The summary statistics format name or alias. |
required |
Returns:
| Type | Description |
|---|---|
|
A SumstatsParser subclass. |