Commit 950f3c28 authored by Sarah Peter's avatar Sarah Peter

Solution for QC exercises

parent f13d3a4f
SAMPLE = "TC1-ST2-D0.12"
rule all:
input: f"output/{SAMPLE}_peaks.narrowPeak", f"output/{SAMPLE}_control_lambda.bigwig", f"output/{SAMPLE}_treat_pileup.bigwig", f"output/H3K4-{SAMPLE}_fastqc.html", f"output/INPUT-{SAMPLE}_fastqc.html", f"output/alignment_metrics_H3K4-{SAMPLE}.txt", f"output/alignment_metrics_INPUT-{SAMPLE}.txt"
rule mapping:
input: "chip-seq/{sample}.fastq.gz"
output: "bowtie2/{sample}.bam"
params:
idx = "reference/Mus_musculus.GRCm38.dna_sm.chromosome.12"
log: "logs/bowtie2_{sample}.log"
benchmark: "benchmarks/mapping/{sample}.tsv"
conda: "envs/bowtie2.yaml"
shell:
"""
bowtie2 -x {params.idx} -U {input} 2> {log} | \
samtools sort - > {output}
samtools index {output}
"""
rule peak_calling:
input:
control = "bowtie2/INPUT-{sample}.bam",
chip = "bowtie2/H3K4-{sample}.bam"
output:
peaks = "output/{sample}_peaks.narrowPeak",
control_bdg = "macs2/{sample}_control_lambda.bdg",
chip_bdg = "macs2/{sample}_treat_pileup.bdg"
conda: "envs/macs2.yaml"
shell:
"""
macs2 callpeak -t {input.chip} -c {input.control} -f BAM -g mm -n {wildcards.sample} -B -q 0.01 --outdir macs2
cp macs2/{wildcards.sample}_peaks.narrowPeak {output.peaks}
"""
rule bigwig:
input: "macs2/{sample}.bdg"
output: "output/{sample}.bigwig"
params:
idx = "reference/Mus_musculus.GRCm38.dna_sm.chromosome.12.fa.fai"
conda: "envs/ucsc.yaml"
shell:
"""
bedGraphToBigWig {input} {params.idx} {output}
"""
rule fastqc:
input: "chip-seq/{sample}.fastq.gz"
output:
html = "output/{sample}_fastqc.html",
zip = "chip-seq/{sample}_fastqc.zip"
conda: "envs/fastqc.yaml"
shell:
"""
fastqc {input}
cp chip-seq/{wildcards.sample}_fastqc.html {output.html}
"""
rule alignment_metrics:
input: "bowtie2/{sample}.bam"
output: "output/alignment_metrics_{sample}.txt"
params:
idx = "reference/Mus_musculus.GRCm38.dna_sm.chromosome.12.fa"
conda: "envs/picard.yaml"
shell:
"""
picard CollectAlignmentSummaryMetrics R={params.idx} I={input} O={output}
"""
name: fastqc
channels:
- bioconda
dependencies:
- fastqc
name: fastqc
channels:
- bioconda
dependencies:
- picard
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment