Answers.Body: <p>It sounds like you want <code>samtools faidx foo.fa</code> followed by <code>samtools faidx foo.fa chr1 &gt; your_subset_file.fa</code> (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., <code>chr1:100-1000</code>, though note that the sequence name in the resulting fasta output will be <code>chr1:100-1000</code>, which may break some downstream tools).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-03T00:16:11.497Z
Answers.Text: '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.
Answers.UserDisplayName: Marjan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-03T08:39:46.193Z
Answers.Text: Then that's likely a bug in ipdSummary.
Answers.UserDisplayName: Devon Ryan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-25T15:24:06.563Z
Answers.LastActivityDate: 2018-01-25T15:49:52.400Z
Answers.LastEditDate: 2018-01-25T15:49:52.400Z
Answers.UserDisplayName: Devon Ryan
Body: <p>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. </p>
  
  <p>That's awful. </p>
  
  <p>Picard tools has an <a href="https://software.broadinstitute.org/gatk/documentation/tooldocs/3.8-0/org_broadinstitute_gatk_tools_walkers_fasta_FastaReferenceMaker.php" rel="nofollow noreferrer">option</a>. But this doesn't appear to subset only by chromosome. How could this be done efficiently? </p>
  
Tags: <fasta><reference-genome><picard>
Title: How can I subset a reference based on only the first chromosome?
ThreadText: # How can I subset a reference based on only the first chromosome?
  
  (Asked by: username_0 on 2018-01-25)
  
  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](https://software.broadinstitute.org/gatk/documentation/tooldocs/3.8-0/org_broadinstitute_gatk_tools_walkers_fasta_FastaReferenceMaker.php). But this doesn't appear to subset only by chromosome. How could this be done efficiently?
  
  **Tags:** fasta, reference-genome, picard
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-01-25. Score: 3 | Accepted answer
  
  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).
  
  > **Comments:**
  > **username_2**: '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.  
  > **username_1**: Then that's likely a bug in ipdSummary.  
  
  ---
  
  