simple RNAseq pipeline based on snakemake workflow with extensive QC
Help improve this workflow!
This workflow has been published but could be further improved with some additional meta data:- Keyword(s) in categories input, output, operation, topic
You can help improve this workflow by suggesting the addition or removal of keywords, suggest changes and report issues, or request to become a maintainer of the Workflow .
This workflow performs a differential gene expression analysis with STAR and Deseq2.
Usage
Code Snippets
14 15 16 17 18 19 20 21 22 23 | shell: "mkdir -p {output} && " "STAR --runMode genomeGenerate " "--runThreadN {threads} " "--genomeDir {output} " "--genomeFastaFiles {input.fasta} " "--sjdbOverhang {params.overhang} " "--sjdbGTFfile {params.gtf} " "--outStd Log " "&> {log}" |
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | shell: "STAR --runThreadN {threads} " "--genomeDir {input.index} " "--readFilesCommand zcat " "--readFilesIn {params.fastqs} " "--outSAMtype BAM SortedByCoordinate " "--quantMode GeneCounts TranscriptomeSAM " "--sjdbGTFfile {params.gtf} " "--outSAMunmapped Within " "--outFilterType BySJout " "--outSAMattributes NH HI AS NM MD " "--alignIntronMin 20 " "--alignIntronMax 1000000 " "--alignMatesGapMax 1000000 " "--alignSJoverhangMin 8 " "--alignSJDBoverhangMin 1 " "--outFileNamePrefix {params.outprefix} " "--outStd Log && " "samtools index {output.bam} && " |
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | run: data_dict = {} cols = ["transcript_id", "gene_id", "length"] for data in ['expected_count', 'TPM', 'FPKM']: show_output(f"Combining {data} to {output[data]}") # load the df of shared rows into the data dict data_dict[data] = pd.read_csv(input[0], sep="\t").loc[:, cols] # add the data_cols = cols + [data] for f in input: # retrieve the sample name sample_name = f.split("/")[-1].split("-")[0] show_output(f"Reading {f}") sample_df = pd.read_csv(f, sep="\t").loc[:, data_cols].rename({data:sample_name}, axis=1) # print(sample_df.columns) data_dict[data] = data_dict[data].merge(sample_df, how="outer") data_dict[data].to_csv(output[data], sep="\t", index=False) show_output(f"Combined {data} data written to {output[data]}", color="success") |
41 42 | script: "../scripts/count-matrix.py" |
14 15 | shell: "zcat {input.fastq} | fastqc stdin:{params.name} {params.limits_file}-o qc/fastqc/ " # &>{log} " |
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | shell: "multiqc -f -o qc/ -n fastQC --interactive qc/fastqc/; " # interactive for big number of files "rm -f qc/fastqc/*_fastqc.html qc/fastq/*.sub" # leave the zip files for accumulated multiQC of all processed samples ## RSEQC rule rseqc_gtf2db: output: db=rseqc_gene_model("db"), log: "logs/rseqc_gtf2db.log", params: gtf = get_gtf() conda: "../envs/gffutils.yaml" |
41 42 | script: "../scripts/gtf2db.py" |
54 55 | script: "../scripts/gtfdb2bed.py" |
73 74 | shell: "junction_annotation.py {params.extra} -i {input.bam} -r {input.bed} -o {params.prefix} " |
92 93 94 | shell: "junction_saturation.py {params.extra} -i {input.bam} -r {input.bed} -o {params.prefix} " "> {log} 2>&1" |
107 108 | shell: "bam_stat.py -i {input} > {output} 2> {log}" |
122 123 | shell: "infer_experiment.py -r {input.bed} -i {input.bam} > {output} 2> {log}" |
139 140 | shell: "inner_distance.py -r {input.bed} -i {input.bam} -o {params.prefix} > {log} 2>&1" |
154 155 | shell: "read_distribution.py -r {input.bed} -i {input.bam} > {output} 2> {log}" |
171 172 | shell: "read_duplication.py -i {input} -o {params.prefix} > {log} 2>&1" |
187 188 | shell: "read_GC.py -i {input} -o {params.prefix} > {log} 2>&1" |
237 238 | wrapper: "0.75.0/bio/multiqc" |
12 13 14 15 16 17 | shell: "rsem-calculate-expression " "--bam --num-threads {threads} " "--paired-end --forward-prob 0.5 " "--no-bam-output " "{input.tbam} {params.rsem_ref} results/RSEM/{wildcards.sample}-{wildcards.unit}" |
41 42 43 | shell: "cutadapt -j {threads} {params.adapters} --minimum-length 1 -q 20 " "-o {output.fastq1} -p {output.fastq2} {input.fastq1} {input.fastq2} > {log}" |
59 60 61 | shell: "cutadapt -j {threads} {params.adapters} --minimum-length 1 -q 20 " "-o {output.fastq} {input.fastq1} > {log}" |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import sys # logging sys.stderr = open(snakemake.log[0], "w") import pandas as pd def get_matrix(s): counts = [ pd.read_table( f, index_col=0, usecols=[0, 1], header=None, skiprows=4 ) for f in s.input ] for t, sample in zip(counts, s.params.samples): t.columns = [sample] matrix = pd.concat(counts, axis=1) matrix.index.name = "gene" # collapse technical replicates matrix = matrix.groupby(matrix.columns, axis=1).sum() matrix.to_csv(s.output[0], sep="\t") get_matrix(snakemake) |
1 2 3 4 5 6 7 8 9 10 11 12 | import gffutils db = gffutils.create_db( snakemake.params.gtf, dbfn=snakemake.output.db, force=True, keep_order=True, merge_strategy="merge", sort_attribute_values=True, disable_infer_genes=True, disable_infer_transcripts=True, ) |
1 2 3 4 5 6 7 8 9 | import gffutils db = gffutils.FeatureDB(snakemake.input.db, keep_order=True) with open(snakemake.output.bed, "w") as outfileobj: for tx in db.features_of_type("transcript", order_by="start"): bed = [s.strip() for s in db.bed12(tx).split("\t")] bed[3] = tx.id outfileobj.write("{}\n".format("\t".join(bed))) |
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | __author__ = "Julian de Ruiter" __copyright__ = "Copyright 2017, Julian de Ruiter" __email__ = "julianderuiter@gmail.com" __license__ = "MIT" from os import path from snakemake.shell import shell input_dirs = set(path.dirname(fp) for fp in snakemake.input) output_dir = path.dirname(snakemake.output[0]) output_name = path.basename(snakemake.output[0]) log = snakemake.log_fmt_shell(stdout=True, stderr=True) shell( "multiqc" " {snakemake.params}" " --force" " -o {output_dir}" " -n {output_name}" " {input_dirs}" " {log}" ) |
Support
Do you know this workflow well? If so, you can
request seller status , and start supporting this workflow.
Created: 1yr ago
Updated: 1yr ago
Maitainers:
public
URL:
https://github.com/Mar111tiN/RNAseq
Name:
rnaseq
Version:
3
Downloaded:
0
Copyright:
Public Domain
License:
MIT License
- Future updates
Related Workflows

