Split merged Bam file without replacement
0
0
Entering edit mode
2.6 years ago
g.persic1991 ▴ 10

Hi guys,

I have 5 bam (ChIPseq PE data sorted by position) files that came from 5 different murine cortexes (mice that belong to the same group, so biological replicates), however I have a lot of group variability. I'm thinking to merge all this 5 bam (I know that is a dirty things) in order to make a unique bam file (already done using samtools merge) and then split (in a random way) in 5 new bam files... I'll use they to make a Differential analysis with DiffBind

However I don't find a way to split it.

I have try with following command (that allow to split just in 2 bam files...that for now could be a good starting point)

samtools view -H test.bam > f1.sam
cp f1.sam f2.sam
samtools view test.bam | awk '{if(NR%4<2){print >> "f1.sam"} else {print >> "f2.sam"}}'

but seem that the new bam files has some problem because when I try to count the reads in each bam file using

samtools view -c f1.sam > reads.txt 

I obtain the following error

[E::sam_parse1] no SQ lines present in the headerls view -c f2.sam  > reads.txt 
[main_samview] truncated file.

Please, can someone help me?

samtools • 637 views
ADD COMMENT
0
Entering edit mode

I don't really understand what's your aim. Nevertheless what is the output of :

samtools view -H test.bam | grep SQ
ADD REPLY
0
Entering edit mode

Below the output

@SQ SN:chr1 LN:195471971
@SQ SN:chr2 LN:182113224
@SQ SN:chr3 LN:160039680
@SQ SN:chr4 LN:156508116
@SQ SN:chr5 LN:151834684
@SQ SN:chr6 LN:149736546
@SQ SN:chr7 LN:145441459
@SQ SN:chr8 LN:129401213
@SQ SN:chr9 LN:124595110
@SQ SN:chr10    LN:130694993
@SQ SN:chr11    LN:122082543
@SQ SN:chr12    LN:120129022
@SQ SN:chr13    LN:120421639
@SQ SN:chr14    LN:124902244
@SQ SN:chr15    LN:104043685
@SQ SN:chr16    LN:98207768
@SQ SN:chr17    LN:94987271
@SQ SN:chr18    LN:90702639
@SQ SN:chr19    LN:61431566
@SQ SN:chrX LN:171031299
@SQ SN:chrY LN:91744698
@SQ SN:chrM LN:16299
ADD REPLY

Login before adding your answer.

Traffic: 1807 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