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.
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
2 answers
Check the error log if STAR had any memory issues, --outSAMtype BAM SortedByCoordinate is supposed to sort the output.
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
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.
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 .
This is the results
[fi1d18@cyan01 ~]$ samtools view -H Aligned.out.sam |grep "@HD"
@HD VN:1.4
[fi1d18@cyan01 ~]$
Unsorted?
Yes the output is unsorted.
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
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
Log in to answer this question.