ENCODE pipeline for histone marks developed for the psychENCODE project
psychip pipeline is an improved version of the ENCODE pipeline for histone marks developed for the psychENCODE project.
The o...

Near-real time tracking of SARS-CoV-2 in Connecticut
Repository containing scripts to perform near-real time tracking of SARS-CoV-2 in Connecticut using genomic data. This pipeli...

snakemake workflow to run cellranger on a given bucket using gke.
A Snakemake workflow for running cellranger on a given bucket using Google Kubernetes Engine. The usage of this workflow ...

ATLAS - Three commands to start analyzing your metagenome data
Metagenome-atlas is a easy-to-use metagenomic pipeline based on snakemake. It handles all steps from QC, Assembly, Binning, t...
raw sequence reads
Genome assembly
Annotation track
checkm2
gunc
prodigal
snakemake-wrapper-utils
MEGAHIT
Atlas
BBMap
Biopython
BioRuby
Bwa-mem2
cd-hit
CheckM
DAS
Diamond
eggNOG-mapper v2
MetaBAT 2
Minimap2
MMseqs
MultiQC
Pandas
Picard
pyfastx
SAMtools
SemiBin
Snakemake
SPAdes
SqueezeMeta
TADpole
VAMB
CONCOCT
ete3
gtdbtk
h5py
networkx
numpy
plotly
psutil
utils
metagenomics

RNA-seq workflow using STAR and DESeq2
This workflow performs a differential gene expression analysis with STAR and Deseq2. The usage of this workflow is described ...

This Snakemake pipeline implements the GATK best-practices workflow
This Snakemake pipeline implements the GATK best-practices workflow for calling small germline variants. The usage of thi...