admix-kit 0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- admix-kit-0.1/PKG-INFO +47 -0
- admix-kit-0.1/README.md +34 -0
- admix-kit-0.1/admix/__init__.py +17 -0
- admix-kit-0.1/admix/_logging.py +3 -0
- admix-kit-0.1/admix/ancestry/__init__.py +4 -0
- admix-kit-0.1/admix/ancestry/_local.py +107 -0
- admix-kit-0.1/admix/ancestry/_wrapper.py +48 -0
- admix-kit-0.1/admix/assoc/__init__.py +657 -0
- admix-kit-0.1/admix/assoc/_fast.py +118 -0
- admix-kit-0.1/admix/cli/__init__.py +42 -0
- admix-kit-0.1/admix/cli/_assoc.py +182 -0
- admix-kit-0.1/admix/cli/_ext.py +311 -0
- admix-kit-0.1/admix/cli/_genet_cor.py +620 -0
- admix-kit-0.1/admix/cli/_geno.py +474 -0
- admix-kit-0.1/admix/cli/_lanc.py +175 -0
- admix-kit-0.1/admix/cli/_plot.py +109 -0
- admix-kit-0.1/admix/cli/_simulate.py +182 -0
- admix-kit-0.1/admix/cli/_utils.py +273 -0
- admix-kit-0.1/admix/data/__init__.py +38 -0
- admix-kit-0.1/admix/data/_geno.py +684 -0
- admix-kit-0.1/admix/data/_lanc.py +817 -0
- admix-kit-0.1/admix/data/_misc.py +41 -0
- admix-kit-0.1/admix/data/_stats.py +236 -0
- admix-kit-0.1/admix/data/_utils.py +413 -0
- admix-kit-0.1/admix/dataset/__init__.py +6 -0
- admix-kit-0.1/admix/dataset/_dataset.py +390 -0
- admix-kit-0.1/admix/dataset/_index.py +141 -0
- admix-kit-0.1/admix/dataset/_load.py +400 -0
- admix-kit-0.1/admix/dataset/_utils.py +107 -0
- admix-kit-0.1/admix/estimate/__init__.py +5 -0
- admix-kit-0.1/admix/estimate/_admix_gen_cor.py +113 -0
- admix-kit-0.1/admix/estimate/_genetic_cor.py +120 -0
- admix-kit-0.1/admix/estimate/_utils.py +42 -0
- admix-kit-0.1/admix/estimate/_var_component.py +313 -0
- admix-kit-0.1/admix/io/__init__.py +10 -0
- admix-kit-0.1/admix/io/_read.py +398 -0
- admix-kit-0.1/admix/io/_write.py +138 -0
- admix-kit-0.1/admix/plot/__init__.py +14 -0
- admix-kit-0.1/admix/plot/_plot.py +625 -0
- admix-kit-0.1/admix/predict/__init__.py +27 -0
- admix-kit-0.1/admix/predict/_utils.py +1 -0
- admix-kit-0.1/admix/simulate/__init__.py +15 -0
- admix-kit-0.1/admix/simulate/_geno.py +290 -0
- admix-kit-0.1/admix/simulate/_lanc.py +135 -0
- admix-kit-0.1/admix/simulate/_pheno.py +455 -0
- admix-kit-0.1/admix/tools/__init__.py +22 -0
- admix-kit-0.1/admix/tools/_standalone.py +357 -0
- admix-kit-0.1/admix/tools/_utils.py +245 -0
- admix-kit-0.1/admix/tools/gcta.py +289 -0
- admix-kit-0.1/admix/tools/liftover.py +85 -0
- admix-kit-0.1/admix/tools/plink.py +136 -0
- admix-kit-0.1/admix/tools/plink2.py +557 -0
- admix-kit-0.1/admix/utils.py +47 -0
- admix-kit-0.1/admix/version.py +1 -0
- admix-kit-0.1/admix_kit.egg-info/PKG-INFO +47 -0
- admix-kit-0.1/admix_kit.egg-info/SOURCES.txt +62 -0
- admix-kit-0.1/admix_kit.egg-info/dependency_links.txt +1 -0
- admix-kit-0.1/admix_kit.egg-info/entry_points.txt +2 -0
- admix-kit-0.1/admix_kit.egg-info/requires.txt +15 -0
- admix-kit-0.1/admix_kit.egg-info/top_level.txt +1 -0
- admix-kit-0.1/pyproject.toml +3 -0
- admix-kit-0.1/setup.cfg +7 -0
- admix-kit-0.1/setup.py +44 -0
admix-kit-0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: admix-kit
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: Tool kits for analyzing genetics data of admixed population
|
|
5
|
+
Home-page: https://github.com/kangchenghou/admix-kit
|
|
6
|
+
Author: Kangcheng Hou
|
|
7
|
+
Author-email: kangchenghou@gmail.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Requires-Python: >=3.7
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# admix-kit
|
|
15
|
+

