This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Cuffdiff Says Sam Isn'T Sorted, Although It Handled It Cufflinks

Hi all, I'm having an issue with cufflinks in that I can get through cufflinks with a de novo, but am halted here:

cuffdiff -o diffout -b annolrubtran.fasta -p 20 -L 0mg,36mg,125mg -u cuffcmp.combined.gtf ./tophat008paired/acceptedhits.sam.sorted ./tophat009paired/acceptedhits.sam.sorted ./tophat010paired/acceptedhits.sam.sorted You are using Cufflinks v1.3.0, which is the most recent release. [bamheaderread] EOF marker is absent. [bamheaderread] invalid BAM binary header (this is not a BAM file). File ./tophat008paired/acceptedhits.sam.sorted doesn't appear to be a valid BAM file, trying SAM... [bamheaderread] EOF marker is absent. [bamheaderread] invalid BAM binary header (this is not a BAM file). File ./tophat009paired/acceptedhits.sam.sorted doesn't appear to be a valid BAM file, trying SAM... [bamheaderread] EOF marker is absent. [bamheaderread] invalid BAM binary header (this is not a BAM file). File ./tophat010paired/accepted_hits.sam.sorted doesn't appear to be a valid BAM file, trying SAM... [19:24:38] Loading reference annotation and sequence. [19:25:40] Inspecting maps and determining fragment length distributions.

Error: this SAM file doesn't appear to be correctly sorted! current hit is at Contig10010|nucleolin-:26, last one was at Contig1000|---NA---:198 Cufflinks requires that if your file has SQ records in the SAM header that they appear in the same order as the chromosomes names in the alignments. If there are no SQ records in the header, or if the header is missing, the alignments must be sorted lexicographically by chromsome name and by position.

I've prviouisly converted the tophat output into a .sam before sorting:

samtools view -h -o acceptedhits.sam acceptedhits.bam

sort -k 3,3 -k 4,4n acceptedhits.sam > acceptedhits.sam.sorted

This feeds into cufflinks alright, but stops as above when shuttled into cuffdiff. If anyone could offer me a suggestion, I'd thoroughly appreciate it!!

cufflinks transcription gene bowtie tophat

4 answers

You should sort your bam file (accepted_hits.bam) using samtools. Use

samtools sort accepted_hits.bam  accepted_hits_sorted

This will give you accepted_hits_sorted.bam file in your directory and Cufflinks do accept bam file, so there will be no need of converting it into sam.

Also if you have used TopHat, then your file is already sorted. So it is ready to use for Cufflinks.

EDIT

If A.bam is the problem file, then [?]samtools view -H A.bam > header.sam samtools reheader header.sam A.bam > B.bam[?]

Source

Reheading didn't work, but I've altered hits.cpp and will get our dude to make install in the morning. Thanks for your help!

cufflinks -p 20 -o 36mg rehead.bam [20:23:19] Inspecting reads and determining fragment length distribution.

Processed 0 loci. [*******] 100% Map Properties: Total Map Mass: 0.00 Fragment Length Distribution: Truncated Gaussian (default) Default Mean: 200 Default Std Dev: 80 [20:23:19] Assembling transcripts and estimating abundances. Processed 0 loci. [*******] 100%

Did you solve the problem after you altered hits.cpp file?I meet the same error thanks

Hi, I am getting the same error. What should I alter in hits.cpp file?

It doesn't think you have a .bam file. That's a bigger problem than the lack of sorting.

Your problem seems to be in the creation of BAM from SAM file. The best way to convert a SAM to BAM file is to use picard tools SamFormatConverter as:

java -jar SamFormatConverter.jar I=input.sam O=output.bam

If you want to sort a SAM file by coordinate and convert it to bam all at the same time, you could use MergeSamFiles with just 1 input as:

java -jar MergeSamFiles.jar I=input.sam O=output.bam SO=coordinate AS=false USE_THREADING=true TMP_DIR=<Path_to_TEMP_dir>

I also met the problem but I have solved it .Maybe you can delete the information about 'Contig1000|---NA---' and it will work well.

Log in to answer this question.