If you are a Python user, you may want to checkout the pyvcf
submodule from the fuc
package I wrote:
>>> from fuc import pyvcf
>>> data = {
... 'CHROM': ['chr1', 'chr1', 'chr1', 'chr1'],
... 'POS': [100, 101, 102, 103],
... 'ID': ['.', '.', '.', '.'],
... 'REF': ['G', 'T', 'T', 'T'],
... 'ALT': ['A', 'C', 'A', 'C'],
... 'QUAL': ['.', '.', '.', '.'],
... 'FILTER': ['.', '.', '.', '.'],
... 'INFO': ['.', '.', '.', '.'],
... 'FORMAT': ['GT', 'GT', 'GT', 'GT'],
... 'Affected1': ['0/0', '0/0', '1/1', '0/1'],
... 'Affected2': ['0/1', '0/0', '0/1', '0/0'],
... 'Affected3': ['0/0', '0/0', '1/1', '0/0'],
... 'Affected4': ['0/0', '0/0', '0/1', '0/1'],
... 'Unaffected1': ['0/0', '0/0', '0/0', '0/0'],
... 'Unaffected2': ['0/1', '0/1', '0/0', '0/0'],
... }
>>> vf = pyvcf.VcfFrame.from_dict([], data)
>>> vf.df
CHROM POS ID REF ALT QUAL FILTER INFO FORMAT Affected1 Affected2 Affected3 Affected4 Unaffected1 Unaffected2
0 chr1 100 . G A . . . GT 0/0 0/1 0/0 0/0 0/0 0/1
1 chr1 101 . T C . . . GT 0/0 0/0 0/0 0/0 0/0 0/1
2 chr1 102 . T A . . . GT 1/1 0/1 1/1 0/1 0/0 0/0
3 chr1 103 . T C . . . GT 0/1 0/0 0/0 0/1 0/0 0/0
>>> affected_samples = ['Affected1', 'Affected2', 'Affected3', 'Affected4']
>>> filtered_vf = vf.filter_sampall(samples=affected_samples)
>>> filtered_vf.df
CHROM POS ID REF ALT QUAL FILTER INFO FORMAT Affected1 Affected2 Affected3 Affected4 Unaffected1 Unaffected2
0 chr1 102 . T A . . . GT 1/1 0/1 1/1 0/1 0/0 0/0