|
|
16
|
+
[](https://kangchenghou.github.io/admix-kit)
|
|
17
|
+
|
|
18
|
+
`admix-kit` is a Python library to facilitate analyses and methods development of genetics data from admixed populations.
|
|
19
|
+
|
|
20
|
+
> `admix-kit` is currently in beta version and frequently updating. We welcome any [feature requests or bug reports](https://github.com/KangchengHou/admix-kit/issues). Please ask us **"Can `admix-kit` do XX?"**. There is chance that some function has already been implemented but not well documented. We can prioritize more useful work if you let us know.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
```bash
|
|
25
|
+
# Install admix-kit with Python 3.7, 3.8, 3.9
|
|
26
|
+
git clone https://github.com/KangchengHou/admix-kit
|
|
27
|
+
cd admix-kit && pip install -e .
|
|
28
|
+
```
|
|
29
|
+
> Installation requires cmake version > 3.12. Use `cmake --version` to check your cmake version. Use `pip install cmake` to install the latest version.
|
|
30
|
+
|
|
31
|
+
> In some cases, `admix` may not be automatically to your `$PATH` (e.g., because of user installation mode). You need to look through the log and find where `admix` script is installed to and manually add that to your `$PATH` (e.g., type `PATH=$PATH:~/.local/bin`).
|
|
32
|
+
|
|
33
|
+
> To specify a version of admix-kit, use `git clone https://github.com/KangchengHou/admix-kit --branch v0.1`, or replace `v0.1` to other versions listed in https://github.com/KangchengHou/admix-kit/releases.
|
|
34
|
+
|
|
35
|
+
## Get started
|
|
36
|
+
- [Full documentation](https://kangchenghou.github.io/admix-kit/index.html)
|
|
37
|
+
- [Quick start (Python)](https://kangchenghou.github.io/admix-kit/notebooks/quickstart.html)
|
|
38
|
+
- [Application: Genetic correlation across local ancestry](https://kangchenghou.github.io/admix-kit/cli/genet-cor.html)
|
|
39
|
+
- [Application: GWAS in admixed populations](https://kangchenghou.github.io/admix-kit/cli/assoc-test.html)
|
|
40
|
+
|
|
41
|
+
## Use cases
|
|
42
|
+
The following manuscripts contain more motivation and details for functionalities within `admix-kit`:
|
|
43
|
+
|
|
44
|
+
1. [Admix-kit: An Integrated Toolkit and Pipeline for Genetic Analyses of Admixed Populations](https://www.biorxiv.org/content/10.1101/2023.09.30.560263v1). bioRxiv 2023
|
|
45
|
+
2. [Impact of cross-ancestry genetic architecture on GWASs in admixed populations](https://www.sciencedirect.com/science/article/pii/S0002929723001581). AJHG 2023
|
|
46
|
+
3. [Causal effects on complex traits are similar for common variants across segments of different continental ancestries within admixed individuals](https://www.nature.com/articles/s41588-023-01338-6). Nature Genetics 2023
|
|
47
|
+
4. [On powerful GWAS in admixed populations](https://www.nature.com/articles/s41588-021-00953-5). Nature Genetics 2021
|
admix-kit-0.1/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# admix-kit
|
|
2
|
+

|
|
3
|
+
[](https://kangchenghou.github.io/admix-kit)
|
|
4
|
+
|
|
5
|
+
`admix-kit` is a Python library to facilitate analyses and methods development of genetics data from admixed populations.
|
|
6
|
+
|
|
7
|
+
> `admix-kit` is currently in beta version and frequently updating. We welcome any [feature requests or bug reports](https://github.com/KangchengHou/admix-kit/issues). Please ask us **"Can `admix-kit` do XX?"**. There is chance that some function has already been implemented but not well documented. We can prioritize more useful work if you let us know.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
```bash
|
|
12
|
+
# Install admix-kit with Python 3.7, 3.8, 3.9
|
|
13
|
+
git clone https://github.com/KangchengHou/admix-kit
|
|
14
|
+
cd admix-kit && pip install -e .
|
|
15
|
+
```
|
|
16
|
+
> Installation requires cmake version > 3.12. Use `cmake --version` to check your cmake version. Use `pip install cmake` to install the latest version.
|
|
17
|
+
|
|
18
|
+
> In some cases, `admix` may not be automatically to your `$PATH` (e.g., because of user installation mode). You need to look through the log and find where `admix` script is installed to and manually add that to your `$PATH` (e.g., type `PATH=$PATH:~/.local/bin`).
|
|
19
|
+
|
|
20
|
+
> To specify a version of admix-kit, use `git clone https://github.com/KangchengHou/admix-kit --branch v0.1`, or replace `v0.1` to other versions listed in https://github.com/KangchengHou/admix-kit/releases.
|
|
21
|
+
|
|
22
|
+
## Get started
|
|
23
|
+
- [Full documentation](https://kangchenghou.github.io/admix-kit/index.html)
|
|
24
|
+
- [Quick start (Python)](https://kangchenghou.github.io/admix-kit/notebooks/quickstart.html)
|
|
25
|
+
- [Application: Genetic correlation across local ancestry](https://kangchenghou.github.io/admix-kit/cli/genet-cor.html)
|
|
26
|
+
- [Application: GWAS in admixed populations](https://kangchenghou.github.io/admix-kit/cli/assoc-test.html)
|
|
27
|
+
|
|
28
|
+
## Use cases
|
|
29
|
+
The following manuscripts contain more motivation and details for functionalities within `admix-kit`:
|
|
30
|
+
|
|
31
|
+
1. [Admix-kit: An Integrated Toolkit and Pipeline for Genetic Analyses of Admixed Populations](https://www.biorxiv.org/content/10.1101/2023.09.30.560263v1). bioRxiv 2023
|
|
32
|
+
2. [Impact of cross-ancestry genetic architecture on GWASs in admixed populations](https://www.sciencedirect.com/science/article/pii/S0002929723001581). AJHG 2023
|
|
33
|
+
3. [Causal effects on complex traits are similar for common variants across segments of different continental ancestries within admixed individuals](https://www.nature.com/articles/s41588-023-01338-6). Nature Genetics 2023
|
|
34
|
+
4. [On powerful GWAS in admixed populations](https://www.nature.com/articles/s41588-021-00953-5). Nature Genetics 2021
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from ._logging import logger
|
|
2
|
+
from .dataset import Dataset
|
|
3
|
+
from . import data, dataset, simulate, ancestry, plot, assoc, estimate, tools, io, cli
|
|
4
|
+
from .version import __version__
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
"data",
|
|
8
|
+
"simulate",
|
|
9
|
+
"ancestry",
|
|
10
|
+
"plot",
|
|
11
|
+
"assoc",
|
|
12
|
+
"estimate",
|
|
13
|
+
"tools",
|
|
14
|
+
"io",
|
|
15
|
+
"cli",
|
|
16
|
+
"Dataset",
|
|
17
|
+
]
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from typing import List
|
|
3
|
+
import admix
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
This will be the interface to call various local ancestry inference methods
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def lanc_single_chrom(
|
|
11
|
+
sample_dset: admix.Dataset,
|
|
12
|
+
ref_dsets: List[admix.Dataset],
|
|
13
|
+
method="lampld",
|
|
14
|
+
n_proto=6,
|
|
15
|
+
window_size=300,
|
|
16
|
+
):
|
|
17
|
+
"""Local ancestry inference for data sets of single chromosome
|
|
18
|
+
|
|
19
|
+
Parameters
|
|
20
|
+
----------
|
|
21
|
+
sample_dset : admix.Dataset
|
|
22
|
+
dataset of the sample to be inferred
|
|
23
|
+
ref_dsets : List[admix.Dataset]
|
|
24
|
+
dataset of the reference panel
|
|
25
|
+
method : str, optional
|
|
26
|
+
method used to perform local ancestry inference, by default "lampld"
|
|
27
|
+
n_proto : int, optional
|
|
28
|
+
number of prototypes used in lampld, by default 6
|
|
29
|
+
window_size : int, optional
|
|
30
|
+
"""
|
|
31
|
+
from pylampld import LampLD
|
|
32
|
+
|
|
33
|
+
assert method in ["lampld"]
|
|
34
|
+
assert len(sample_dset.snp.CHROM.unique()), "Datasets are not of single chromosome"
|
|
35
|
+
assert admix.dataset.is_aligned(
|
|
36
|
+
[sample_dset, *ref_dsets]
|
|
37
|
+
), "Datasets are not aligned"
|
|
38
|
+
|
|
39
|
+
n_anc = len(ref_dsets)
|
|
40
|
+
n_snp = sample_dset.n_snp
|
|
41
|
+
|
|
42
|
+
model = LampLD(n_snp=n_snp, n_anc=n_anc, n_proto=n_proto, window_size=window_size)
|
|
43
|
+
ref_list = [
|
|
44
|
+
np.vstack(
|
|
45
|
+
[
|
|
46
|
+
dset.geno[:, :, 0].T,
|
|
47
|
+
dset.geno[:, :, 1].T,
|
|
48
|
+
]
|
|
49
|
+
)
|
|
50
|
+
for dset in ref_dsets
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
model.set_pos(sample_dset.snp.POS.values)
|
|
54
|
+
model.fit(ref_list)
|
|
55
|
+
|
|
56
|
+
est = np.dstack(
|
|
57
|
+
[
|
|
58
|
+
model.infer_lanc(sample_dset.geno[:, :, 0].T.compute()),
|
|
59
|
+
model.infer_lanc(sample_dset.geno[:, :, 1].T.compute()),
|
|
60
|
+
]
|
|
61
|
+
)
|
|
62
|
+
return np.swapaxes(est.astype(np.int8), 0, 1)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def lanc(
|
|
66
|
+
sample_dset: admix.Dataset,
|
|
67
|
+
ref_dsets: List[admix.Dataset],
|
|
68
|
+
method="lampld",
|
|
69
|
+
n_proto=6,
|
|
70
|
+
window_size=300,
|
|
71
|
+
) -> np.ndarray:
|
|
72
|
+
"""Local ancestry inference
|
|
73
|
+
|
|
74
|
+
Parameters
|
|
75
|
+
----------
|
|
76
|
+
sample_dset : admix.Dataset
|
|
77
|
+
dataset of the sample to be inferred
|
|
78
|
+
ref_dsets : List[admix.Dataset]
|
|
79
|
+
dataset of the reference panel
|
|
80
|
+
method : str, optional
|
|
81
|
+
method used to perform local ancestry inference, by default "lampld"
|
|
82
|
+
n_proto : int, optional
|
|
83
|
+
number of prototypes used in lampld, by default 6
|
|
84
|
+
window_size : int, optional
|
|
85
|
+
window size used in local ancestry inference, by default 100
|
|
86
|
+
|
|
87
|
+
Returns
|
|
88
|
+
-------
|
|
89
|
+
np.ndarray
|
|
90
|
+
Estimated local ancestries
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
assert method in ["lampld"]
|
|
94
|
+
chrom_list = sample_dset.snp.CHROM.unique()
|
|
95
|
+
lanc = []
|
|
96
|
+
for chrom in chrom_list:
|
|
97
|
+
chrom_sample_dset = sample_dset[(sample_dset.snp.CHROM == chrom).values]
|
|
98
|
+
chrom_ref_dsets = [dset[(dset.snp.CHROM == chrom).values] for dset in ref_dsets]
|
|
99
|
+
chrom_lanc = lanc_single_chrom(
|
|
100
|
+
chrom_sample_dset,
|
|
101
|
+
chrom_ref_dsets,
|
|
102
|
+
method=method,
|
|
103
|
+
n_proto=n_proto,
|
|
104
|
+
window_size=window_size,
|
|
105
|
+
)
|
|
106
|
+
lanc.append(chrom_lanc)
|
|
107
|
+
return np.concatenate(lanc, axis=0)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import tempfile
|
|
4
|
+
from os.path import join
|
|
5
|
+
import subprocess
|
|
6
|
+
from ..io import read_digit_mat, write_digit_mat
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def lampld_wrapper(
|
|
10
|
+
ref_hap_list,
|
|
11
|
+
sample_hap,
|
|
12
|
+
snp_pos,
|
|
13
|
+
window_size=300,
|
|
14
|
+
n_proto=6,
|
|
15
|
+
bin_dir="/u/project/pasaniuc/kangchen/admix-tools/cache/LAMPLD-v1.3/bin/",
|
|
16
|
+
):
|
|
17
|
+
tmp = tempfile.TemporaryDirectory()
|
|
18
|
+
tmp_dir = tmp.name
|
|
19
|
+
|
|
20
|
+
assert len(ref_hap_list) in [2, 3], "Currently only support 2-way / 3-way ancestry"
|
|
21
|
+
for ref_i in range(len(ref_hap_list)):
|
|
22
|
+
write_digit_mat(join(tmp_dir, f"ref{ref_i}.hap"), ref_hap_list[ref_i])
|
|
23
|
+
write_digit_mat(join(tmp_dir, "sample.hap"), sample_hap)
|
|
24
|
+
np.savetxt(join(tmp_dir, "pos.txt"), snp_pos, fmt="%s")
|
|
25
|
+
|
|
26
|
+
if len(ref_hap_list) == 2:
|
|
27
|
+
bin_path = join(bin_dir, "haplanc2way")
|
|
28
|
+
elif len(ref_hap_list) == 3:
|
|
29
|
+
bin_path = join(bin_dir, "haplanc")
|
|
30
|
+
else:
|
|
31
|
+
raise NotImplementedError
|
|
32
|
+
cmd = " ".join(
|
|
33
|
+
[
|
|
34
|
+
bin_path,
|
|
35
|
+
str(window_size),
|
|
36
|
+
str(n_proto),
|
|
37
|
+
join(tmp_dir, "pos.txt"),
|
|
38
|
+
*[join(tmp_dir, f"ref{ref_i}.hap") for ref_i in range(len(ref_hap_list))],
|
|
39
|
+
join(tmp_dir, "sample.hap"),
|
|
40
|
+
join(tmp_dir, "out.txt"),
|
|
41
|
+
str(1),
|
|
42
|
+
]
|
|
43
|
+
)
|
|
44
|
+
print(cmd)
|
|
45
|
+
subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
|
|
46
|
+
infer_lanc = read_digit_mat(join(tmp_dir, "out.txt"))
|
|
47
|
+
tmp.cleanup()
|
|
48
|
+
return infer_lanc
|