diff --git a/src/nf_modules/danpos/main.nf b/src/nf_modules/danpos/main.nf
index bb8a8ed72d272276dd6aa00569487446f84751ca..a099b713c2d999d6cdbf38fedd73c88417124677 100644
--- a/src/nf_modules/danpos/main.nf
+++ b/src/nf_modules/danpos/main.nf
@@ -12,12 +12,13 @@ params.dpos_out = ""
 
 workflow dpos_bam_bg {
   take:
+    fasta
     fastq
     bam
 
   main:
     dpos_bam(fastq, bam)
-    wig2_to_bedgraph2(dpos_bam.out.wig)
+    wig2_to_bedgraph2(fasta, dpos_bam.out.wig)
 
   emit:
     bedgraph = wig2_to_bedgraph2.out.bedgraph
@@ -249,10 +250,11 @@ awk -v FS='\t' -v OFS='\t' 'FNR > 1 { print \$1, \$4-1, \$4, "Interval_"NR-1, \$
 
 workflow dpeak_bw {
   take:
+    fasta
     fastq
     bw
   main:
-    dpeak_wig(fastq, bigwig2_to_wig2(bw))
+    dpeak_wig(fasta, fastq, bigwig2_to_wig2(bw))
     wig2_to_bedgraph2(dpeak_wig.out.wig)
 
   emit:
@@ -311,6 +313,7 @@ awk -v FS='\t' -v OFS='\t' 'FNR > 1 { print \$1, \$4-1, \$4, "Interval_"NR-1, \$
 
 workflow dpeak_bwvsbw {
   take:
+    fasta
     fastq
     bw_a
     bw_b
@@ -320,7 +323,7 @@ workflow dpeak_bwvsbw {
       bigwig2_to_wig2(bw_a),
       bigwig2_to_wig2(bw_b),
     )
-    wig2_to_bedgraph2(dpeak_wigvswig.out.wig)
+    wig2_to_bedgraph2(fasta, dpeak_wigvswig.out.wig)
 
   emit:
   bedgraph = wig2_to_bedgraph2.out.bedgraph
diff --git a/src/nf_modules/ucsc/main.nf b/src/nf_modules/ucsc/main.nf
index 369a00d608f2a95ff98521febd1f9861e5769d24..77d9169532daa9ebe83b9e313f243cc07dc0d72f 100644
--- a/src/nf_modules/ucsc/main.nf
+++ b/src/nf_modules/ucsc/main.nf
@@ -37,46 +37,80 @@ sort -T ./ -k1,1 -k2,2n ${bg} > \
 
 params.wig_to_bedgraph = ""
 params.wig_to_bedgraph_out = ""
-process wig_to_bedgraph {
+workflow wig_to_bedgraph {
+  take:
+    fasta
+    wig
+  main:
+    wig_to_bigwig(
+      fasta,
+      wig
+    )
+    wig_to_bedgraph(
+      wig_to_bigwig.out.bw
+    )
+  emit:
+  bg = wig_to_bigwig.out.bg
+}
+
+workflow wig2_to_bedgraph2 {
+  take:
+    fasta
+    wig
+  main:
+    wig2_to_bigwig2(
+      fasta,
+      wig
+    )
+    wig2_to_bedgraph2(
+      wig2_to_bigwig2.out.bw
+    )
+  emit:
+  bg = wig2_to_bigwig2.out.bg
+}
+
+params.bigwig_to_bedgraph = ""
+params.bigwig_to_bedgraph_out = ""
+process bigwig_to_bedgraph {
   container = "${container_url}"
   label "big_mem_mono_cpus"
   tag "${file_id}"
-  if (params.wig_to_bedgraph_out != "") {
-    publishDir "results/${params.wig_to_bedgraph_out}", mode: 'copy'
+  if (params.bigwig_to_bedgraph_out != "") {
+    publishDir "results/${params.bigwig_to_bedgraph_out}", mode: 'copy'
   }
 
   input:
-  tuple val(file_id), path(wig)
+  tuple val(file_id) path(bw)
 
   output:
-  tuple val(file_id), path("${wig.simpleName}.bg"), emit: bedgraph
+  tuple val(file_id), path("*.bg"), emit: bg
 
   script:
 """
-awk '{print \$1"\\t"\$2-1"\\t"\$2"\\t"\$3}' ${wig} > ${wig.simpleName}.bg
+bigWigToBedGraph ${bw} ${bw.simpleName}.bg
 """
 }
 
-params.wig2_to_bedgraph2 = ""
-params.wig2_to_bedgraph2_out = ""
-process wig2_to_bedgraph2 {
+params.bigwig2_to_bedgraph2 = ""
+params.bigwig2_to_bedgraph2_out = ""
+process bigwig2_to_bedgraph2 {
   container = "${container_url}"
   label "big_mem_mono_cpus"
   tag "${file_id}"
-  if (params.wig2_to_bedgraph2_out != "") {
-    publishDir "results/${params.wig2_to_bedgraph2_out}", mode: 'copy'
+  if (params.bigwig_to_bedgraph_out != "") {
+    publishDir "results/${params.bigwig_to_bedgraph_out}", mode: 'copy'
   }
 
   input:
-  tuple val(file_id), path(wig_a), path(wig_b)
+  tuple val(file_id), path(bw_a), path(bw_b)
 
   output:
-  tuple val(file_id), path("${wig_a.simpleName}.bg"), path("${wig_b.simpleName}.bg"), emit: bedgraph
+  tuple val(file_id), path("${bw_a.simpleName}.bg"), path("${bw_b.simpleName}.bg"), emit: bg
 
   script:
 """
-awk '{print \$1"\\t"\$2-1"\\t"\$2"\\t"\$3}' ${wig_a} > ${wig_a.simpleName}.bg
-awk '{print \$1"\\t"\$2-1"\\t"\$2"\\t"\$3}' ${wig_b} > ${wig_b.simpleName}.bg
+bigWigToBedGraph ${bw_a} ${bw_a.simpleName}.bg
+bigWigToBedGraph ${bw_b} ${bw_b.simpleName}.bg
 """
 }