Skip to main content

PyNetCor is a fast Python C++ extension for correlation and network analysis

Reason this release was yanked:

Package uploaded with incorrect build artifacts affecting functionality.

Project description

pyNetCor

PyNetCor is a fast Python C++ extension for correlation and network analysis on high-dimensional datasets. It aims to serve as a scalable foundational package to accelerate large-scale computations.

Features

  • Calculate correlation matrix using Pearson, Spearman, or Kendall methods
  • Processing large-scale computation in chunks (larger than RAM)
  • Find top-k and differential correlations between each row of two arrays
  • Efficient P-value approximation and multiple testing correction
  • Handle missing values
  • Multi-thread

Installation

You can install pyNetCor using pip:

pip install pynetcor

Quick Start

Create Data

import numpy as np

features = 100000
sampes = 100
arr1 = np.random.random((features, samples))
arr2 = np.random.random((features, samples))

Calculate correlation matrix

Compute and return the full matrix at once.

from pynetcor.cor import corrcoef

# using 8 threads
# Pearson correlations between `arr1` and itself
cor_result = corrcoef(arr1, threads=8)

Compute the matrix in chunks and return an Iterator, recommended for large-scale analysis that exceed RAM.

from pynetcor.cor import chunked_corrcoef

# Calculate and return `chunk_size=1024` rows of the correlation matrix with each iteration.
cor_iter = chunked_corrcoef(arr1, chunk_size=1024, threads=8)
for cor_chunk_matrix in cor_iter:
    ...

Top-k correlation search

Identify the accurate top k correlations (Spearman correlation).

from pynetcor.cor import cor_topk

# top 1% correlations
cor_topk_result = cor_topk(arr1, method="spearman", k=0.001, threads=8)

# top 100 correlations
cor_topk_result = cor_topk(arr1, method="spearman", k=100, threads=8)

# Return a 2D array with 4 columns: [row_index, col_index, correlation, pvalue]

Top-k differential correlation search

Identify the accurate top k differences in correlation between pairs of features across two states or time points.

# Compute the pairwise correlations separately for `arr1` with `arr1`, and `arr2` with `arr2`, then identify the feature pairs with the largest difference
from pynetcor.cor import cor_topkdiff

# top 1% differential correlations
cor_topkdiff_result = cor_topkdiff(x1=arr1, y1=arr2, x2=arr1, y2=arr2, k=0.001, threads=8)

# top 100 differential correlations
cor_topkdiff_result = cor_topkdiff(x1=arr1, y1=arr2, x2=arr1, y2=arr2, k=100, threads=8)

# Return a 2D array with 5 columns: [row_index, col_index, diffCor, cor1, cor2]

P-value computation

Compute the P-values for correlations (Pearson or Spearman) using the Student's t-distribution. The approximation method is significantly faster than the classical method, with the absolute errors are nearly less than 1e-8.

from pynetcor.cor import corrcoef, pvalue_student_t
samples = arr1.shape[1]

# Generate the Pearson correlation matrix
cor_result = corrcoef(arr1, threads=8)

# P-value approximation
pvalue_result = pvalue_student_t(cor_result, df=samples-2, approx=True, threads=8)

# P-value classic
pvalue_result = pvalue_student_t(cor_result, df=samples-2, approx=False, threads=8)

Unified implementation for calculating correlations and P-values.

from pynetcor.cor import cortest, chunked_cortest

# Pearson correlation & P-value approximation
cortest_result = cortest(arr1, approx=True, threads=8)

# chunking computation, recommended for large-scale analysis that exceed RAM
for iter in chunked_cortest(arr1, approx=True, threads=8):
    for (row_index, col_index, correlation, pvalue) in iter:
        ...
        
# Return a 2D array with 4 columns: [row_index, col_index, correlation, pvalue]

Multiple testing correction: holm, hochberg, bonferroni, BH, BY.

from pynetcor.cor import cortest, chunked_cortest

# Pearson correlation & multiple testing correction
cortest_result = cortest(arr1, adjust_pvalue=True, adjust_method="BH", threads=8)

# chunking computation, recommended for large-scale analysis that exceed RAM
for iter in chunked_cortest(arr1, adjust_pvalue=True, adjust_method="BH", threads=8):
    for (row_index, col_index, correlation, pvalue) in iter:
        ...
        
# Return a 2D array with 5 columns: [row_index, col_index, correlation, pvalue, adjusted_pvalue]       

NOTE: chunked function only supports approximate adjusted P-value. PyNetCor utilizes approximation methods to achieve effective FDR control before computing all P-values.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pynetcor-0.0.2-cp312-cp312-win_amd64.whl (9.0 MB view details)

Uploaded CPython 3.12Windows x86-64

pynetcor-0.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pynetcor-0.0.2-cp311-cp311-win_amd64.whl (9.0 MB view details)

Uploaded CPython 3.11Windows x86-64

pynetcor-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pynetcor-0.0.2-cp310-cp310-win_amd64.whl (9.0 MB view details)

Uploaded CPython 3.10Windows x86-64

pynetcor-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pynetcor-0.0.2-cp39-cp39-win_amd64.whl (9.0 MB view details)

Uploaded CPython 3.9Windows x86-64

pynetcor-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pynetcor-0.0.2-cp38-cp38-win_amd64.whl (9.0 MB view details)

