Skip to content

Commit

Permalink
Merge pull request #4 from davidebolo1993/impg_initial
Browse files Browse the repository at this point in the history
merging impg_initial into master
  • Loading branch information
davidebolo1993 authored Apr 26, 2024
2 parents 8aa4ef9 + e6583f7 commit 7c78f29
Show file tree
Hide file tree
Showing 18 changed files with 368 additions and 278 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ cosigt_smk/.snakemake/*
cosigt_smk/workflow/scripts/__pycache__
cosigt_smk/snakemake.run.sh
cosigt_smk/config/*
cosigt_smk/benchmarks/*
cosigt_smk/.*
4 changes: 1 addition & 3 deletions cosigt_smk/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# Snakemake pipeline

Docs are in preparation
# Snakemake pipeline
6 changes: 5 additions & 1 deletion cosigt_smk/workflow/Snakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pandas as pd
from glob import glob

configfile: 'config/config.yaml'

Expand All @@ -7,7 +8,10 @@ df=(pd.read_table(config['samples'], dtype={'sample_id': str, 'cram':str})
.sort_index()
)

include: 'rules/extract.smk'
include: 'rules/impg.smk'
include: 'rules/bedtools.smk'
include: 'rules/samtools.smk'
include: 'rules/faidx.smk'
include: 'rules/pggb.smk'
include: 'rules/odgi.smk'
include: 'rules/bwa-mem2.smk'
Expand Down
12 changes: 0 additions & 12 deletions cosigt_smk/workflow/envs/python.yml

This file was deleted.

8 changes: 0 additions & 8 deletions cosigt_smk/workflow/envs/r.yml

This file was deleted.

26 changes: 26 additions & 0 deletions cosigt_smk/workflow/rules/bedtools.smk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
rule bedtools_merge:
'''
https://github.com/arq5x/bedtools2
'''
input:
rules.impg_project.output
output:
config['output'] + '/bedtools/{region}.bed'
threads:
1
resources:
mem_mb=lambda wildcards, attempt: attempt * config['default']['mem_mb'],
time=lambda wildcards, attempt: attempt * config['default']['time']
container:
'docker://davidebolo1993/cosigt_workflow:latest'
benchmark:
'benchmarks/{region}.bedtools_merge.benchmark.txt'

shell:
'''
bedtools sort \
-i {input} | \
bedtools merge \
-d 50000 \
-i - > {output}
'''
28 changes: 19 additions & 9 deletions cosigt_smk/workflow/rules/bwa-mem2.smk
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
rule bwa_mem2_index:
rule bwamem2_index:
'''
bwa index
https://github.com/bwa-mem2/bwa-mem2
'''
input:
rules.odgi_paths_fasta.output
rules.pyfaidx_extract.output
output:
multiext(config['output'] + '/odgi/paths/fasta/{region}.fa', '.bwt.2bit.64', '.pac', '.ann', '.amb', '.0123')
multiext(config['output'] + '/pyfaidx/{region}.fasta', '.bwt.2bit.64', '.pac', '.ann', '.amb', '.0123')
threads:
1
resources:
mem_mb=lambda wildcards, attempt: attempt * config['bwa-mem2']['mem_mb'],
time=lambda wildcards, attempt: attempt * config['bwa-mem2']['time']
container:
'docker://davidebolo1993/cosigt_workflow:latest'
benchmark:
'benchmarks/{region}.bwamem2_index.benchmark.txt'
shell:
'''
bwa-mem2 index {input}
'''

rule bwa_mem2_samtools_sort:
rule bwamem2_mem_samtools_sort:
'''
bwa-mem2 and sam-to-bam conversion with samtools
https://github.com/bwa-mem2/bwa-mem2
https://github.com/samtools/samtools
'''
input:
ref=rules.odgi_paths_fasta.output,
idx=rules.bwa_mem2_index.output,
ref=rules.pyfaidx_extract.output,
idx=rules.bwamem2_index.output,
sample=rules.samtools_fasta.output
output:
config['output'] + '/bwa-mem2/{sample}/{region}.realigned.bam'
Expand All @@ -35,7 +38,14 @@ rule bwa_mem2_samtools_sort:
time=lambda wildcards, attempt: attempt * config['bwa-mem2']['time']
container:
'docker://davidebolo1993/cosigt_workflow:latest'
benchmark:
'benchmarks/{sample}.{region}.bwamem2_mem_samtools_sort.benchmark.txt'
shell:
'''
bwa-mem2 mem -t {threads} {input.ref} {input.sample} | samtools sort -@ {threads} - > {output}
bwa-mem2 mem \
-t {threads} \
{input.ref} \
{input.sample} | samtools sort \
-@ {threads} \
- > {output}
'''
13 changes: 10 additions & 3 deletions cosigt_smk/workflow/rules/cosigt.smk
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
rule cosigt_genotype:
'''
cosigt genotype
https://github.com/davidebolo1993/cosigt
'''
input:
zpath=rules.odgi_paths_matrix.output,
xpack=rules.gafpack_coverage.output,
cluster=rules.cluster.output
cluster=rules.make_clusters.output
output:
geno=config['output'] + '/cosigt/{sample}/{region}/cosigt_genotype.tsv',
combo=config['output'] + '/cosigt/{sample}/{region}/sorted_combos.tsv'
Expand All @@ -18,7 +18,14 @@ rule cosigt_genotype:
'docker://davidebolo1993/cosigt_workflow:latest'
params:
prefix=config['output'] + '/cosigt/{sample}/{region}'
benchmark:
'benchmarks/{sample}.{region}.cosigt_genotype.benchmark.txt'
shell:
'''
cosigt -p {input.zpath} -g {input.xpack} -c {input.cluster} -b resources/extra/blacklist.txt -o {params.prefix}
cosigt \
-p {input.zpath} \
-g {input.xpack} \
-c {input.cluster} \
-b resources/extra/blacklist.txt \
-o {params.prefix}
'''
161 changes: 0 additions & 161 deletions cosigt_smk/workflow/rules/extract.smk

This file was deleted.

46 changes: 46 additions & 0 deletions cosigt_smk/workflow/rules/faidx.smk
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
rule pyfaidx_extract:
'''
https://github.com/mdshw5/pyfaidx/
'''
input:
fasta=config['assemblies'],
bed=rules.bedtools_merge.output
output:
config['output'] + '/pyfaidx/{region}.fasta'
threads:
1
resources:
mem_mb=lambda wildcards, attempt: attempt * config['default']['mem_mb'],
time=lambda wildcards, attempt: attempt * config['default']['time']
container:
'docker://davidebolo1993/cosigt_workflow:latest'
benchmark:
'benchmarks/{region}.pyfaidx_extract.benchmark.txt'
shell:
'''
faidx \
--bed {input.bed} \
{input.fasta} > {output}
'''

rule samtools_faidx_index:
'''
https://github.com/samtools/samtools
'''
input:
rules.pyfaidx_extract.output
output:
config['output'] + '/pyfaidx/{region}.fasta.fai'
threads:
1
resources:
mem_mb=lambda wildcards, attempt: attempt * config['default']['mem_mb'],
time=lambda wildcards, attempt: attempt * config['default']['time']
container:
'docker://davidebolo1993/cosigt_workflow:latest'
benchmark:
'benchmarks/{region}.samtools_faidx_index.benchmark.txt'
shell:
'''
samtools faidx {input}
'''
Loading

0 comments on commit 7c78f29

Please sign in to comment.