-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* export key functions for sorting chromosomes / effect types * use new key functions for sorting * reduce memory usage during aggregation * fix doctest output * make aggregation steps clearer
- Loading branch information
Showing
16 changed files
with
216 additions
and
86 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
from .aggregate_cli import run_aggregate | ||
|
||
__all__ = ["run_aggregate"] | ||
__all__ = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" This module assumes you're working with paths that follow the format: | ||
{sampleset}_{chrom}_{effect_type}_{n} | ||
""" | ||
from natsort import natsort_keygen, ns | ||
|
||
|
||
def effect_type_keyfunc(): | ||
"""Return a key that sorts by effect type and n. Chromosome order doesn't matter. | ||
This is useful for things like itertools.groupby which expect sorted input | ||
>>> import pathlib | ||
>>> paths = [pathlib.Path("ukb_2_dominant_0.txt.gz"), pathlib.Path("ukb_X_additive_0.txt.gz"), pathlib.Path("ukb_X_additive_1.txt.gz"), pathlib.Path("ukb_1_recessive_0.txt.gz")] | ||
>>> sorted(paths, key=effect_type_keyfunc()) | ||
[PosixPath('ukb_X_additive_0.txt.gz'), PosixPath('ukb_X_additive_1.txt.gz'), PosixPath('ukb_2_dominant_0.txt.gz'), PosixPath('ukb_1_recessive_0.txt.gz')] | ||
""" | ||
return natsort_keygen(key=lambda x: x.stem.split("_")[2:], alg=ns.REAL) | ||
|
||
|
||
def chrom_keyfunc(): | ||
"""Return a key that sorts by chromosome, including non-integer chromosomes | ||
>>> import pathlib | ||
>>> paths = [pathlib.Path("ukb_2_additive_0.txt.gz"), pathlib.Path("ukb_X_additive_0.txt.gz"), pathlib.Path("ukb_1_additive_0.txt.gz")] | ||
>>> sorted(paths, key=chrom_keyfunc()) | ||
[PosixPath('ukb_1_additive_0.txt.gz'), PosixPath('ukb_2_additive_0.txt.gz'), PosixPath('ukb_X_additive_0.txt.gz')] | ||
""" | ||
return natsort_keygen(key=lambda x: x.stem.split("_")[1], alg=ns.REAL) |
Oops, something went wrong.