1
$\begingroup$

Im trying to follow this pipeline https://github.com/epifluidlab/cragr on cfDNA WGS. I have bam files from paired end reads aligned with bwa mem.

The workflow requires bgzipped and indexed fragment data files as input. enter image description here

I have been searching how can I obtain BED files from fragments coordinates instead of reads coordinates, and came up with no answer.

Does someone know how can I obtain such bed file?

$\endgroup$
2
  • $\begingroup$ Hi, what do you mean? :) I don't know how to do it. I'm familiar with bamtobed from bedtools but that gives me a bed file based on reads. I need a bed file based on fragments instead :) $\endgroup$
    – Julieta
    Aug 1, 2023 at 19:45
  • $\begingroup$ I see so you are looking whether there is a bedtools option for fragment output. Got it, thanks. Would be good to modify the question with the info. $\endgroup$
    – M__
    Aug 1, 2023 at 21:39

1 Answer 1

2
$\begingroup$

There's an example in the README (https://github.com/epifluidlab/cragr#example-datasets):

For you information, below are steps from the BAM file to the fragment file:

samtools sort -n -o qsorted.bam -@ 4 sample.bam
samtools view -h -f 3 -F 3852 -G 48 --incl-flags 48 qsorted.bam |\
  bamToBed -bedpe -mate1 -i stdin |\
  awk -F'\t' -v OFS="\t" '{if ($1!=$4) next; if ($9=="+") {s=$2;e=$6} else {s=$5;e=$3} if (e>s) print $1,s,e,$7,$8,$9}' |\
  sort -k1,1V -k2,2n |\
  bgzip > sample.frag.bed.gz
tabix -p bed sample.frag.bed.gz
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.