Extract bed regions from CRAM files
2
0
Entering edit mode
4.2 years ago
MAPK ★ 2.1k

Hi Everyone,

I have several hundreds of cram files. I need to extract some bed regions from these files. Is there a way to extract bed regions from cram without unwrapping them to BAM? My final output should be BAM file for selected regions for each sample.

BAM CRAM • 3.3k views
ADD COMMENT
2
Entering edit mode
4.2 years ago
ATpoint 85k

In general the -L option works for CRAM (according to the manual) same as it does for BAM given you indexed them with samtools index.

samtools view --reference ref.fa -L your.bed -o overlaps.bam your.cram
ADD COMMENT
0
Entering edit mode
4.2 years ago
 samtools view -b --reference ref.fa in.cram | bedtools bamtobed -i stdin
ADD COMMENT
0
Entering edit mode

Hi Pierre, I am starting with CRAM not BAM.

ADD REPLY
0
Entering edit mode

Hi Peter, I am starting with CRAM not BAM.

fixed

ADD REPLY
1
Entering edit mode

Added -b to your command to avoid unheadered SAM output :)

ADD REPLY
0
Entering edit mode

ah yes ! thanks you ! :-)

ADD REPLY
0
Entering edit mode

How is the solution addressing this requirement?

My final output should be BAM file for selected regions for each sample.

ADD REPLY
0
Entering edit mode

Not sure why this gives me error, but @ATpoint's answer works great.

 [an@user]$ samtools view -b --reference /home/all_sequences.fa /40/AD/XX^92XX^0319.cram | bedtools bamtobed -i genes_build37.bed-hg38
    [W::sam_read1] Parse error at line 1
    Failed to open BAM file ades_genes_build37.bed-hg38
ADD REPLY

Login before adding your answer.

Traffic: 1832 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6