From aee27463cd159d14d3c9c37fae1d61d8b8a8badd Mon Sep 17 00:00:00 2001
From: xgrand <xavier.grand@ens-lyon.fr>
Date: Thu, 9 Sep 2021 12:38:21 +0200
Subject: [PATCH] =?UTF-8?q?modif=20pipeline=20bamcoverage=20deeptools=20po?=
 =?UTF-8?q?ur=20chipseq=20et=20param=C3=A8tres?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/chipster.nf                  | 20 ++++++++++++++++----
 src/nf_modules/bedtools/main.nf  | 26 ++++++++++++++++++++++++++
 src/nf_modules/deeptools/main.nf | 27 +++++++++++++++++++++++++++
 3 files changed, 69 insertions(+), 4 deletions(-)

diff --git a/src/chipster.nf b/src/chipster.nf
index 61cf3041..4af93862 100755
--- a/src/chipster.nf
+++ b/src/chipster.nf
@@ -58,6 +58,8 @@ params.bam_to_bigwig_out = "$params.project/BigWig/"
 params.peak_calling_bg_out = "$params.project/Peak_calling/"
 params.bam_to_bed_out = "$params.project/Bed/"
 params.bed_slop_out = "$params.project/Bed_sloped/"
+params.bedGraph_out = "$params.project/BedGraph/"
+params.chipseq_bam2BG_out = "$params.project/chipseq_BigGig"
 
 /*
  ****************************************************************
@@ -148,9 +150,11 @@ include { filter_bam_quality } from "./nf_modules/samtools/main.nf"
 include { sort_bam } from "./nf_modules/samtools/main.nf"
 include { index_bam } from "./nf_modules/samtools/main.nf"
 include { bam_to_bigwig } from "./nf_modules/deeptools/main.nf"
+include { chipseq_bam2BG } from "./nf_modules/deeptools/main.nf"
 include { peak_calling_bg } from "./nf_modules/macs3/main.nf"
 include { bam_to_bed } from "./nf_modules/bedtools/main.nf"
 include { bed_slop } from "./nf_modules/bedtools/main.nf"
+include { bed_to_bedGraph } from "./nf_modules/bedtools/main.nf"
 
 /*
  ****************************************************************
@@ -159,11 +163,12 @@ include { bed_slop } from "./nf_modules/bedtools/main.nf"
 */
 
 workflow {
-  // fastq_files.view() // Pour voir les fichier qui sont chargés
 
   // fastp
   fastp_default(fastq_files)
   
+
+  /*
   // fastqc_rawdata
   fastqc_raw(fastq_files)
   // fastqc_processed
@@ -175,6 +180,7 @@ workflow {
       fastqc_preprocessed.out.report
       ).collect()
   )
+  */
 
   // index reference genome
   index_fasta(genome_file)
@@ -196,16 +202,22 @@ workflow {
   sort_bam(filter_bam_quality.out.bam)
 
   // samtools_index
-  // index_bam(sort_bam.out.bam.collect())
+  index_bam(sort_bam.out.bam)
 
   // Create a bigwig file
   // bam_to_bigwig(index_bam.out.bam_idx)
 
+  // Chipseq Bam 2 bigwig file with reads extends
+  chipseq_bam2BG(index_bam.out.bam_idx)
+
   // From Bam to Bed
-  bam_to_bed(sort_bam.out.bam)
+  // bam_to_bed(sort_bam.out.bam)
 
   // Extension of reads with bedtools slop
-  bed_slop(bam_to_bed.out.bed, genome_sizes.collect())
+  // bed_slop(bam_to_bed.out.bed, genome_sizes.collect())
+
+  // From bed to bedgraph
+  // bed_to_bedGraph(bed_slop.out, genome_sizes.collect())
 
   // peak calling using MACS3 Prend des bed ou des bam en entrée...
   // peak_calling_bg()
diff --git a/src/nf_modules/bedtools/main.nf b/src/nf_modules/bedtools/main.nf
index 6826615f..bc017708 100644
--- a/src/nf_modules/bedtools/main.nf
+++ b/src/nf_modules/bedtools/main.nf
@@ -168,4 +168,30 @@ bedtools slop -s -r 100 -l 0 \
   -g ${chromsizes} \
   > ${bed.simpleName}_sloped.bed
 """
+}
+
+params.bedGraph = ""
+params.bedGraph_out = ""
+process bed_to_bedGraph {
+  container = "${container_url}"
+  label "big_mem_mono_cpus"
+  tag "${bed_id}"
+  if (params.bedGraph_out != "") {
+    publishDir "results/${params.bedGraph_out}", mode: 'copy'
+  }
+
+  input:
+  tuple val(bed_id), path(bed)
+  tuple val(file_id), path(chromsizes)
+
+  output:
+  tuple val(bed_id), path("*.bg"), emit: bedGraph
+
+  script:
+"""
+bedtools genomecov -bg\
+  -i ${bed} \
+  -g ${chromsizes} \
+  > ${bed.simpleName}.bg
+"""
 }
\ No newline at end of file
diff --git a/src/nf_modules/deeptools/main.nf b/src/nf_modules/deeptools/main.nf
index 25468706..8a4b7932 100644
--- a/src/nf_modules/deeptools/main.nf
+++ b/src/nf_modules/deeptools/main.nf
@@ -104,3 +104,30 @@ plotProfile -m ${matrix} \
   --plotTitle "${params.title}"
 """
 }
+
+params.chipseq_bam2BG = ""
+params.chipseq_bam2BG_out = ""
+process chipseq_bam2BG {
+  container = "${container_url}"
+  label "big_mem_multi_cpus"
+  tag "$file_id"
+  if (params.chipseq_bam2BG_out != "") {
+    publishDir "results/${params.chipseq_bam2BG_out}", mode: 'copy'
+  }
+
+  input:
+    tuple val(file_id), path(bam), path(idx)
+
+  output:
+    tuple val(file_id), path("*.bw"), emit: bw
+
+  script:
+"""
+bamCoverage -p ${task.cpus} -b ${bam} \
+  --binSize 10 \
+  --ignoreDuplicates \
+  --extendReads 200 \
+  --effectiveGenomeSize 2913022398 \
+  -o ${bam.simpleName}.bw \
+"""
+}
\ No newline at end of file
-- 
GitLab