Hi Rebecca,

samtools sort does not sort the sequence dictionary in the header, it sorts
only the reads (by read name with the -n flag that you're using). Look into
PicardTools ReorderSam (
https://broadinstitute.github.io/picard/command-line-overview.html#ReorderSam)
to reorder your sequence dictionaries to the same order so your BAMs can be
merged.


Andrew

On Mon, Oct 10, 2016 at 4:50 PM Rebecca Harris <rebz...@gmail.com> wrote:

> Hi,
>
> I have a couple of genomes, aligned to the same reference, that I am
> trying to merge using the command:
>
> java -jar picard.jar MergeSamFiles MERGE_SEQUENCE_DICTIONARIES=true
> I=NA18867.bam I=Denisovan.bam O=out.bam
>
> Upon merging, I get an error that my BAM files are in different orders -
> in particular 2 and 19. So, I attempted to use samtools sort -n to sort all
> my BAM files. However, this is not working as expected. After sorting, I
> used samtools view -H to look at the header of my sorted BAM files (results
> shown below) and find that these genomes continue to be in different orders.
>
> I am using samtools version 1.2 and the following command for sorting:
> samtools sort -n -T human -o humans/NA18867.sorted.bam -O bam -@ 12
> humans/NA18867.bam
>
> Any help would be greatly appreciated. Thanks!
> Rebecca
>
>
> For one genome I get:
>
> @HD VN:1.0 SO:queryname
>
> @SQ SN:1 LN:249250621
>
> @SQ SN:10 LN:135534747
>
> @SQ SN:11 LN:135006516
>
> @SQ SN:12 LN:133851895
>
> @SQ SN:13 LN:115169878
>
> @SQ SN:14 LN:107349540
>
> @SQ SN:15 LN:102531392
>
> @SQ SN:16 LN:90354753
>
> @SQ SN:17 LN:81195210
>
> @SQ SN:18 LN:78077248
>
> @SQ SN:19 LN:59128983
> @SQ SN:2 LN:243199373
>
> and for the other genome I get:
>
> @HD VN:1.0 GO:none SO:queryname
>
> @SQ SN:1 LN:249250621 AS:NCBI37 UR:
> ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/technical/reference/human_g1k_v37.fasta.gz
> M5:1b22b98cdeb4a9304cb5d48026a85128 SP:Human
>
> @SQ SN:2 LN:243199373 AS:NCBI37 UR:
> ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/technical/reference/human_g1k_v37.fasta.gz
> M5:a0d9851da00400dec1098a9255ac712e SP:Human
>
> @SQ SN:3 LN:198022430 AS:NCBI37 UR:
> ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/technical/reference/human_g1k_v37.fasta.gz
> M5:fdfd811849cc2fadebc929bb925902e5 SP:Human
>
> @SQ SN:4 LN:191154276 AS:NCBI37 UR:
> ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/technical/reference/human_g1k_v37.fasta.gz
> M5:23dccd106897542ad87d2765d28a19a1 SP:Human
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Samtools-help mailing list
> Samtools-help@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/samtools-help
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Samtools-help mailing list
Samtools-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/samtools-help

Reply via email to