Skip to main content

A Tool for Multiplex Chromatin Interaction Analysis by Efficiently Sorting Chromatin Complexes

Project description

MIA-Sort

Authors: Zichen Zhang and Minji Kim, University of Michigan

Code for the Paper "MIA-Sort: Multiplex Chromatin Interaction Analysis by Efficiently Sorting Chromatin Complexes"

About

miasort is a Python Library for multiplex chromatin interaction analysis by efficiently sorting chromatin complexes.

image

To start using miasort, you need to install bedtools. To do so, follow instructions on https://bedtools.readthedocs.io/en/latest/content/installation.html#. One of the options is:

$ mamba install -c conda-forge bedtools

After doing so, you can simply install our library:

$ pip install miasort

Documentation

1. abc_sort()

Purpose: Sorts three regions and generates plots or histograms as needed.

Parameters:

  • path1 (str): Path to the first input file.
  • path2 (str): Path to the second input file.
  • graphs (str): Graph configuration for sorting. There are in total 6 schemes: AtoC, CtoA, AandC, Bcentered, BtoA and BtoC. If you want all these 6 schemes, set this parameter as AtoC;CtoA;AandC;Bcentered;BtoA;BtoC (seperated by semicolons).
  • out_dir (str, optional): Output directory for the results. Default is '/'.
  • plot (bool, optional): Whether to generate plots. Default is True.
  • histogram (bool, optional): Whether to generate histograms. Default is False.
  • anchor_option (str, optional): Anchor options for sorting: yes_complete (drawing complex anchors), yes_top (drawing anchors on top of the plot), and no (do not draw anchors). Default is 'no'.
  • colors (str, optional): Colors for the anchors, fragments and lines on the plot respectively. Each item should be separated by a semicolon. Default is 'red;green;#525252'.
  • num_frag_min (int, optional): Minimum number of fragments required in one complex. Otherwise, we will not consider the complex. Default is 2.
  • num_frag_max (int, optional): Maximum number of fragments required in one complex. Otherwise, we will not consider the complex. Default is 1000.
  • extension (str, optional): Extension option for fragment drawing. It can be either natural (accurately represent each fragment's length) or an integer (each fragment's length will be set to this integer when the program outputs the plots). Default is '6000'.
  • frag_height (float, optional): Fragment height for plots. Default is 0.6.
  • line_width (float, optional): Line width for plots. Default is 2.0.
  • plot_width (int, optional): Width of the plots. Default is 50.
  • subplots_margins (tuple of three elements, optional): Margins for subplots: top, bottom and hspace respectively. Learn more about these three metrics in matplotlib.pyplot.subplots_adjust. Default is (0.9, 0.05, 0.9).

Usage:

import miasort

miasort.abc_sort("./data/test_input.region",
                 "./data/test_input.domains",
                 "AtoC;CtoA;AandC;Bcentered;BtoA;BtoC",
                 out_dir="./test_folder_syn_6000",
                 anchor_option="yes_complete")

