Skip to content

Commit 788e83c

Browse files
committed
fix empty bam bug in m3c contact call
1 parent 1b62f94 commit 788e83c

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

cemba_data/hisat3n/hisat3n_m3c.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,14 +635,18 @@ def _dedup_contacts(output_prefix, save_raw=False):
635635
total_dedup = []
636636
for _, chrom_df in contacts.groupby(['chrom1', 'chrom2']):
637637
total_dedup.append(_dedup_chrom_df(chrom_df))
638-
total_dedup = pd.concat(total_dedup)
638+
try:
639+
total_dedup = pd.concat(total_dedup)
640+
except ValueError:
641+
# no dataframes in total_dedup
642+
total_dedup = pd.DataFrame(columns=contacts.columns)
639643
total_dedup.to_csv(output_path, sep='\t', index=False)
640644

641645
if not save_raw:
642646
subprocess.run(shlex.split(f'rm -f {input_path}'), check=True)
643647

644648
dedup_contacts = total_dedup.shape[0]
645-
dup_rate = (input_contacts - dedup_contacts) / input_contacts
649+
dup_rate = (input_contacts - dedup_contacts) / (input_contacts + 0.00001)
646650
return dedup_contacts, dup_rate
647651

648652

hisat3n_env.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ channels:
44
- bioconda
55
- defaults
66
dependencies:
7-
- python=3.8
7+
- python=3.9
88
- pip
99
- jupyter
1010
- snakemake
@@ -15,12 +15,10 @@ dependencies:
1515
- samtools
1616
- picard
1717
- bedtools
18-
- htslib>=1.9
18+
- htslib=1.15
1919
- pysam
2020
- pybedtools
2121
- pyBigWig
22-
- star=2.7.3a
23-
- subread=2.0
2422
- pip:
2523
- papermill
2624
- allcools

0 commit comments

Comments
 (0)