Endogenous Retrovirus Expression Pipeline for Human and Mouse for use with bulk RNA
ervx 🔬
Endogenous Retrovirus Expression Pipeline for Human and Mouse
Code Snippets
175 176 177 178 | shell: """ rsem-prepare-reference -p {threads} --gtf {input.gtf} {input.fa} {params.prefix} rsem-generate-ngvector {params.prefix}.transcripts.fa {params.prefix}.transcripts """ |
208 209 210 211 212 213 214 215 216 | shell: """ python3 {params.get_gene} {input.gtf} > annotate.genes.txt python3 {params.get_isoform} {input.gtf} > annotate.isoforms.txt gtfToGenePred -ignoreGroupsWithoutExons {input.gtf} genes.genepred genePredToBed genes.genepred genes.bed12 sort -k1,1 -k2,2n genes.bed12 > genes.ref.bed python3 {params.make_refFlat} > refFlat.txt python3 {params.make_geneinfo} {input.gtf} > geneinfo.bed """ |
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | shell: """ # Setups temporary directory for # intermediate files with built-in # mechanism for deletion on exit if [ ! -d "{params.tmpdir}" ]; then mkdir -p "{params.tmpdir}"; fi tmp=$(mktemp -d -p "{params.tmpdir}") trap 'rm -rf "${{tmp}}"' EXIT # Create Index for read length rl=$(({wildcards.readlength}-1)) STAR \\ --runThreadN {threads} \\ --runMode genomeGenerate \\ --genomeDir STAR/2.7.6a/genes-{wildcards.readlength} \\ --genomeFastaFiles {input.fa} \\ --sjdbGTFfile {input.gtf} \\ --sjdbOverhang $rl \\ --outFileNamePrefix STAR/2.7.6a/build_{wildcards.readlength}_ \\ --outTmpDir ${{tmp}}/tmp_{wildcards.readlength} """ |
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | shell: """ # Setups temporary directory for # intermediate files with built-in # mechanism for deletion on exit if [ ! -d "{params.tmpdir}" ]; then mkdir -p "{params.tmpdir}"; fi tmp=$(mktemp -d -p "{params.tmpdir}") trap 'rm -rf "${{tmp}}"' EXIT # Build an index optimized # for small reference genomes genomeSize=$(grep -v '^>' {input.fa} | awk '{{sum+=length($0)}}; END {{print sum}}') # Calculate min(14, log2(GenomeSize)/2 - 1) genomeSAindexNbases=$(python -c "import math; print(min(14,int((math.log($genomeSize,2)/2)-1)))") echo "Building index with --genomeSAindexNbases $genomeSAindexNbases" STAR \\ --runThreadN {threads} \\ --runMode genomeGenerate \\ --genomeSAindexNbases ${{genomeSAindexNbases}} \\ --genomeDir STAR/2.7.6a/genome \\ --genomeFastaFiles {input.fa} \\ --outFileNamePrefix STAR/2.7.6a/build_genome_ \\ --outTmpDir ${{tmp}}/tmp_genome """ |
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | shell: """ # Setups temporary directory for # intermediate files with built-in # mechanism for deletion on exit if [ ! -d "{params.tmpdir}" ]; then mkdir -p "{params.tmpdir}"; fi tmp=$(mktemp -d -p "{params.tmpdir}") trap 'rm -rf "${{tmp}}"' EXIT STAR \\ --runThreadN {threads} \\ --runMode genomeGenerate \\ --genomeDir STAR/2.7.6a/genome \\ --genomeFastaFiles {input.fa} \\ --outFileNamePrefix STAR/2.7.6a/build_genome_ \\ --outTmpDir ${{tmp}}/tmp_genome """ |
407 408 409 410 411 412 | shell: """ python3 {params.create_rRNA} \\ {input.fa} \\ {input.gtf} \\ {params.genome} > {params.genome}.rRNA_interval_list """ |
431 432 433 | shell: """ python3 {params.get_karyoplot} {input.gtf} > karyoplot_gene_coordinates.txt """ |
452 453 454 455 | shell: """ mkdir -p karyobeds && cd karyobeds python3 {params.get_karyoplot} {input.gtf} """ |
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | shell: """ python {params.gtf2protein} {input.gtf} > protein_coding_genes.lst gtfToGenePred -ignoreGroupsWithoutExons -genePredExt {input.gtf} genes.gtf.genePred genePredToBed genes.gtf.genePred genes.gtf.genePred.bed awk -F '\\t' -v OFS='\\t' '{{print $12,$1}}' genes.gtf.genePred \\ | sort -k1,1n > gene2transcripts while read gene; do grep "${{gene}}" gene2transcripts; done < protein_coding_genes.lst > gene2transcripts.protein_coding_only python {params.gene2transcripts} \\ gene2transcripts.protein_coding_only \\ genes.gtf.genePred.bed \\ > gene2transcripts.protein_coding_only.with_len sort -k1,1 -k3,3nr gene2transcripts.protein_coding_only.with_len | \\ awk -F '\\t' '{{if (!seen[$1]) {{seen[$1]++; print $2}}}}' > protein_coding_only.txt while read transcript; do grep -m1 "${{transcript}}" genes.gtf.genePred.bed; done < <(awk -F '.' '{{print $1}}' protein_coding_only.txt) > transcripts.protein_coding_only.bed12 rm -f "protein_coding_genes.lst" "genes.gtf.genePred" "genes.gtf.genePred.bed" \\ "gene2transcripts" "gene2transcripts.protein_coding_only" "protein_coding_only.txt" \\ "gene2transcripts.protein_coding_only.with_len" "protein_coding_only.txt" """ |
526 527 528 529 530 531 532 | shell: """ python3 {params.generate_qualimap} \\ -g {input.gtf} \\ -f {input.fa} \\ -o {output} \\ --ignore-strange-chrom 2> qualimap_error.log """ |
565 566 567 568 | shell: """ wget https://hpc.nih.gov/~OpenOmics/common/{params.tarname} -O {params.tarfile} tar vxf {params.tarfile} -C {params.outdir} && rm {params.tarfile} """ |
601 602 603 604 | shell: """ wget https://hpc.nih.gov/~OpenOmics/common/{params.tarname} -O {params.tarfile} tar vxf {params.tarfile} -C {params.outdir} && rm {params.tarfile} """ |
629 630 631 632 633 634 635 | shell: """ mkdir -p "{params.outdir}" wget https://hpc.nih.gov/~OpenOmics/common/{params.conf1} -O {output.conf1} wget https://hpc.nih.gov/~OpenOmics/common/{params.conf2} -O {output.conf2} sed -i 's@/data/OpenOmics/references/common@{params.new}@g' {output.conf1} sed -i 's@/data/OpenOmics/references/common@{params.new}@g' {output.conf2} """ |
658 659 660 661 | shell: """ wget https://hpc.nih.gov/~OpenOmics/common/{params.tarfile} -O {params.outfh} tar vxf {params.outfh} -C {params.outdir} && rm {params.outfh} """ |
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 | run: import json outdir=params.workdir if not outdir.endswith("/"): outdir+="/" refdict = {} refdict["references"] = {} refdict["references"]["rnaseq"] = {} refdict["references"]["rnaseq"]["GENOMEFILE"] = input.fa refdict["references"]["rnaseq"]["GENOME"] = input.fa refdict["references"]["rnaseq"]["GTFFILE"] = input.gtf refdict["references"]["rnaseq"]["GENOME_STARDIR"] = outdir+"STAR/2.7.6a/genome" refdict["references"]["rnaseq"]["ANNOTATE"] = outdir+"annotate.genes.txt" refdict["references"]["rnaseq"]["ANNOTATEISOFORMS"] = outdir+"annotate.isoforms.txt" refdict["references"]["rnaseq"]["REFFLAT"] = outdir+"refFlat.txt" refdict["references"]["rnaseq"]["BEDREF"] = outdir+"genes.ref.bed" refdict["references"]["rnaseq"]["GENEINFO"] = outdir+"geneinfo.bed" refdict["references"]["rnaseq"]["QUALIMAP_INFO"] = outdir+"qualimap_info.txt" refdict["references"]["rnaseq"]["KARYOBEDS"] = outdir+"karyobeds/" refdict["references"]["rnaseq"]["KARYOPLOTER"] = outdir+"karyoplot_gene_coordinates.txt" refdict["references"]["rnaseq"]["RSEMREF"] = outdir+"rsemref/"+params.genome refdict["references"]["rnaseq"]["RRNALIST"] = outdir+params.genome+".rRNA_interval_list" refdict["references"]["rnaseq"]["ORGANISM"] = wildcards.genome refdict["references"]["rnaseq"]["TINREF"] = outdir+"transcripts.protein_coding_only.bed12" refdict["references"]["rnaseq"]["TELESCOPE_ERVS_GTF"] = input.ervs_gtf refdict["references"]["rnaseq"]["ERVS_FAMILY_ANNOTATION_TABLE"]=input.ervs_fam_table # Try to infer which Arriba reference files to add a user defined reference genome if 'hg19' in params.genome.lower() or \ 'hs37d' in params.genome.lower() or \ 'grch37' in params.genome.lower(): refdict["references"]["rnaseq"]["FUSIONBLACKLIST"] = \ "s3://nciccbr/Resources/RNA-seq/arriba/blacklist_hg19_hs37d5_GRCh37_v2.0.0.tsv.gz" refdict["references"]["rnaseq"]["FUSIONCYTOBAND"] = \ "s3://nciccbr/Resources/RNA-seq/arriba/cytobands_hg19_hs37d5_GRCh37_v2.0.0.tsv" refdict["references"]["rnaseq"]["FUSIONPROTDOMAIN"] = \ "s3://nciccbr/Resources/RNA-seq/arriba/protein_domains_hg19_hs37d5_GRCh37_v2.0.0.gff3" elif 'hg38' in params.genome.lower() or \ 'hs38d' in params.genome.lower() or \ 'grch38' in params.genome.lower(): refdict["references"]["rnaseq"]["FUSIONBLACKLIST"] = \ "s3://nciccbr/Resources/RNA-seq/arriba/blacklist_hg38_GRCh38_v2.0.0.tsv.gz" refdict["references"]["rnaseq"]["FUSIONCYTOBAND"] = \ "s3://nciccbr/Resources/RNA-seq/arriba/cytobands_hg38_GRCh38_v2.0.0.tsv" refdict["references"]["rnaseq"]["FUSIONPROTDOMAIN"] = \ "s3://nciccbr/Resources/RNA-seq/arriba/protein_domains_hg38_GRCh38_v2.0.0.gff3" elif 'mm10' in params.genome.lower() or \ 'grcm38' in params.genome.lower(): refdict["references"]["rnaseq"]["FUSIONBLACKLIST"] = \ "s3://nciccbr/Resources/RNA-seq/arriba/blacklist_mm10_GRCm38_v2.0.0.tsv.gz" refdict["references"]["rnaseq"]["FUSIONCYTOBAND"] = \ "s3://nciccbr/Resources/RNA-seq/arriba/cytobands_mm10_GRCm38_v2.0.0.tsv" refdict["references"]["rnaseq"]["FUSIONPROTDOMAIN"] = \ "s3://nciccbr/Resources/RNA-seq/arriba/protein_domains_mm10_GRCm38_v2.0.0.gff3" with open(output.json, 'w') as fp: json.dump(refdict, fp, indent=4) |
36 37 38 | shell: """ python {params.get_flowcell_lanes} {input.R1} {wildcards.name} > {output.fqinfo} """ |
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | shell: """ # Setups temporary directory for # intermediate files with built-in # mechanism for deletion on exit if [ ! -d "{params.tmpdir}" ]; then mkdir -p "{params.tmpdir}"; fi tmp=$(mktemp -d -p "{params.tmpdir}") trap 'rm -rf "${{tmp}}"' EXIT java -Xmx{params.memory}g -XX:ParallelGCThreads={threads} -jar ${{PICARDJARPATH}}/picard.jar AddOrReplaceReadGroups \ I={input.file1} O=${{tmp}}/{params.sampleName}.star_rg_added.sorted.bam \ TMP_DIR=${{tmp}} RGID=id RGLB=library RGPL=illumina RGPU=machine RGSM=sample VALIDATION_STRINGENCY=SILENT; java -Xmx{params.memory}g -XX:ParallelGCThreads={threads} -jar ${{PICARDJARPATH}}/picard.jar MarkDuplicates \ I=${{tmp}}/{params.sampleName}.star_rg_added.sorted.bam \ O=${{tmp}}/{params.sampleName}.star_rg_added.sorted.dmark.bam \ TMP_DIR=${{tmp}} CREATE_INDEX=true VALIDATION_STRINGENCY=SILENT METRICS_FILE={output.metrics}; mv ${{tmp}}/{params.sampleName}.star_rg_added.sorted.dmark.bam {output.bam}; mv ${{tmp}}/{params.sampleName}.star_rg_added.sorted.dmark.bai {output.bai}; sed -i 's/MarkDuplicates/picard.sam.MarkDuplicates/g' {output.metrics}; """ |
103 104 105 | shell:""" preseq c_curve -B -o {output.ccurve} {input.bam} """ |
130 131 132 133 134 | shell: """ unset DISPLAY; qualimap bamqc -bam {input.bamfile} --feature-file {params.gtfFile} \ -outdir {params.outdir} -nt {threads} --java-mem-size={params.memory}G """ |
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | shell: """ # Setups temporary directory for # intermediate files with built-in # mechanism for deletion on exit if [ ! -d "{params.tmpdir}" ]; then mkdir -p "{params.tmpdir}"; fi tmp=$(mktemp -d -p "{params.tmpdir}") trap 'rm -rf "${{tmp}}"' EXIT java -Xmx{params.memory}g -jar ${{PICARDJARPATH}}/picard.jar CollectRnaSeqMetrics \ REF_FLAT={params.refflat} I={input.file1} O={output.outstar1} \ RIBOSOMAL_INTERVALS={params.rrnalist} \ STRAND_SPECIFICITY=SECOND_READ_TRANSCRIPTION_STRAND \ TMP_DIR=${{tmp}} VALIDATION_STRINGENCY=SILENT; sed -i 's/CollectRnaSeqMetrics/picard.analysis.CollectRnaSeqMetrics/g' {output.outstar1} samtools flagstat {input.file1} > {output.outstar2}; python3 {params.statscript} {input.file1} >> {output.outstar2} """ |
210 211 212 213 214 | shell: """ python {params.pythonscript} {params.annotate} {params.inputdir} {params.inputdir} sed 's/\\t/|/1' {output.gene_counts_matrix} | \ sed '1 s/^gene_id|GeneName/symbol/' > {output.reformatted} """ |
236 237 238 239 | shell: """ infer_experiment.py -r {params.bedref} -i {input.file1} -s 1000000 > {output.out1} read_distribution.py -i {input.file1} -r {params.bedref} > {output.out2} """ |
266 267 268 269 270 | shell: """ # tin.py writes to current working directory cd {params.outdir} tin.py -i {input.bam} -r {params.bedref} """ |
291 292 293 | shell: """ python {params.create_matrix} {input.tins} > {output.matrix} """ |
16 17 18 19 20 21 22 23 24 25 26 | run: with open(output.out1, "w") as out: out.write("sampleName\tfileName\tcondition\tlabel\n") i=0 for f in input.files: out.write("{}\t".format(params.allsamples[i])) out.write("{}/{}.star.count.txt\t".format(params.pathprefix, params.allsamples[i])) out.write("{}\t".format(params.groups[i])) out.write("{}\n".format(params.labels[i])) i=i+1 out.close() |
41 42 43 44 45 | shell: """ cd {params.outdir} module load {params.rver} Rscript {params.rscript} '{params.outdir}' '{input.files}' '{params.annotate}' '{input.sampletable}' """ |
64 65 66 67 68 69 | shell: """ cd {params.outdir} module load {params.rver} Rscript {params.rscript1} '{params.outdir}' '{output.outhtml}' \ '{input.file1}' '{input.file2}' '{params.projectId}' '{params.projDesc}' '{params.rscript2}' """ |
30 31 32 33 34 | shell: """ mkdir -p {params.outdir} fastQValidator --noeof --file {input.R1} > {output.out1} fastQValidator --noeof --file {input.R2} > {output.out2} """ |
60 61 62 | shell: """ fastqc {input.R1} {input.R2} -t {threads} -o {params.outdir}; """ |
93 94 95 96 97 98 99 | shell: """ cutadapt --pair-filter=any --nextseq-trim=2 --trim-n \ -n 5 -O 5 -q {params.leadingquality},{params.trailingquality} \ -m {params.minlen}:{params.minlen} \ -b file:{params.fastawithadaptersetd} -B file:{params.fastawithadaptersetd} \ -j {threads} -o {output.out1} -p {output.out2} {input.file1} {input.file2} """ |
126 127 128 | shell: """ fastqc {input.R1} {input.R2} -t {threads} -o {params.outdir}; """ |
155 156 157 158 159 160 161 162 | shell: """ # Get encoding of Phred Quality Scores encoding=$(python {params.encoding} {input.R1}) echo "Detected Phred+${{encoding}} ASCII encoding" bbtools bbmerge-auto in1={input.R1} in2={input.R2} qin=${{encoding}} \ ihist={output} k=62 extend2=200 rem ecct -Xmx{params.memory}G """ |
202 203 204 205 206 207 208 209 210 | shell: """ fastq_screen --conf {params.fastq_screen_config} --outdir {params.outdir} \ --threads {threads} --subset 1000000 \ --aligner bowtie2 --force {input.file1} {input.file2} fastq_screen --conf {params.fastq_screen_config2} --outdir {params.outdir2} \ --threads {threads} --subset 1000000 \ --aligner bowtie2 --force {input.file1} {input.file2} """ |
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | shell: """ # Setups temporary directory for # intermediate files with built-in # mechanism for deletion on exit if [ ! -d "{params.tmpdir}" ]; then mkdir -p "{params.tmpdir}"; fi tmp=$(mktemp -d -p "{params.tmpdir}") trap 'rm -rf "${{tmp}}"' EXIT # Copy kraken2 db to /lscratch or temp # location to reduce filesystem strain cp -rv {params.bacdb} ${{tmp}}/; kdb_base=$(basename {params.bacdb}) kraken2 --db ${{tmp}}/${{kdb_base}} \ --threads {threads} --report {output.krakentaxa} \ --output {output.krakenout} \ --gzip-compressed \ --paired {input.fq1} {input.fq2} # Generate Krona Report cut -f2,3 {output.krakenout} | \ ktImportTaxonomy - -o {output.kronahtml} """ |
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | shell: """ # Setups temporary directory for # intermediate files with built-in # mechanism for deletion on exit if [ ! -d "{params.tmpdir}" ]; then mkdir -p "{params.tmpdir}"; fi tmp=$(mktemp -d -p "{params.tmpdir}") trap 'rm -rf "${{tmp}}"' EXIT # Optimal readlength for sjdbOverhang = max(ReadLength) - 1 [Default: 100] readlength=$( zcat {input.file1} | \ awk -v maxlen=100 'NR%4==2 {{if (length($1) > maxlen+0) maxlen=length($1)}}; \ END {{print maxlen-1}}' ) echo "sjdbOverhang for STAR: ${{readlength}}" STAR --genomeDir {params.stardir} \ --outFilterIntronMotifs {params.filterintronmotifs} \ --outSAMstrandField {params.samstrandfield} \ --outFilterType {params.filtertype} \ --outFilterMultimapNmax {params.filtermultimapnmax} \ --alignSJoverhangMin {params.alignsjoverhangmin} \ --alignSJDBoverhangMin {params.alignsjdboverhangmin} \ --outFilterMismatchNmax {params.filtermismatchnmax} \ --outFilterMismatchNoverLmax {params.filtermismatchnoverlmax} \ --alignIntronMin {params.alignintronmin} \ --alignIntronMax {params.alignintronmax} \ --alignMatesGapMax {params.alignmatesgapmax} \ --clip3pAdapterSeq {params.adapter1} {params.adapter2} \ --readFilesIn {input.file1} {input.file2} \ --readFilesCommand zcat \ --runThreadN {threads} \ --outFileNamePrefix {params.prefix}. \ --outSAMunmapped {params.outsamunmapped} \ --outWigType {params.wigtype} \ --outWigStrand {params.wigstrand} \ --twopassMode Basic \ --sjdbGTFfile {params.gtffile} \ --limitSjdbInsertNsj {params.nbjuncs} \ --quantMode TranscriptomeSAM GeneCounts \ --outSAMtype BAM Unsorted \ --alignEndsProtrude 10 ConcordantPair \ --peOverlapNbasesMin 10 \ --outTmpDir=${{tmp}}/STARtmp_{wildcards.name} \ --sjdbOverhang ${{readlength}} # SAMtools sort (uses less memory than STAR SortedByCoordinate) samtools sort -@ {threads} \ -m 2G -T ${{tmp}}/SORTtmp_{wildcards.name} \ -O bam {params.prefix}.Aligned.out.bam \ > {output.out1} rm {params.prefix}.Aligned.out.bam mv {params.prefix}.Aligned.toTranscriptome.out.bam {workpath}/{bams_dir}; mv {params.prefix}.Log.final.out {workpath}/{log_dir} """ |
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | shell: """ # Setups temporary directory for # intermediate files with built-in # mechanism for deletion on exit if [ ! -d "{params.tmpdir}" ]; then mkdir -p "{params.tmpdir}"; fi tmp=$(mktemp -d -p "{params.tmpdir}") trap 'rm -rf "${{tmp}}"' EXIT # Optimal readlength for sjdbOverhang = max(ReadLength) - 1 [Default: 100] readlength=$( zcat {input.file1} | \ awk -v maxlen=100 'NR%4==2 {{if (length($1) > maxlen+0) maxlen=length($1)}}; \ END {{print maxlen-1}}' ) echo "sjdbOverhang for STAR: ${{readlength}}" STAR --genomeDir {params.stardir} \ --outFilterIntronMotifs {params.filterintronmotifs} \ --outSAMstrandField {params.samstrandfield} \ --outFilterType {params.filtertype} \ --outFilterMultimapNmax {params.filtermultimapnmax} \ --alignSJoverhangMin {params.alignsjoverhangmin} \ --alignSJDBoverhangMin {params.alignsjdboverhangmin} \ --outFilterMismatchNmax {params.filtermismatchnmax} \ --outFilterMismatchNoverLmax {params.filtermismatchnoverlmax} \ --alignIntronMin {params.alignintronmin} \ --alignIntronMax {params.alignintronmax} \ --alignMatesGapMax {params.alignmatesgapmax} \ --clip3pAdapterSeq {params.adapter1} {params.adapter2} \ --readFilesIn {input.file1} {input.file2} \ --readFilesCommand zcat \ --runThreadN {threads} \ --outFileNamePrefix {params.prefix}. \ --outSAMtype BAM Unsorted \ --alignEndsProtrude 10 ConcordantPair \ --peOverlapNbasesMin 10 \ --sjdbGTFfile {params.gtffile} \ --outTmpDir=${{tmp}}/STARtmp_{wildcards.name} \ --sjdbOverhang ${{readlength}} """ |
493 494 495 496 497 498 499 500 | shell: """ cat {input.files} | \ sort | \ uniq | \ awk -F \"\\t\" '{{if ($5>0 && $6==1) {{print}}}}'| \ cut -f1-4 | sort | uniq | \ grep \"^chr\" | grep -v \"^chrM\" > {output.out1} """ |
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | shell: """ # Setups temporary directory for # intermediate files with built-in # mechanism for deletion on exit if [ ! -d "{params.tmpdir}" ]; then mkdir -p "{params.tmpdir}"; fi tmp=$(mktemp -d -p "{params.tmpdir}") trap 'rm -rf "${{tmp}}"' EXIT # Optimal readlength for sjdbOverhang = max(ReadLength) - 1 [Default: 100] readlength=$( zcat {input.file1} | \ awk -v maxlen=100 'NR%4==2 {{if (length($1) > maxlen+0) maxlen=length($1)}}; \ END {{print maxlen-1}}' ) echo "sjdbOverhang for STAR: ${{readlength}}" STAR --genomeDir {params.stardir} \ --outFilterIntronMotifs {params.filterintronmotifs} \ --outSAMstrandField {params.samstrandfield} \ --outFilterType {params.filtertype} \ --outFilterMultimapNmax {params.filtermultimapnmax} \ --alignSJoverhangMin {params.alignsjoverhangmin} \ --alignSJDBoverhangMin {params.alignsjdboverhangmin} \ --outFilterMismatchNmax {params.filtermismatchnmax} \ --outFilterMismatchNoverLmax {params.filtermismatchnoverlmax} \ --alignIntronMin {params.alignintronmin} \ --alignIntronMax {params.alignintronmax} \ --alignMatesGapMax {params.alignmatesgapmax} \ --clip3pAdapterSeq {params.adapter1} {params.adapter2} \ --readFilesIn {input.file1} {input.file2} \ --readFilesCommand zcat \ --runThreadN {threads} \ --outFileNamePrefix {params.prefix}. \ --outSAMunmapped {params.outsamunmapped} \ --outWigType {params.wigtype} \ --outWigStrand {params.wigstrand} \ --sjdbFileChrStartEnd {input.tab} \ --sjdbGTFfile {params.gtffile} \ --limitSjdbInsertNsj {params.nbjuncs} \ --quantMode TranscriptomeSAM GeneCounts \ --outSAMtype BAM Unsorted \ --alignEndsProtrude 10 ConcordantPair \ --peOverlapNbasesMin 10 \ --outTmpDir=${{tmp}}/STARtmp_{wildcards.name} \ --sjdbOverhang ${{readlength}} # SAMtools sort (uses less memory than STAR SortedByCoordinate) samtools sort -@ {threads} \ -m 2G -T ${{tmp}}/SORTtmp_{wildcards.name} \ -O bam {params.prefix}.Aligned.out.bam \ > {output.out1} rm {params.prefix}.Aligned.out.bam mv {params.prefix}.Aligned.toTranscriptome.out.bam {workpath}/{bams_dir}; mv {params.prefix}.Log.final.out {workpath}/{log_dir} """ |
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 | shell: """ # Setups temporary directory for # intermediate files with built-in # mechanism for deletion on exit if [ ! -d "{params.tmpdir}" ]; then mkdir -p "{params.tmpdir}"; fi tmp=$(mktemp -d -p "{params.tmpdir}") trap 'rm -rf "${{tmp}}"' EXIT # Optimal readlength for sjdbOverhang = max(ReadLength) - 1 [Default: 100] readlength=$( zcat {input.R1} | \ awk -v maxlen=100 'NR%4==2 {{if (length($1) > maxlen+0) maxlen=length($1)}}; \ END {{print maxlen-1}}' ) # Avoids inheriting $R_LIBS_SITE # from local env variables R_LIBS_SITE=/usr/local/lib/R/site-library STAR --runThreadN {threads} \ --sjdbGTFfile {params.gtffile} \ --sjdbOverhang ${{readlength}} \ --genomeDir {params.stardir} \ --genomeLoad NoSharedMemory \ --readFilesIn {input.R1} {input.R2} \ --readFilesCommand zcat \ --outStd BAM_Unsorted \ --outSAMtype BAM Unsorted \ --outSAMunmapped Within \ --outFilterMultimapNmax 50 \ --peOverlapNbasesMin 10 \ --alignSplicedMateMapLminOverLmate 0.5 \ --alignSJstitchMismatchNmax 5 -1 5 5 \ --chimSegmentMin 10 \ --chimOutType WithinBAM HardClip \ --chimJunctionOverhangMin 10 \ --chimScoreDropMax 30 \ --chimScoreJunctionNonGTAG 0 \ --chimScoreSeparation 1 \ --chimSegmentReadGapMax 3 \ --chimMultimapNmax 50 \ --twopassMode Basic \ --outTmpDir=${{tmp}}/STARtmp_{wildcards.name} \ --outFileNamePrefix {params.prefix}. \ | tee ${{tmp}}/{params.chimericbam} | \ arriba -x /dev/stdin \ -o {output.fusions} \ -O {output.discarded} \ -a {params.reffa} \ -g {params.gtffile} \ -b {input.blacklist} \ # Sorting and Indexing BAM files is required for Arriba's Visualization samtools sort -@ {threads} \ -m 2G -T ${{tmp}}/SORTtmp_{wildcards.name} \ -O bam ${{tmp}}/{params.chimericbam} \ > {output.bam} samtools index {output.bam} {output.bai} rm ${{tmp}}/{params.chimericbam} # Generate Gene Fusions Visualization draw_fusions.R \ --fusions={output.fusions} \ --alignments={output.bam} \ --output={output.figure} \ --annotation={params.gtffile} \ --cytobands={input.cytoband} \ --proteinDomains={input.protdomain} """ |
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 | shell: """ # Setups temporary directory for # intermediate files with built-in # mechanism for deletion on exit if [ ! -d "{params.tmpdir}" ]; then mkdir -p "{params.tmpdir}"; fi tmp=$(mktemp -d -p "{params.tmpdir}") trap 'rm -rf "${{tmp}}"' EXIT # Get strandedness to calculate Forward Probability fp=$(tail -n1 {input.file2} | awk '{{if($NF > 0.75) print "0.0"; else if ($NF<0.25) print "1.0"; else print "0.5";}}') echo "Forward Probability Passed to RSEM: $fp" rsem-calculate-expression --no-bam-output --calc-ci --seed 12345 \ --bam --paired-end -p {threads} {input.file1} {params.rsemref} {params.prefix} --time \ --temporary-folder ${{tmp}} --keep-intermediate-files --forward-prob=${{fp}} --estimate-rspd """ |
787 788 789 790 | shell: """ inner_distance.py -i {input.bam} -r {params.genemodel} \ -k 10000000 -o {params.prefix} """ |
819 820 821 822 823 824 825 826 827 828 829 | shell: """ bash {params.bashscript} {input.bam} {params.outprefix} # reverse files if method is not dUTP/NSR/NNSR ... ie, R1 in the direction of RNA strand. strandinfo=`tail -n1 {input.strandinfo} | awk '{{print $NF}}'` if [ `echo "$strandinfo < 0.25"|bc` -eq 1 ];then mv {output.fbw} {output.fbw}.tmp mv {output.rbw} {output.fbw} mv {output.fbw}.tmp {output.rbw} fi """ |
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 | shell: """ multiqc --ignore '*/.singularity/*' -f -c {params.qcconfig} --interactive --outdir {params.outdir} {params.workdir} # Parse RSeQC Inner Distance Maximas echo -e "Sample\\tInner_Dist_Maxima" > {output.maximas} for f in $(find {params.workdir} -iname '*.inner_distance_freq.txt'); do sample=$(basename "${{f}}"); inner_dist_maxima=$(sort -k3,3nr "${{f}}" | awk -F '\\t' 'NR==1{{print $1}}'); echo -e "${{sample}}\\t${{inner_dist_maxima}}"; done >> {output.maximas} # Parse RSeQC Median TINs echo -e "Sample\\tmedian_tin" > {output.medtins} find {params.workdir} -name '*.star_rg_added.sorted.dmark.summary.txt' -exec cut -f1,3 {{}} \\; | \ grep -v '^Bam_file' | \ awk -F '\\t' '{{printf "%s\\t%.3f\\n", $1,$2}}' >> {output.medtins} # Parse Flowcell and Lane information echo -e "Sample\\tflowcell_lanes" > {output.fclanes} find {params.workdir} -name '*.fastq.info.txt' -exec awk -F '\\t' -v OFS='\\t' 'NR==2 {{print $1,$5}}' {{}} \\; \ >> {output.fclanes} python3 {params.pyparser} {params.logfiles} {params.outdir} """ |
926 927 928 929 930 931 932 933 934 935 | shell: """ # Generate RNA QC Dashboard {params.rwrapper} \ -m {params.rmarkdown} \ -r {input.counts} \ -t {input.tins} \ -q {input.qc} \ -o {params.odir} \ -f RNA_Report.html """ |
949 950 951 952 953 954 955 956 | shell: """ mkdir -p {params.outdir} cd {params.outdir} samtools sort -n -O bam -@ 10 {input.bam} > {output.sorted} telescope assign {output.sorted} \ --attribute transcript_id {params.gtf_file} \ --exp_tag {params.name} """ |
973 974 975 976 977 978 979 980 981 | shell:""" set +u if [ "{params.mode}" == "uge" ]; then module load R else module load R/4.1.3 fi Rscript {params.rmerger} -tsvs {input} {params.ervs_fam_table} -dir {params.outdir} """ |
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://openomics.github.io/ervx/
Name:
ervx
Version:
1
Downloaded:
0
Copyright:
Public Domain
License:
MIT License
Keywords:
- 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...