<p><code>bcftools</code> has the <code>view</code> command which can do this. Create a text file (<code>samples</code>) which has the names of the samples you want, one per line, and then:</p>

<pre><code>bcftools view -S samples merged.vcf.gz &gt; new.vcf
</code></pre>

<p>Or, if you're running a shell that supports it, you can use input redirection for a single sample name:</p>

<pre><code>bcftools view -S &lt;(echo "sample name") merged.vcf.gz &gt; new.vcf
</code></pre>

CC BY-SA 4.0
2019-11-29T12:37:15.610Z
2019-11-29T12:37:15.610Z
terdon
<p>How can one do the reverse of bcftools merge?
To get one sample back out of the merged one.
Without holding reference sites.</p>

<bcftools>
How to do the reverse of bcf merge?
# How to do the reverse of bcf merge?

(Asked by: username_0 on 2019-11-29)

How can one do the reverse of bcftools merge?
To get one sample back out of the merged one.
Without holding reference sites.

**Tags:** bcftools

---

## 1 answers

### Answer by username_1 on 2019-11-29. Score: 1 | Accepted answer

bcftools has the view command which can do this. Create a text file (samples) which has the names of the samples you want, one per line, and then:
bcftools view -S samples merged.vcf.gz > new.vcf

Or, if you're running a shell that supports it, you can use input redirection for a single sample name:
bcftools view -S <(echo "sample name") merged.vcf.gz > new.vcf


---

