Question: IGV ignoring indexed and sorted .bai file and trying to create a .fai file to view an alignment
0
gravatar for cbm46672
4 months ago by
cbm466720
cbm466720 wrote:

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!

bam fai igv alignment bai • 283 views
ADD COMMENTlink modified 4 months ago • written 4 months ago by cbm466720

fasta file must be indexd with samtools faidx ref.fa

ADD REPLYlink written 4 months ago by Pierre Lindenbaum118k

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 written 4 months ago by cbm466720

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

ADD REPLYlink written 4 months ago by michael.ante3.2k

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 written 4 months ago by cbm466720

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 written 4 months ago by WouterDeCoster38k

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

ADD REPLYlink modified 4 months ago • written 4 months ago by cmdcolin1.2k
1

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

ADD REPLYlink written 4 months ago by WouterDeCoster38k

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

ADD REPLYlink written 4 months ago by cbm466720

How exactly are you trying to load your bam?

ADD REPLYlink written 4 months ago by swbarnes25.2k

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 written 4 months ago by cbm466720
0
gravatar for cbm46672
4 months ago by
cbm466720
cbm466720 wrote:

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 written 4 months ago by cbm466720
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: 2024 users visited in the last hour