Question: How I know a file is sam or bam, sorted or unsorted
0
gravatar for A
12 months ago by
A3.9k
A3.9k 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 • 766 views
ADD COMMENTlink modified 12 months ago by Arup Ghosh2.7k • written 12 months ago by A3.9k
5
gravatar for Arup Ghosh
12 months ago by
Arup Ghosh2.7k
India
Arup Ghosh2.7k wrote:

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

ADD COMMENTlink written 12 months ago by Arup Ghosh2.7k
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 12 months ago • written 12 months ago by Friederike6.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 12 months ago by A3.9k
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 12 months ago • written 12 months ago by Friederike6.2k
3
gravatar for Arup Ghosh
12 months ago by
Arup Ghosh2.7k
India
Arup Ghosh2.7k 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 12 months ago by Arup Ghosh2.7k

This is the results

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

Unsorted?

ADD REPLYlink written 12 months ago by A3.9k

Yes the output is unsorted.

ADD REPLYlink written 12 months ago by Arup Ghosh2.7k

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 12 months ago by A3.9k

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 12 months ago by 27atcggcta27160
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: 1346 users visited in the last hour