I have the GATK FASTA reference for hg19. I would like to subset this based on the first chromosome. Normally what I do is open the FASTA as a text file, and then delete all other chromosomes except chromosome 1.

That's awful.

Picard tools has an option. But this doesn't appear to subset only by chromosome. How could this be done efficiently?


1 Answer 1


It sounds like you want samtools faidx foo.fa followed by samtools faidx foo.fa chr1 > your_subset_file.fa (or whatever the first chromosome is). The output file is then a regular fasta file subset as you like. You can get any chromosome you want with that. In fact, you can also do regions (e.g., chr1:100-1000, though note that the sequence name in the resulting fasta output will be chr1:100-1000, which may break some downstream tools).

  • $\begingroup$ 'samtools faidx foo.fa chr1 > your_subset_file.fa' seems problematic for downstream analysis, specifically ipdSummary doesn't work with the resulted fasta file, and it seems the header is not saved correctly. $\endgroup$
    – Marjan
    Commented Dec 3, 2023 at 0:16
  • $\begingroup$ Then that's likely a bug in ipdSummary. $\endgroup$
    – Devon Ryan
    Commented Dec 3, 2023 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.