Skip to content

Commit

Permalink
Add click decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
cchlanger committed Jan 13, 2020
1 parent 6167760 commit 972da9c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ tmpdata/*
.vscode
*.bed
*.tad
*.bedpe
*.bedpe
*.sizes
3 changes: 1 addition & 2 deletions convert_to_bedpe.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
# Load to pandas:
df = pd.read_csv(csvfile, sep="\t", header=None)
df[3] = df[0]
df = df.drop(columns=[4,5,8])
df = df.drop(columns=[4, 5, 8])
df.to_csv(filename[:-4]+".bedpe", header=None, index=False, sep="\t")

40 changes: 25 additions & 15 deletions create_dense_matrix.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Command line interface for OnTAD preprocessing"""
import click
import os
import cooler
# import cooltools
Expand All @@ -12,22 +14,30 @@

# get chromosomal arms

chromsizes = bioframe.fetch_chromsizes('hg19')
chromsizes = bioframe.fetch_chromsizes("hg19")
arms = HT.getArmsHg19()

# load in data

HICPATH = "/groups/gerlich/experiments/Experiments_004800/004812/Sequencing_data/Pooled_FC_1_2/cooler/"

BINSIZE = 50000
BARCODE = "G2.fc_1_2.wOldG2"
clrs = {interType:
cooler.Cooler(
os.path.join(HICPATH, f'{BARCODE}.{interType}.1000.mcool::/resolutions/{BINSIZE}'))
for interType in ["cis", "trans"]}


cis_cooler = clrs['cis']
cis_matrix = cis_cooler.matrix(balance=True).fetch("chr18")
cis_matrix = np.nan_to_num(cis_matrix)
np.savetxt("tmpdata/G2.fc_1_2.wOldG2.chr18.cis.matrix", cis_matrix, fmt='%1.4f', delimiter="\t")
# fileP = "testdata/G2.fc_1_2.wOldG2.cis.1000.mcool"
# binsize = 50000


@click.command()
@click.argument('filep', type=click.Path(exists=True))
@click.option('--binsize', '-b', 'binsize', default=50000,
help='Resulution size.',
show_default=True)
def create_dense_matrix(filep, binsize):
cooler_obj = cooler.Cooler(f'{filep}::/resolutions/{binsize}')
filename = os.path.basename(filep)
filename_base = filename[:-6]
for chr_name in chromsizes.index:
matrix = cooler_obj.matrix(balance=True).fetch(chr_name)
matrix = np.nan_to_num(matrix)
print(chr_name)
print("tmpdata/%s.%s.matrix" % (filename_base, chr_name))
np.savetxt("tmpdata/%s.%s.matrix" % (filename_base, chr_name), matrix, fmt='%1.8f', delimiter="\t")

if __name__ == "__main__":
create_dense_matrix()
7 changes: 4 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
OnTAD repo:
https://github.com/anlin00007/OnTAD

Create Imput with:
create_dense_matrix.py
Create Input with:
python create_dense_matrix.py testdata/G2.fc_1_2.wOldG2.cis.1000.mcool -b 50000


Use there docker:
singularity run docker://anlin00007/ontad:v1.2

Run there tool with following parameters:

OnTAD tmpdata/G2.fc_1_2.wOldG2.chr18.cis.matrix -penalty 0.1 -maxsz 200 -bedout 18 78077248 50000 -o OnTAD_cis_chr18
OnTAD tmpdata/G2.fc_1_2.wOldG2.chr18.cis.matrix -penalty 0.1 -maxsz 200 -bedout 18 78077248 50000 -o OnTAD_cis_chr18

0 comments on commit 972da9c

Please sign in to comment.