Giter Site home page Giter Site logo

coverage_seqcontent_pipeline's Introduction

Coverage & Sequence Content Pipeline: README!

For this assignment, I have implemented Snakemake as a workflow management system to create a reproducible, scalable, and customizable pipeline. The Snakefile is currently specific to the HIV MiSeq dataset & reference genome given for this assignment but can be generalized. The steps are broken into several modules (or snakemake "rules") that are described below.

Dependencies & Installation

See INSTALL.md!

Run Instructions

note: this is assuming you have completed every step of the install file!

Within your pipeline folder (wherever your Snakefile is located), you can run the entire pipeline using the command:

snakemake --use-conda --cores-1

A dry-run (for troubleshooting purposes, no outputs) can be performed with:

snakemake --use-conda -n

A specific rule can be run with:

snakemake --use-conda -R rulename

OR by setting a specific target file (an output from one of the rules):

snakemake --use-conda /path/to/target

Modules

Index the reference genome using BWA.

rule index:
    input:
        "data/reference.fasta" 
    output:
        "data/reference.fasta.bwt" 
    conda:
        "envs/map.yaml" 
    shell:
        "bwa index {input}"

The input can be generalized by replacing 'reference' with {genome}. The output will include several index files with various file formats. The environment for the mapping & alignment tools that was created is invoked using the conda directive. The shell directive invokes a generalized command for the program that you are running.

Map the paired reads to the reference genome.

rule map_reads:
    input:
        "data/reference.fasta",
        "data/miseq/SRR961514_1.fastq",
        "data/miseq/SRR961514_2.fastq"
    output:
        "results/mapped/q{q}/hiv.bam"
    conda:
        "envs/map.yaml"
    params:
        q = config["quality_filter"]
    shell:
        "bwa mem {input} | samtools view -S -b -q {wildcards.q} - > {output}"

Multiple files must be separated by commas (see input). As is, the files will be written sequentially. The parameter "q" is defined using the config file and can be used to generalize the output. {wildcards.q} within the shell directive acts as a placeholder for q since it is a range of values.

Sort by name & clean up alignment file (rule fix), sort by coordinate order (rule sort), & remove duplicates (rule dedup).

rule fix:
  input:
      "results/mapped/q{q}/hiv.bam"
  output:
      "results/mapped/q{q}/hiv.fix.bam"
  conda:
      "envs/map.yaml"
  shell:
      "samtools sort -n {input} | samtools fixmate -m - {output}"

rule sort:
    input:
        "results/mapped/q{q}/hiv.fix.bam"
    output:
        "results/mapped/q{q}/hiv.sorted.bam"
    conda:
        "envs/map.yaml"
    shell:
        "samtools sort -o {output} {input}"

rule dedup:
    input:
        "results/mapped/q{q}/hiv.sorted.bam"
    output:
        "results/mapped/q{q}/hiv.sorted.dedup.bam"
    conda:
        "envs/map.yaml"
    shell:
        "samtools markdup -r -S {input} {output}"

Calculate read depth (depth.tsv has contig name, bp position, and # of mapped reads at each position).

rule depth:
    input:
        "results/mapped/q{q}/hiv.sorted.dedup.bam"
    output:
        "results/mapped/q{q}/depth.tsv"
    conda:
        "envs/map.yaml"
    shell:
        "samtools depth {input} > {output}"

Use an R script to reformat depth.tsv to the final coverage.tsv output and plot the coverage across the reference sequence.

rule cov_plot:
     input:
        tsv="results/mapped/q{q}/depth.tsv"
     output:
        tsv="results/mapped/q{q}/coverage.tsv",
        pdf="results/mapped/q{q}/coverage.pdf"
     script:
        "scripts/coverage_plot.R"

Use Qualimap to get more detailed quality metrics that are compiled into a report.

Of particular interest is Page 6 of each report that compares coverage across the reference (top graph) to %GC content across the reference (smaller bottom graph). From this plot we can conclude there is no obvious correlation between coverage and sequence content of the reference.

rule qualimap:
     input:
        "results/mapped/q{q}/hiv.sorted.dedup.bam"
     output:
        directory("results/mapped/q{q}/qualimap")
     shell:
        "unset DISPLAY | qualimap bamqc -bam {input} -outdir {output} -outfile correlation.pdf -outformat PDF"

coverage_seqcontent_pipeline's People

Contributors

ashokrags avatar lzholl avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.