-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_ren_hic_contacts.py
96 lines (73 loc) · 3.55 KB
/
get_ren_hic_contacts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import argparse
from contact import Contacts
def main():
args = parse_arguments()
contacts = Contacts(build = args.assembly,
chromosome = args.chromosome,
resolution = args.resolution)
contacts.get_raw_contacts_from_ren_hic_file(hic_file = args.hic)
contacts.write_contacts_to_file(outfile = args.raw_contacts, fmt = "%1f")
contacts.ice_raw_contacts(raw_contacts_file = args.raw_contacts,
bias_file = args.biases,
iterations = args.iterations,
hicorrector_path = args.hicorrector)
contacts.write_contacts_to_file(outfile = args.iced, fmt = "%1f")
contacts.truncate_to_median_diagonal_value()
contacts.write_contacts_to_file(outfile = args.output, fmt = "%1f")
def parse_arguments():
parser = argparse.ArgumentParser(
description = 'Generates an ICEd matrix of intra- or ' +
'interchromosomal contacts from a Ren lab Hi-C file.')
parser.add_argument('--hic',
metavar = "FILE",
action = "store",
help = "The input Hi-C file.")
parser.add_argument('--raw_contacts',
metavar = "FILE",
action = "store",
help = "An intermediate file of raw (un-ICEd) " +
"contacts.")
parser.add_argument('--biases',
metavar = "FILE",
action = "store",
help = "An intermediate file of biases generated by " +
"hicorrector.")
parser.add_argument('--iced',
metavar = "FILE",
action = "store",
help = "An intermediate file of ICEd contacts.")
parser.add_argument('-o', '--output',
metavar = "FILE",
action = "store",
help = "The output ICEd and scaled contacts file.")
parser.add_argument('--assembly',
metavar = "ASSEMBLY",
action = "store",
choices = ["mm9", "mm10", "hg19"],
default = "mm9",
help = "The genome assembly. (default mm9)")
parser.add_argument('--chromosome',
metavar = "CHROM",
action = "store",
help = "The chromosome of interest. Input 'genome' " +
"for an interchromosomal matrix.")
parser.add_argument('--resolution',
metavar = 'INT',
type = int,
action = 'store',
default = 1000000,
help = "Contact matrix resolution in bp. (default 1000000 = 1 Mb)")
parser.add_argument('--hicorrector',
metavar = "FILE",
action = 'store',
default = "/mnt/new-storage/Software/hicorrector/1.2/bin/ic",
help = "Path to hicorrector ic. (default /mnt/new-storage/Software/hicorrector/1.2/bin/ic)")
parser.add_argument('--iterations',
metavar = 'INT',
type = int,
action = 'store',
default = 100,
help = "Number of ICE iterations (default 100)")
return parser.parse_args()
if __name__ == "__main__":
main()