-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added new module hicInfo that will print simple statistics of HiC mat…
…rices
- Loading branch information
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters