Extract counts from paired end bam files
1
0
Entering edit mode
2.6 years ago
minoo ▴ 10

I have two bam file for each sample which are paired end sequenced. I need to extract raw counts from these bam files which they look like S1.bam and s2.bam for each sample. I founf these by a search but still don't know how to move forward as they are paired end and two bam files.

featureCounts -T 4 -s 2 \   -a ~/annotations/Homo_sapiens.GRCh38.104.gtf
\   -o ~/results/counts/s1_featurecounts.txt \  
~/results/STAR/bams/*.out.bam

Apparently as they are paired, they need to be sorted by

samtools sort

but I don’t know how to make a single bam file from the two paired that I already have. And how to insert it in this formula. Any help would be appreciated.

featureCounts fastqc STAR samtools • 1.3k views
ADD COMMENT
2
Entering edit mode
2.6 years ago
ATpoint 85k

It's far simpler than you probably think. featureCounts will sort paired-end files as needed if you tell it that the data are paired. You don't need to manually do any sorting or indexing. In fact I never sort files from STAR as featureCounts anyway would sort them back by name in case of paired-end data.

#/ The -p flag tells it to consider the files as paired-end
featureCounts -T 4 -s 2 -a ~/annotations/Homo_sapiens.GRCh38.104.gtf \
  -p \
  -o ~/results/counts/s1_featurecounts.txt \
  ~/results/STAR/bams/*.out.bam

There is not more to do, no merging or whatever.

ADD COMMENT
0
Entering edit mode

Thanks for your quick resoponse ATpoint , but how can I add my two paired bam files here in this formula?

ADD REPLY
1
Entering edit mode

It's the ~/results/STAR/bams/*.out.bam part, it means "use all bam files". Alternatively replace that with the paths to your bam files.

ADD REPLY
0
Entering edit mode

how can I add my two paired bam files here in this formula?

I hope you did not align your paired-end reads independently i.e. Read 1 is in S1.bam and R2 is in S2.bam. That would be incorrect. You have to align paired-end data in a single alignment run.

ADD REPLY
0
Entering edit mode

I didn't align anything. I just put two end paired bam files that I had in a folder and run the above code by changing only .out.bam to .bam. This worked but I don't know if this is correct or not.

ADD REPLY
0
Entering edit mode

BAM files are not paired-end but they can have alignments that came from a paired-end dataset. Hopefully that is clear.

ADD REPLY
0
Entering edit mode

Two bams implies two different samples. You could combine them if you are sure they are the same thing, but it doesn't sound like you are sure.

ADD REPLY

Login before adding your answer.

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