Uploaded CPython 3.8Windows x86-64

pynetcor-0.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

pynetcor-0.0.2-cp37-cp37m-win_amd64.whl (9.0 MB view details)

Uploaded CPython 3.7mWindows x86-64

pynetcor-0.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.0 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

File details

Details for the file pynetcor-0.0.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pynetcor-0.0.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 9.0 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pynetcor-0.0.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 15f3ddc3f8f42626add64e47ba2d4cd8dc1accdfe092ea73d77384d36b9d35a6
MD5 529a30e8cf6ce25f8dd3be94e06e2808
BLAKE2b-256 70ee7429d2e666cc8b0d89c6ce7a58511859a5fd8da881c830fdce0052972313

See more details on using hashes here.

File details

Details for the file pynetcor-0.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pynetcor-0.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2db3bad18e420de23c82eacecba405924641b81985cf3f6bc8ee2e22d9f99aa3
MD5 0c9627ab202e6811fd28f4305a04257c
BLAKE2b-256 0d004f05d7c619f4193bf2b153543c35227bb12a69d0df60b995e0269d9db4c0

See more details on using hashes here.

File details

Details for the file pynetcor-0.0.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pynetcor-0.0.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 9.0 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pynetcor-0.0.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 41cfc43b520a79b5a9e1b3e68a0db5fb5b4539e5be1702bbc6c2e0b46c7384d6
MD5 a0539c89b1078184c7f2904b23990017
BLAKE2b-256 21b7fa59a184feeb4877d830949c7312a73d1ae0ecc79eddc1c5f98f9cb7b742

See more details on using hashes here.

File details

Details for the file pynetcor-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pynetcor-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2775483646c0cbe406e88edd89600f78241cc6110fc77bacd79a67b2ca054490
MD5 8ead7db73d851a3ade6d9802cc37fa2d
BLAKE2b-256 d05964858327eadc913f82e0b5c2d1ec4d68206d9f0b76a358a34dd625ef733e

See more details on using hashes here.

File details

Details for the file pynetcor-0.0.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pynetcor-0.0.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 9.0 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pynetcor-0.0.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 47a8819b5c89d51971554e860f5b92bdd3ac1153cbea7638a5bb92d9e1163ddf
MD5 44500dfda0be541afea1f5ea91e25a8f
BLAKE2b-256 50c980399c96aad99a24c5773676649e990e32ed110006b0357cc17680dd2318

See more details on using hashes here.

File details

Details for the file pynetcor-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pynetcor-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7c0dcceb996d4f3a3d9482327523158a1e91d3c0e4f9673fcf4c050e62bb12dc
MD5 67a0f6442f1588fad6ce9c519c849bf0
BLAKE2b-256 27c550d7c9092d52784e5771cb052c6b11ccefbe4002fc70fb6cac2a1cbcdc98

See more details on using hashes here.

File details

Details for the file pynetcor-0.0.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pynetcor-0.0.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 9.0 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pynetcor-0.0.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 556bfdec6672e91bde693472448004c2bbf49395d069a35baefbe08dd30a5d1f
MD5 43b95f64a1d3ce13cb117ddfca1283d7
BLAKE2b-256 e2dbbaaeae32fa52986927cf336d1852cabd94d6fa34a9b178c589b2b6c18dd5

See more details on using hashes here.

File details

Details for the file pynetcor-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pynetcor-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0ba37db33577a35433b7f42e1fe418980481766c2e01aa67c374e8d2d8bccadb
MD5 7dbde18e1e1e41fa525ec425151bcce0
BLAKE2b-256 ad000fbb7bc59f49649d4a661c88fb8f6144b35835107df7d45771cd527046e1

See more details on using hashes here.

File details

Details for the file pynetcor-0.0.2-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pynetcor-0.0.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 9.0 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pynetcor-0.0.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 dcf97c4ea4bccf20237b00136c3a2afce3154fc62dece2f26e2fff1b460735cf
MD5 d1b3533a182e4e597b3983933ce95e62
BLAKE2b-256 d2f134ac8095ee249992d4364c78e83309ed47142bb760a685a0f699da01ba15

See more details on using hashes here.

File details

Details for the file pynetcor-0.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pynetcor-0.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1bf9366a8a6080e0ddd2d304b2dff577ce1ed781a7ee72e339cd7b69c44744a6
MD5 9e2f9502d8191a6d34ae6828addfde5e
BLAKE2b-256 b82cac23ac5bbe9613fa52da31bb6a32313562d24354f1e93a3fd479c1d971d9

See more details on using hashes here.

File details

Details for the file pynetcor-0.0.2-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pynetcor-0.0.2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 9.0 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pynetcor-0.0.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 23afaea3de5d233b40cad03a1116a81bf2aae3db2cf189d5709fba6d6f36f490
MD5 9f86a36206356cdfb486a98b7c0923d4
BLAKE2b-256 a41213052bdf7855ca56331e5be2a8d4a565e24c124260d85bebe805f9d99ccf

See more details on using hashes here.

File details

Details for the file pynetcor-0.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pynetcor-0.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 afd97bee9561a402d6df11dc82eff7ddd80f1f846cef0f2306fee376de914009
MD5 866aeeca540e65f057bbf8f4f09873e0
BLAKE2b-256 c53ab8d1482f263e2ec943e6cf4e340a3603b05219443531a786f87bf5102d15

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