The same code is in tests/test_abc_sort.py. To run the code, you can use this commandxx`:

$ ./tests/test_abc_sort.py

Results: This code will produce two plots:

(1) image (2) image

This code will also generate a CSV file:

Region ID,Site A,Site B,Site C,Region,Sort Scheme,num_complexes,num_1frag,num_2frag,num_3frag,num_4frag,num>=5frag
cr1_M-1,chr3:100000-108000,chr3:150000-155000,chr3:300000-308000,chr3:100000-308000,AtoC,4,0,3,1,0,0
cr1_M-1,chr3:100000-108000,chr3:150000-155000,chr3:300000-308000,chr3:100000-308000,CtoA,4,0,4,0,0,0
cr1_M-1,chr3:100000-108000,chr3:150000-155000,chr3:300000-308000,chr3:100000-308000,AandC,5,0,3,2,0,0
cr1_M-1,chr3:100000-108000,chr3:150000-155000,chr3:300000-308000,chr3:100000-308000,BtoAC,3,0,0,3,0,0
cr1_M-1,chr3:100000-108000,chr3:150000-155000,chr3:300000-308000,chr3:100000-308000,BtoA,2,0,2,0,0,0
cr1_M-1,chr3:100000-108000,chr3:150000-155000,chr3:300000-308000,chr3:100000-308000,BtoC,2,0,2,0,0,0

2. multiple_sort()

Purpose: Sorts regions A, B, and C, generating plots or histograms as needed.

Parameters:

  • path1 (str): Path to the first input file.
  • path2 (str): Path to the second input file.
  • out_dir (str, optional): Output directory for the results. Default is '/'.
  • plot (bool, optional): Whether to generate plots. Default is True.
  • histogram (bool, optional): Whether to generate histograms. Default is False.
  • anchor_option (str, optional): Anchor options for sorting: yes_complete (drawing complex anchors), yes_top (drawing anchors on top of the plot), and no (do not draw anchors). Default is 'no'.
  • colors (str, optional): Colors for the anchors, fragments and lines on the plot respectively. Each item should be separated by a semicolon. Default is 'red;green;#525252'.
  • num_frag_min (int, optional): Minimum number of fragments required in one complex. Otherwise, we will not consider the complex. Default is 2.
  • num_frag_max (int, optional): Maximum number of fragments required in one complex. Otherwise, we will not consider the complex. Default is 1000.
  • extension (str, optional): Extension option for fragment drawing. It can be either natural (accurately represent each fragment's length) or an integer (each fragment's length will be set to this integer when the program outputs the plots). Default is '6000'.
  • frag_height (float, optional): Fragment height for plots. Default is 0.6.
  • line_width (float, optional): Line width for plots. Default is 1.5.
  • plot_width (int, optional): Width of the plots. Default is 50.
  • subplots_margins (tuple of three elements, optional): Margins for subplots: top, bottom and hspace respectively. Learn more about these three metrics in matplotlib.pyplot.subplots_adjust. Default is (0.9, 0.05, 0.9).

Usage:

import miasort

miasort.multiple_sort("./data/test_input.region",
                      "./data/test_input_abc.domains",
                      out_dir="./test_folder_syn_AandBandC_6000",
                      anchor_option="yes_complete",
                      subplots_margins=(0.65, 0.15, 0.9))

The same code is in tests/test_multiple_sort.py. To run the code, you can use this command:

$ ./tests/test_multiple_sort.py

Results: This code will produce three plots. One of them is shown here: image

This code will also generate a CSV file:

Region ID,Site A,Site B,Site C,Region,Sort Scheme,num_complexes,num_1frag,num_2frag,num_3frag,num_4frag,num>=5frag
cr1_M-1,chr3:100000-108000,chr3:150000-155000,chr3:300000-308000,chr3:100000-308000,AandBandC,1,0,0,1,0,0
cr1_M-2,chr3:100000-109800,chr3:150000-155000,chr3:300000-308000,chr3:100000-308000,AandBandC,1,0,0,1,0,0
cr1_M-3,chr3:100000-149000,chr3:150000-155000,chr3:300000-318000,chr3:100000-318000,AandBandC,1,0,0,1,0,0

3. unlimited_multiple_sort()

Purpose: Allows for sorting an unlimited number of regions, generating plots or histograms as needed based on specified operations.

Parameters:

  • path1 (str): Path to the first input file.
  • regions (str): A string of regions to be sorted, separated by semicolons. This should correspond to the operations parameter. In the case of the usage demo, we require every complex to have a fragment in anchors A, C and D, but not in anchor B.
  • operations (str): Operations to be applied during sorting, separated by semicolons. This should correspond to the regions parameter.
  • out_dir (str, optional): Output directory for the results. Default is '/'.
  • plot (bool, optional): Whether to generate plots. Default is True.
  • histogram (bool, optional): Whether to generate histograms. Default is False.
  • anchor_option (str, optional): Anchor options for sorting: yes_complete (drawing complex anchors), yes_top (drawing anchors on top of the plot), and no (do not draw anchors). Default is 'no'.
  • colors (str, optional): Colors for the anchors, fragments and lines on the plot respectively. Each item should be separated by a semicolon. Default is 'red;green;#525252'.
  • num_frag_min (int, optional): Minimum number of fragments required in one complex. Otherwise, we will not consider the complex. Default is 2.
  • num_frag_max (int, optional): Maximum number of fragments required in one complex. Otherwise, we will not consider the complex. Default is 1000.
  • extension (str, optional): Extension option for fragment drawing. It can be either natural (accurately represent each fragment's length) or an integer (each fragment's length will be set to this integer when the program outputs the plots). Default is '6000'.
  • frag_height (float, optional): Fragment height for plots. Default is 0.6.
  • line_width (float, optional): Line width for plots. Default is 1.5.
  • plot_width (int, optional): Width of the plots. Default is 50.
  • subplots_margins (tuple of three elements, optional): Margins for subplots: top, bottom and hspace respectively. Learn more about these three metrics in matplotlib.pyplot.subplots_adjust. Default is (0.9, 0.05, 0.9).

Usage:

import miasort

miasort.unlimited_multiple_sort("./data/test_input.region",
                                "chr3:100000-108000;chr3:150000-155000;chr3:300000-308000;chr3:420000-428000",
                                "yes;no;yes;yes",
                                out_dir="./test_folder_syn_multiple_6000",
                                anchor_option="yes_complete",
                                subplots_margins=(0.65, 0.15, 0.9))

The same code is in tests/test_unlimited_multiple_sort.py. To run the code, you can use this command:

$ ./tests/test_unlimited_multiple_sort.py

Results: This code will produce one plot: image

License

Shield: CC BY-NC-ND 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 4.0 International License.

CC BY-NC-ND 4.0

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

miasort-0.1.6.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

miasort-0.1.6-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file miasort-0.1.6.tar.gz.

File metadata

  • Download URL: miasort-0.1.6.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for miasort-0.1.6.tar.gz
Algorithm Hash digest
SHA256 0954179064f3975b5d45a0f19a7541857f0ea06bfb2800acc42c8e6ad72d81f5
MD5 7bd854892b2ca6d470165a38d7e9dea4
BLAKE2b-256 a1451ffbde20e6558233cac8acd56ed7f9e012983d24cf76278408cac40ccf73

See more details on using hashes here.

File details

Details for the file miasort-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: miasort-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for miasort-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 8deca0f2654d0c2d3d637d59fa2b83549e3368ea2ce5773de20002ee598120a5
MD5 3f1bc59c10e40e023251334a8de52838
BLAKE2b-256 2675c066dd42a6e475dc5be075ce104c5ecb894add6c174a9851e4f3ef85f584

See more details on using hashes here.

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