I/O¶
Classes and functions for reading input data and writing results.
io
¶
CVData
¶
Define the cross validation data object.
Attributes:
| Name | Type | Description |
|---|---|---|
train_geno |
list[Array]
|
genotype data for training SuShiE weights. |
train_pheno |
list[Array]
|
phenotype data for training SuShiE weights. |
valid_geno |
list[Array]
|
genotype data for validating SuShiE weights. |
valid_pheno |
list[Array]
|
phenotype data for validating SuShiE weights. |
CleanData
¶
RawData
¶
Define the raw data object for the future data cleaning.
Attributes:
| Name | Type | Description |
|---|---|---|
bim |
DataFrame
|
SNP information data. |
fam |
DataFrame
|
individual information data. |
bed |
Array
|
actual genotype data. |
pheno |
DataFrame
|
phenotype data. |
covar |
PDOrNone
|
covariate needed to be adjusted in the inference. |
read_data
¶
read_data(
n_pop: int,
ancestry_index: DataFrame,
pheno_paths: list[str],
covar_paths: ListStrOrNone,
geno_paths: list[str],
geno_func: Callable[
[str], tuple[DataFrame, DataFrame, Array]
],
) -> list[RawData]
Read in pheno, covar, and genotype data and convert it to raw data object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_pop
|
int
|
The int to indicate the number of ancestries. |
required |
ancestry_index
|
DataFrame
|
The DataFrame that contains ancestry index. |
required |
pheno_paths
|
list[str]
|
The path for phenotype data across ancestries. |
required |
covar_paths
|
ListStrOrNone
|
The path for covariates data across ancestries. |
required |
geno_paths
|
list[str]
|
The path for genotype data across ancestries. |
required |
geno_func
|
Callable[[str], tuple[DataFrame, DataFrame, Array]]
|
The function to read in genotypes depending on the format. |
required |
Returns:
| Type | Description |
|---|---|
list[RawData]
|
|
Source code in sushie/io.py
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 192 193 194 195 | |
read_triplet
¶
Read in genotype data in plink 1 format. genoio package is used to read in the plink file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The path for plink genotype data (suffix only). |
required |
Returns:
| Type | Description |
|---|---|
tuple[DataFrame, DataFrame, Array]
|
|
Source code in sushie/io.py
read_pfile
¶
Read genotype data in plink 2 format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The path for plink 2 genotype data (prefix only). |
required |
dosage
|
bool
|
Read dosage values instead of hard calls. |
False
|
Returns:
| Type | Description |
|---|---|
tuple[DataFrame, DataFrame, Array]
|
|
Source code in sushie/io.py
read_bgen
¶
Read in genotype data in bgen 1.3 format. genoio package is used to read in the bgen file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The path for bgen genotype data (full file name). |
required |
Returns:
| Type | Description |
|---|---|
tuple[DataFrame, DataFrame, Array]
|
|
Source code in sushie/io.py
read_vcf
¶
Read in genotype data in vcf format. genoio package is used to read in the vcf file. Missing genotypes are coded as NA.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The path for vcf genotype data (full file name). It will count ALT allele. |
required |
Returns:
| Type | Description |
|---|---|
tuple[DataFrame, DataFrame, Array]
|
|
Source code in sushie/io.py
read_gwas
¶
read_gwas(
path: str,
header: list[str],
chrom: IntOrNone,
start: IntOrNone,
end: IntOrNone,
) -> DataFrame
Read in GWAS data in tsv file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The path for GWAS data (full file name). |
required |
header
|
list[str]
|
The header for GWAS data. |
required |
chrom
|
IntOrNone
|
The chromosome number. |
required |
start
|
IntOrNone
|
The start position. |
required |
end
|
IntOrNone
|
The end position. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Source code in sushie/io.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | |
read_ld
¶
read_ld(path: str) -> DataFrame
Read in LD (linkage disequilibrium) matrix from a TSV file.
The LD matrix should be a symmetric correlation matrix where rows and columns represent SNPs. The file should be tab-separated with SNP IDs as column headers. Rows with infinite or NaN values are automatically removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The path to the LD matrix file (tab-separated, .tsv format). |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Example
Read an LD matrix for fine-mapping:
Note
The LD matrix must be computed using the same reference alleles as the GWAS summary statistics for correct fine-mapping results.
Source code in sushie/io.py
output_cs
¶
output_cs(
result: list[SushieResult],
meta_pip: list[Array] | None,
snps: DataFrame,
output: str,
trait: str,
compress: bool,
method_type: str,
) -> DataFrame
Output credible set (after pruning for purity) file *cs.tsv
(see credible-set output).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
list[SushieResult]
|
The sushie inference result. |
required |
meta_pip
|
list[Array] | None
|
The meta-analyzed PIPs from Meta SuShiE. |
required |
snps
|
DataFrame
|
The SNP information table. |
required |
output
|
str
|
The output file prefix. |
required |
trait
|
str
|
The trait name better for post-hoc analysis index. |
required |
compress
|
bool
|
The indicator whether to compress the output files. |
required |
method_type
|
str
|
Which method the result belongs to: sushie, mega, or meta. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Source code in sushie/io.py
output_alphas
¶
output_alphas(
result: list[SushieResult],
snps: DataFrame,
output: str,
trait: str,
compress: bool,
method_type: str,
purity: float,
) -> DataFrame
Output full credible set (before pruning for purity) file *alphas.tsv
(see full credible-set output).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
list[SushieResult]
|
The sushie inference result. |
required |
snps
|
DataFrame
|
The SNP information table. |
required |
output
|
str
|
The output file prefix. |
required |
trait
|
str
|
The trait name better for post-hoc analysis index. |
required |
compress
|
bool
|
The indicator whether to compress the output files. |
required |
method_type
|
str
|
Which method the result belongs to: sushie, mega, or meta. |
required |
purity
|
float
|
The purity threshold. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Source code in sushie/io.py
output_weights
¶
output_weights(
result: list[SushieResult],
meta_pip: list[Array] | None,
snps: DataFrame,
output: str,
trait: str,
compress: bool,
method_type: str,
) -> DataFrame
Output prediction weights file *weights.tsv (see prediction-weight output).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
list[SushieResult]
|
The sushie inference result. |
required |
meta_pip
|
list[Array] | None
|
The meta-analyzed PIPs from Meta SuShiE. |
required |
snps
|
DataFrame
|
The SNP information table. |
required |
output
|
str
|
The output file prefix. |
required |
trait
|
str
|
The trait name better for post-hoc analysis index. |
required |
compress
|
bool
|
The indicator whether to compress the output files. |
required |
method_type
|
str
|
Which method the result belongs to: sushie, mega, or meta. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Source code in sushie/io.py
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 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | |
output_her
¶
Output heritability estimation file *her.tsv (see heritability output).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
CleanData
|
The clean data that are used to estimate traits' heritability. |
required |
output
|
str
|
The output file prefix. |
required |
trait
|
str
|
The trait name better for post-hoc analysis index. |
required |
compress
|
bool
|
The indicator whether to compress the output files. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Source code in sushie/io.py
output_corr
¶
output_corr(
result: list[SushieResult],
output: str,
trait: str,
compress: bool,
) -> DataFrame
Output effect size correlation file *corr.tsv
(see effect-size correlation output).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
list[SushieResult]
|
The sushie inference result. |
required |
output
|
str
|
The output file prefix. |
required |
trait
|
str
|
The trait name better for post-hoc analysis index. |
required |
compress
|
bool
|
The indicator whether to compress the output files. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Source code in sushie/io.py
output_cv
¶
output_cv(
cv_res: list,
sample_size: list[int],
output: str,
trait: str,
compress: bool,
) -> DataFrame
Output cross validation file *cv.tsv for
future FUSION pipeline
(see cross-validation output).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cv_res
|
list
|
The cross-validation result (adjusted \(r^2\) and corresponding \(p\) values). |
required |
sample_size
|
list[int]
|
The sample size for the SuShiE inference. |
required |
output
|
str
|
The output file prefix. |
required |
trait
|
str
|
The trait name better for post-hoc analysis index. |
required |
compress
|
bool
|
The indicator whether to compress the output files. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Source code in sushie/io.py
output_numpy
¶
output_numpy(
result: list[SushieResult], snps: DataFrame, output: str
) -> None
Output all results in *.npy file (no compress option) (see NumPy output).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
list[SushieResult]
|
The sushie inference result. |
required |
snps
|
DataFrame
|
The SNP information |
required |
output
|
str
|
The output file prefix. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|