Skip to content

How to best call variants with ska lo? #93

Description

@rrwick

Hello, and thank you for developing SKA and the new ska lo subcommand!

I'm interested in using SKA to call variants against a reference using a single assembly. This is what I've done previously (in this preprint) using ska map:

ska build -o ska.skf -k 31 assembly.fasta
ska weed --filter no-ambig ska.skf
ska map reference.fasta ska.skf -f vcf | bcftools view -e'ALT="."' > variants.vcf

This works well for most SNPs but not for closely-spaced SNPs or indels. But then @johnlees let me know about ska lo, which sounds like it could solve these shortcomings! But I can't quite figure out how to get the VCF I need using ska lo. These commands almost work:

ska build -o ska.skf -k 31 assembly.fasta reference.fasta
ska lo ska.skf test -r reference.fasta

Except I have these two issues:

  1. The indels appear in a separate VCF file that don't have positions.
  2. ska lo only seems to allow a single sequence in the reference, so it errors out when reference.fasta contains multiple sequences (e.g. a chromomsome and plasmids).

Based on the documentation, the first issue seems to be an inherent limitation of ska lo, is that right?

For the second issue, the best solution I've found is to run ska lo separately on each reference sequence and then merge the results together. This is what I've come up with:

samtools faidx reference.fasta
ska build -o ska.skf -k 31 assembly.fasta reference.fasta

# Get reference seq names
seqs=($(grep ">" "$ref" | sed 's/>//; s/ .*//'))

# Run ska lo using each reference sequence
for seq in "${seqs[@]}"; do
    ska lo ska.skf "$seq" -r <(samtools faidx reference.fasta "$seq")
done

# Reheader and concatenate VCFs
vcf_files=()
for seq in "${seqs[@]}"; do
    bcftools reheader -f "${ref}.fai" "${seq}_snps.vcf" > "${seq}_snps_fixed.vcf"
    vcf_files+=("${seq}_snps_fixed.vcf")
done

# Merge all VCFs
bcftools concat -o variants.vcf "${vcf_files[@]}"

It's clunky, but it seems to work. Is there a better way?

Thanks!
Ryan

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions