Biostar Beta. Not for public use.
IGV ignoring indexed and sorted .bai file and trying to create a .fai file to view an alignment
0
Entering edit mode
15 months ago
cbm46672 • 0

Hello all!

I am trying to resequence a wild peanut species genome and align it to cultivated peanut.

The steps I followed are thus:

  1. Generate a BWA index for the reference gnenome: "bwa index -a bwtsw tifrunnerA.fa
  2. Generate a fasta file index: samtools "faidx tifrunnerA.ga"
  3. Map the paired-end reads: "bwa mem tifrunnerA.fa correntinaR1.fq correntinaR2.fq > correntina_BWA.sam"
  4. Convert sam to bam: "samtools view -S -b correntina_BWA.sam > correntina_BWA.bam"
  5. Sort: "samtools sort correntina_BWA.bam -o corretnina_sorted.bam:
  6. Index: "samtools index correntina_sorted.bam"

The resulting correntina_sorted.bam file was 35,057,080 KB and the correntina_sorted.bam.bai file was 3,249 KB.

The issue is that when I try to load the .bam file into IGV to view the alignment, IGV ignores the .bai file in the same folder as the .bam file and tries to create a .fai file. Why is it trying to create a .fai file?? The IGV error reads: "Could not create index file: Z:\Chandler Levinson\2018 Experiments\Correntina sequence\correntina_sorted.bam.fai." I have not been able to find a thread that addresses this issue.

Thank you to anyone who tries to help me. I look forward to your response!

ADD COMMENTlink
0
Entering edit mode

fasta file must be indexd with samtools faidx ref.fa

ADD REPLYlink
0
Entering edit mode

Thanks for responding! I did that to prep the reference genome, but do I need to do that to index the bam alignment too instead of using "samtools index"?

ADD REPLYlink
0
Entering edit mode

Have you generated a custom genome with the reference file and its index?

ADD REPLYlink
0
Entering edit mode

Yes! The custom genome is is correntina_sorted.bam. The reference file is tifrunnerA.fa. When I indexed the reference I got a .fa.amb, .fa.ann, .fa.bwt, .fa.fai, .fa.pac, .fa.sa files.

ADD REPLYlink
0
Entering edit mode

You can combine steps 3,4 and 5 and avoid intermediate files using:

bwa mem tifrunnerA.fa correntinaR1.fq correntinaR2.fq | samtools sort -o corretnina_sorted.bam
ADD REPLYlink
0
Entering edit mode

TIL....I always thought you needed the sam-to-bam conversion samtools view -Sb, but this looks like it works

ADD REPLYlink
1
Entering edit mode

It does work since recent samtools versions, looking at the extension as specified by the -o parameter IIRC.

ADD REPLYlink
0
Entering edit mode

Thank you for this tip! I will do this next time! :)

ADD REPLYlink
0
Entering edit mode

How exactly are you trying to load your bam?

ADD REPLYlink
0
Entering edit mode

So in IGV I go to "Genomes" and then "Load genome from file..." Then I click on the .bam file. Even though there is a .bai file in the same folder, it tries to generate a .fai file, which has 0KB and does nothing.

ADD REPLYlink
0
Entering edit mode
15 months ago
cbm46672 • 0

Thanks everyone who responded. I figured out the answer, and I feel pretty foolish. I didn't know you added the alignment as a file on top of the reference genome. The way I was loading it was telling the system that it was a reference genome, not an alignment.

ADD COMMENTlink

Login before adding your answer.

Similar Posts
Loading Similar Posts
Powered by the version 2.1