Skip to content

Commit

Permalink
added new module hicInfo that will print simple statistics of HiC mat…
Browse files Browse the repository at this point in the history
…rices
  • Loading branch information
fidelram committed Dec 13, 2016
1 parent 6f10b3c commit 9324897
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
7 changes: 7 additions & 0 deletions bin/hicInfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

from hicexplorer.hicInfo import main

if __name__ == "__main__":
main()
45 changes: 45 additions & 0 deletions hicexplorer/hicInfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import argparse
from hicexplorer import HiCMatrix as hm
from hicexplorer._version import __version__


def parse_arguments(args=None):

parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description=('Prints information about a matrix including size, '
'number of elements, sum of elements, etc.'))

parser.add_argument('--matrices', '-m',
help='matrices to add. Must have the same shape.',
metavar='.h5 of .npz file format',
nargs='+',
required=True)

parser.add_argument('--version', action='version',
version='%(prog)s {}'.format(__version__))

return parser


def main():

args = parse_arguments().parse_args()
for matrix in args.matrices:
print("File:\t{}".format(matrix))

hic_ma = hm.hiCMatrix(matrix)
size = hic_ma.matrix.shape[0]
num_non_zero = hic_ma.matrix.nnz
sum_elements = hic_ma.matrix.sum()/2
bin_length = hic_ma.getBinSize()
num_nan_bins = len(hic_ma.nan_bins)
chromosomes = hic_ma.chrBinBoundaries.keys()

print("Size:\t{:,}".format(size))
print("Sum:\t{:,}".format(sum_elements))
print("Bin_length:\t{}".format(bin_length))
print("Chromosomes:\t{}".format(", ".join(chromosomes)))
print("Non-zero elements:\t{:,}".format(num_non_zero))
print("NaN bins:\t{}".format(num_nan_bins))
print("")

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def get_version():
scripts=['bin/findRestSite', 'bin/hicBuildMatrix', 'bin/hicCorrectMatrix',
'bin/hicCorrelate', 'bin/hicFindEnrichedContacts', 'bin/hicFindTADs',
'bin/hicMergeMatrixBins', 'bin/hicPlotMatrix', 'bin/hicPlotDistVsCounts',
'bin/hicPlotTADs', 'bin/hicSumMatrices', 'bin/hicExport'],
'bin/hicPlotTADs', 'bin/hicSumMatrices', 'bin/hicExport', 'bin/hicInfo'],
include_package_data=True,
package_data={'': ['config/hicexplorer.cfg']},
url='http://hicexplorer.readthedocs.io',
Expand Down

0 comments on commit 9324897

Please sign in to comment.