Skip to main content

Determine number of principle components based on sequencing data

Project description

ERstruct - Official Python Implementation

A Python package for inferring the number of top informative PCs that capture population structure based on genotype information.

Requirements for Data File

Data files must be of .npy format. The data matrix must with 0,1,2 and/or NaN (for missing values) entries only, the rows represent individuals and columns represent markers. If there are more than one data files, the data matrix inside must with the same number of rows.

Dependencies

ERStruct depends on numpy, torch and joblib.

Installation

Users can install ERStruct by running the command below in command line:

pip install ERStruct

Parameters

erstruct(n, path, rep, alpha, cpu_num=1, device_idx="cpu", varm=1, Kc=-1)

n (int) - total number of individuals in the study

path (str) - the path of data file(s)

filename (list) - the name of the data file(s)

rep (int) - number of simulation times for the null distribution

alpha (float) - significance level, can be either a scaler or a vector

Kc (int) - a coarse estimate of the top PCs number (set to -1 by default)

cpu_num (int) - optional, number of CPU cores to be used for parallel computing. (set to 1 by default)

device_idx (str) - device you are using, "cpu" pr "gpu". (set to "cpu" by default)

varm (int): - Allocated memory (in bytes) of GPUs for computing. When device_idx is set to "gpu", the varm parameter can be specified to increase the computational speed by allocating the required amount of memory (in bytes) to the GPU. (set to 2e+8 by default)

Examples

Download sample dataset:

from ERStruct import download_sample
download_sample()

Import ERStruct algorithm

from ERStruct import erstruct

Run ERStruct algorithm on sample dataset with CPUs:

test = erstruct(500, ['chr21.npy', 'chr22.npy'], 1000, 1e-4, cpu_num=1, device_idx="cpu")
K = test.run()

Run ERStruct algorithm on sample dataset with GPUs:

test = erstruct(500, './', ['chr21.npy', 'chr22.npy'], 1000, 1e-4, device_idx="gpu", varm=2e8)
K = test.run()

Example data files test_chr21.npy and test_chr22.npy can be found on the "sample_data" of ERStruct GitHub repository.

Other Details

Please refer to our paper

ERStruct: A Python Package for Inferring the Number of Top Principal Components from Whole Genome Sequencing Data

For details of the ERStruct algorithm:

ERStruct: An Eigenvalue Ratio Approach to Inferring Population Structure from Sequencing Data

If you have any question, please contact the email eciel@connect.hku.hk.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ERStruct-0.1.24.tar.gz (27.7 MB view details)

Uploaded Source

File details

Details for the file ERStruct-0.1.24.tar.gz.

File metadata

  • Download URL: ERStruct-0.1.24.tar.gz
  • Upload date:
  • Size: 27.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.11

File hashes

Hashes for ERStruct-0.1.24.tar.gz
Algorithm Hash digest
SHA256 f4eed23a1a93f005828c6441046cf2642e23acf5edc97b7d4c280d45049a5558
MD5 e64da2203f4bf0d94b741392fc8def68
BLAKE2b-256 9790eda610c10f41d97e9af51377b243ae83638d30842620cfbd44a41c480e39

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page