Skip to main content

Blazing fast toolkit to work with .hic and .cool files

Project description

hictkpy

License Download from Bioconda


Python bindings for hictk, a blazing fast toolkit to work with .hic and .cool files.

Installing hictkpy

hictkpy can be installed in various ways.

PIP

pip install hictkpy

Conda (bioconda)

conda install -c conda-forge -c bioconda hictkpy

From source

pip install 'git+https://github.com/paulsengroup/hictkpy.git@main'

On Windows you will have to manually install some of hictk dependencies, namely hdf5 (with zlib support) and libdeflate.

Using hictkpy

import hictkpy

path_to_clr = "file.mcool"  # "file.hic"

clr = hictkpy.File(path_to_clr, 100_000)
sel = clr.fetch("chr1")

df = sel.to_df()     # Get interactions as a pd.DataFrame
m1 = sel.to_numpy()  # Get interactions as a numpy matrix
m2 = sel.to_coo()    # Get interactions as a scipy.sparse.coo_matrix

# Loop over interactions
for bin1_id, bin2_id, count in clr.fetch("chr1"):
  print(bin1_id, ...)

# Loop over interactions
for chrom1, start1, end1, chrom2, start2, end2, count in clr.fetch("chr1", join=True):
  print(chrom1, ...)

# Fetch interactions using UCSC queries
clr.fetch("chr1:0-10,000,000").to_df()
clr.fetch("chr1:0-10,000,000", "chr2:100,000,000-105,000,000").to_df()

# Fetch interactions using BED queries
clr.fetch("chr1\t0\t10000000", query_type="BED").to_df()

# Fetch balanced interactions
clr.fetch("chr1", normalization="weight").to_df()
clr.fetch("chr1", normalization="VC").to_df()

# Sum interactions overlapping query
clr.fetch("chr1").sum()

# Count non-zero entries
clr.fetch("chr1").nnz()

MIT License

Copyright (c) 2023 Roberto Rossini

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

hictkpy-0.0.2.tar.gz (18.5 kB view hashes)

Uploaded Source

Built Distributions

hictkpy-0.0.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

hictkpy-0.0.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

hictkpy-0.0.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

hictkpy-0.0.2-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

hictkpy-0.0.2-cp311-cp311-win_amd64.whl (2.1 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

hictkpy-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

hictkpy-0.0.2-cp311-cp311-macosx_10_15_universal2.whl (2.2 MB view hashes)

Uploaded CPython 3.11 macOS 10.15+ universal2 (ARM64, x86-64)

hictkpy-0.0.2-cp310-cp310-win_amd64.whl (2.1 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

hictkpy-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

hictkpy-0.0.2-cp310-cp310-macosx_11_0_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ x86-64

hictkpy-0.0.2-cp39-cp39-win_amd64.whl (2.1 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

hictkpy-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

hictkpy-0.0.2-cp39-cp39-macosx_11_0_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ x86-64

hictkpy-0.0.2-cp38-cp38-win_amd64.whl (2.1 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

hictkpy-0.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

hictkpy-0.0.2-cp38-cp38-macosx_11_0_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.8 macOS 11.0+ x86-64

hictkpy-0.0.2-cp37-cp37m-win_amd64.whl (2.1 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

hictkpy-0.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

hictkpy-0.0.2-cp37-cp37m-macosx_11_0_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.7m macOS 11.0+ x86-64

hictkpy-0.0.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

Supported by

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