Question: How I know a file is sam or bam, sorted or unsorted
0
gravatar for A
6 weeks ago by
A3.5k
A3.5k wrote:

Hi

I have a file by STAR alignment, I supposed to get a bam file but I obtained Aligned.out.sam

Is there any command to check if this file is a .bam or .sam file? A command to check this file sorted or unsorted?

Thank you so much

rna-seq alignment • 233 views
ADD COMMENTlink modified 6 weeks ago by arup1.9k • written 6 weeks ago by A3.5k
5
gravatar for arup
6 weeks ago by
arup1.9k
India
arup1.9k wrote:

Check the error log if STAR had any memory issues, --outSAMtype BAM SortedByCoordinate is supposed to sort the output.

ADD COMMENTlink written 6 weeks ago by arup1.9k
1

Just to follow up on Arup's advice -- given that you seem to have generated a SAM file instead of a BAM file, it seems highly likely that the conversion and sorting failed [EDIT:], therefore it would be highly advisable to understand what caused STAR to not honor your parameter choices, i.e. read the log file(s) and see if you can pinpoint the error that must have occurred.

ADD REPLYlink modified 6 weeks ago • written 6 weeks ago by Friederike5.2k

This command gave sorted bam using STAR

STAR --runThreadN 4 --genomeDir ./STAR_hg38_Genome --readFilesIn 1.fastq 2.fastq --limitBAMsortRAM 64606632121 --outFileNamePrefix ./SeqBatch2/ --outSAMtype BAM   SortedByCoordinate --outSAMmode Full --outSAMstrandField intronMotif
ADD REPLYlink written 5 weeks ago by A3.5k
1

So it was a problem with the memory. It'd be great if you could accept the answer that suggested that so that other users in the future will be pointed to the right track immediately.

ADD REPLYlink modified 5 weeks ago • written 5 weeks ago by Friederike5.2k
3
gravatar for arup
6 weeks ago by
arup1.9k
India
arup1.9k wrote:

Check the bam/sam file header line using samtools samtools view -H Aligned.out.sam |grep "@HD" if you see SO:coordinate is present, it means the output is sorted. For STAR sorted/unsorted output check the STAR aligner manual section 4.3 .

ADD COMMENTlink written 6 weeks ago by arup1.9k

This is the results

[fi1d18@cyan01 ~]$ samtools view -H Aligned.out.sam |grep "@HD"
@HD     VN:1.4
[fi1d18@cyan01 ~]$

Unsorted?

ADD REPLYlink written 6 weeks ago by A3.5k

Yes the output is unsorted.

ADD REPLYlink written 6 weeks ago by arup1.9k

That means this STAR command does not work

STAR --genomeDir ./STAR_hg38_Genome --readFilesIn ./1.fastq ./2.fastq --outSAMtype BAM SortedByCoordinate

Because I expected by adding --outSAMtype BAM SortedByCoordinate to STAR alignment I am getting a sorted .bam as output

ADD REPLYlink written 6 weeks ago by A3.5k

you could try to output both and see if there is a difference,

--outSAMtype BAM Unsorted SortedByCoordinate

check both files to see if either is sorted

ADD REPLYlink written 6 weeks ago by 27atcggcta27120
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2541 users visited in the last hour