Port of PopGen MATLAB backend
Project description
PyPopGenBE
PyPopGenBE is a port of the PopGen MATLAB backend reported in McNally et al., 2014.
Getting Started
Install the package from pypi.org:
$ python3 -m pip install pypopgenbe
From a Python prompt, sample 10 individuals, and list their heights and liver masses:
>>> from pypopgenbe import Dataset, generate_pop
>>> population, number_of_individuals_discarded = generate_pop(
population_size=10,
dataset_name=Dataset.P3M,
age_range=(18, 60),
bmi_range=(20, 25),
height_range=(100, 150),
prob_of_male=0.5,
probs_of_ethnicities=(0.3, 0.4, 0.3),
is_richly_perfused_tissue_discrete=[
False,
False,
False,
True, # kidneys
False,
True, # liver
False,
False,
False,
False
],
is_slowly_perfused_tissue_discrete=[
True, # adipose
False,
False,
False
],
seed=42,
)
>>> population['Roots']['Names']
['Age', 'Sex', 'Ethnicity', 'Body Mass', 'Height', 'Cardiac Output']
>>> heights = population['Roots']['Values'][:,4]
>>> heights
array([161.73342684, 162.40729026, 156.1832546, 151.2041105, 164.37847922, 163.77112667, 158.80653778, 152.14851135, 155.82766881, 157.63376385])
>>> population['Tissues']['Names']
['Lung', 'Kidneys', 'Liver', 'Adipose', 'Liver Total', 'Slowly Perfused', 'Richly Perfused', 'Lung Bronchial']
>>> population['Tissues']['Properties']
['Mass', 'Flow']
>>> liver_masses = population['Tissues']['Values'][:,2][:,0]
>>> liver_masses
array([2.58117028, 2.83772054, 1.6478209, 2.1865733, 2.41184484, 1.90865662, 2.10913417, 1.7031989, 1.06043036, 2.60443474])
Export the population data to CSV:
>>> from pypopgenbe import pop_to_csv
>>> csv = pop_to_csv(population)
>>> import os
>>> with open("./test.csv", "w") as f:
f.writelines(line + os.linesep for line in csv)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pypopgenbe-1.5.5.tar.gz
(33.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pypopgenbe-1.5.5.tar.gz.
File metadata
- Download URL: pypopgenbe-1.5.5.tar.gz
- Upload date:
- Size: 33.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f4f203e525b2155b6533135f2de95e3059b3596c6b63c23da17f32aa4786525
|
|
| MD5 |
96517db65bbec16d3993c58beefda9f8
|
|
| BLAKE2b-256 |
2da3eb924e26a5e08ab2d312220d80443176bea79ac66651b87a3c697d346316
|
File details
Details for the file pypopgenbe-1.5.5-py3-none-any.whl.
File metadata
- Download URL: pypopgenbe-1.5.5-py3-none-any.whl
- Upload date:
- Size: 42.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c456c33f2bc76079381f134d881c4e40a6cf89a0b74f44322375d044b36b74a
|
|
| MD5 |
ec41aaf9663955bf2cad986dacd69231
|
|
| BLAKE2b-256 |
e3f10ea026383d18e85c7df35d6c13bb684300b78b6010327ac75639dea2263f
|