-
Notifications
You must be signed in to change notification settings - Fork 0
/
vcf.py
808 lines (655 loc) · 27.5 KB
/
vcf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
import gzip
import os
from pathlib import Path, PurePath
import re
import subprocess
import sys
from typing import Union
import urllib.parse
import pandas as pd
from .columns import splitColumns
from .filters import filter
from .utils import buildHyperlink, is_numeric, determine_delimiter, \
parse_cvo, parse_metrics_output
class vcf():
"""
Functions to handle reading and manipulating vcf data
Attributes
----------
args : argparse.Namespace
arguments passed from command line
vcfs : list
list of dataframe(s) of vcf data read in and formatted
additional_files : dict
dict of dataframes from (optionaly) passed additional files of
tabulated data to write to additional sheets in workbook
refs : list
list of genome reference files used for given VCFs
filtered_rows : list
list of dataframes of rows filtered out from vcfs
urls : dict
mapping dictionary of column name to URLs, used for adding hyperlinks
to column values before writing to file
"""
def __init__(self, args) -> None:
self.args = args
self.vcfs = []
self.additional_files = {}
self.refs = []
self.filtered_vcfs = []
def process(self) -> None:
"""
Function to call all methods in vcf() for processing given VCFs and
formatting ready to write to output file
Calls methods in following order:
- self.filter() (optional with --filter)
- self.read()
- splitColumns.split()
- self.merge()
- self.drop_columns()
- self.reorder()
- self.format_strings()
- self.add_hyperlinks()
- self.rename_columns()
"""
filters = filter(self.args)
if self.args.additional_files:
# additional non VCF files given, try read these in to dataframe(s)
self.read_additional_files()
# read in the each vcf, optionally filter, and then apply formatting
for vcf in self.args.vcfs:
# names for intermediary vcfs
split_vcf = f"{Path(vcf).stem}.split.vcf"
split_vcf_gz = f"{Path(vcf).stem}.split.vcf.gz"
filter_vcf = f"{Path(vcf).stem}.filter.vcf"
filter_vcf_gz = f"{Path(vcf).stem}.filter.vcf.gz"
# first split multiple transcript annotation to separate VCF
# records, and separate CSQ fields to separate INFO fields
self.bcftools_pre_process(vcf, split_vcf)
self.bgzip(split_vcf)
if self.args.filter:
# filter vcf against specified filters using bcftools
_, columns = self.parse_header(vcf)
filters.filter(split_vcf, filter_vcf, columns)
self.bgzip(filter_vcf)
# filters.filter() writes temp vcf with modified FILTER column
variant_df = self.read(filter_vcf, Path(vcf).stem)
# get filtered rows and read back to new dfs
keep_df, filtered_df = filters.split_include_exclude(variant_df)
# check we haven't dropped any variants
filters.verify_total_variants(split_vcf_gz, keep_df, filtered_df)
# split out INFO and FORMAT column values to individual
# columns in dataframe, need to handle cases where one or both
# may be empty to not raise errors downstream
if not keep_df.empty and not filtered_df.empty:
# both have variants
keep_df = splitColumns().split(keep_df)
filtered_df = splitColumns().split(filtered_df)
elif keep_df.empty and not filtered_df.empty:
# everything excluded, make empty keep df with same columns
# as those in excluded/filtered df
filtered_df = splitColumns().split(filtered_df)
keep_df = filtered_df.copy().drop(filtered_df.index)
elif not keep_df.empty and filtered_df.empty:
# nothing filtered out, make empty filtered df with same
# columns as included variants
keep_df = splitColumns().split(keep_df)
filtered_df = keep_df.copy().drop(keep_df.index)
else:
# both empty, we can't magic up columns names so just
# continue and workbook will have standard VCF columns
pass
self.vcfs.append(keep_df)
self.filtered_vcfs.append(filtered_df)
if not self.args.keep_tmp:
os.remove(filter_vcf_gz)
# clean up some memory since big dataframes can use a lot
del keep_df, filtered_df
else:
# not filtering vcf, read in full vcf and split out INFO and
# FORMAT/SAMPLE column values to individual columns in df
vcf_df = self.read(split_vcf, Path(vcf).stem)
if not vcf_df.empty:
vcf_df = splitColumns().split(vcf_df)
self.vcfs.append(vcf_df)
del vcf_df
# delete tmp vcf from splitting CSQ str in bcftools_pre_process()
os.remove(split_vcf)
if self.args.filter:
os.remove(filter_vcf)
if not self.args.keep_tmp:
os.remove(split_vcf_gz)
if self.args.merge:
self.vcfs = self.merge(self.vcfs)
if self.args.filter and self.args.keep:
# merge all filtered dataframes to one and add to list of vcfs for
# doing column operations and writing to Excel file
if not all(x.empty for x in self.filtered_vcfs):
self.filtered_vcfs = self.merge(self.filtered_vcfs)
self.vcfs.append(self.filtered_vcfs[0])
self.args.sheets.append('excluded')
if self.args.summary == 'dias':
# if it is dias pipeline, add the empty col
# named Interpreted in the first variant sheet
self.vcfs[0]['Interpreted']=''
if self.args.split_hgvs:
self.split_hgvs()
if self.args.add_raw_change:
self.add_raw_change()
if self.args.print_columns:
self.print_columns()
if self.args.exclude or self.args.include:
self.drop_columns()
if self.args.additional_columns:
self.add_additional_columns()
if self.args.reorder:
self.order_columns()
self.format_strings()
self.add_hyperlinks()
self.rename_columns()
print("\nSUCCESS: Finished munging variants from vcf(s)\n")
def bcftools_pre_process(self, vcf, output_vcf) -> None:
"""
Decompose multiple transcript annotation to individual records, and
split VEP CSQ string to individual INFO keys. Adds a 'CSQ_' prefix
to each field extracted from the CSQ string to stop potential conflicts
with existing INFO fields, which is then stripped before writing
to the Excel file
Parameters
------
vcf : str
path to vcf file to use
output_vcf : str
name for output vcf
Outputs
-------
{vcf}.split.vcf : file
vcf file output from bcftools
Raises
------
AssertionError
Raised when non-zero exit code returned by bcftools
"""
print(f"Splitting {vcf} with bcftools +split-vep")
# check total rows before splitting
pre_split_total = subprocess.run(
f"zgrep -v '^#' {vcf} | wc -l", shell=True,
capture_output=True
)
cmd = (
f"bcftools +split-vep --columns - -a CSQ -Ou -p 'CSQ_' -d {vcf} | "
f"bcftools annotate -x INFO/CSQ -o {output_vcf}"
)
output = subprocess.run(cmd, shell=True, capture_output=True)
assert output.returncode == 0, (
f"\n\tError in splitting VCF with bcftools +split-vep. VCF: {vcf}"
f"\n\tExitcode:{output.returncode}"
f"\n\t{output.stderr.decode()}"
)
# check total rows after splitting
post_split_total = subprocess.run(
f"zgrep -v '^#' {output_vcf} | wc -l", shell=True,
capture_output=True
)
print(
f"Total lines before splitting: {pre_split_total.stdout.decode()}"
f"Total lines after splitting: {post_split_total.stdout.decode()}"
)
def bgzip(self, file) -> None:
"""
Call bgzip on given file
Parameters
----------
file : file to compress
Outputs
-------
input file, but compressed
Raises
------
AssertionError
Raised when non-zero exit code returned by bgzip
"""
output = subprocess.run(
f"bgzip --force {file} -c > {file}.gz",
shell=True, capture_output=True
)
assert output.returncode == 0, (
f"\n\tError in compressing file with bgzip. File: {file}"
f"\n\tExitcode:{output.returncode}"
f"\n\t{output.stderr.decode()}"
)
def read(self, vcf, sample=None) -> pd.DataFrame:
"""
Reads given vcf into pd.DataFrame and parses header
Parameters
------
vcf : str
path to vcf file to use
sample : str
name of vcf, used for adding name to df if --add_name passed
Returns
-------
vcf_df : pandas.DataFrame
dataframe of all variants
"""
print(f"\n\nReading in vcf {vcf} for sample {sample}\n")
if sample:
sample = sample.replace('.vcf', '').replace('.gz', '')
if '_' in sample:
sample = sample.split('_')[0]
header, columns = self.parse_header(vcf)
self.parse_reference(header)
if self.args.print_header:
self.print_header(header)
# read vcf into pandas df
vcf_df = pd.read_csv(
vcf, sep='\t', comment='#', names=columns, compression='infer'
)
if self.args.add_name:
# add sample name from filename as 1st column
vcf_df.insert(loc=0, column='sampleName', value=sample)
if self.args.add_comment_column:
# add empty 'Comment' column to end of df
vcf_df['Comment'] = ''
if self.args.add_classification_column:
# add empty 'Classification' column to end of df
vcf_df['Classification'] = ''
return vcf_df
def read_additional_files(self):
"""
Attempt to read in additional tabulated files to dataframes for
writing as additional sheets to the output workbook
Updates self.additional_files dictionary with file_prefix : dataframe
"""
for idx, file in enumerate(self.args.additional_files):
# get prefix from filename for naming sheet if not specified
if self.args.additional_sheets:
prefix = self.args.additional_sheets[idx]
else:
prefix = PurePath(file).name.replace(
''.join(PurePath(file).suffixes), ''
)
# Excel has a limit of 31 characters for sheet name -> trim
if len(prefix) > 31:
prefix = prefix[:31]
print(
f"Prefix of additional file {file} is >31 character "
"limit for an Excel worksheet. Name will be trimmed to "
f"maximum length: {prefix}"
)
# read file contents in to list
if file.endswith('.gz'):
with gzip.open(file) as fh:
file_contents = [
x.decode() for x in fh.read().splitlines()
]
else:
with open(file) as fh:
file_contents = fh.read().splitlines()
# check what delimiter the data uses
# check end of file to avoid potential headers causing issues
delimiter = determine_delimiter(
'\n'.join(file_contents[-5:]), PurePath(file).suffixes
)
file_df = pd.DataFrame(
[line.split(delimiter) for line in file_contents]
)
if file.endswith('_CombinedVariantOutput.tsv'):
# file passed is a CombinedVariantOutput file from Illumina
# TSO500 app, just parse out TMB, MSI and Amplifications
print(
'CombinedVariantOutput file passed to --additional_files, '
'parsing out TMB, MSI and Amplifications'
)
file_df = parse_cvo(cvo_df=file_df)
if file.endswith('MetricsOutput.tsv'):
# file passed is run level MetricsOutput.tsv from Illumina
# TSO500 app, attempt to parse out just sample metrics to display
print(
'TSO500 MetricsOutput passed to --additional_files, '
'attempting to parse sample metrics from file'
)
file_df = parse_metrics_output(
metrics_df=file_df,
sample_vcf=Path(self.args.vcfs[0]).name
)
self.additional_files[prefix] = file_df
def parse_header(self, vcf) -> Union[list, list]:
"""
Read in header lines of given vcf to list, returning the list and the
vcf column names
Parameters
----------
vcf : str
vcf filename to read header from
Returns
-------
header : list
list of header lines read from vcf
columns : list
column names from vcf
Raises
------
AssertionError
Raised when header looks to be malformed and column names incorrect
"""
if vcf.endswith('.gz'):
fh = gzip.open(vcf)
else:
fh = open(vcf)
# read in header of vcf
header = []
for line in fh.readlines():
if vcf.endswith('.gz'):
line = line.decode()
if line.startswith('#'):
header.append(line.rstrip('\n'))
else:
break
fh.close
columns = [x.strip('#') for x in header[-1].split()]
columns[-1] = 'SAMPLE'
assert columns[0] == 'CHROM', (
"Parsed header appears to be malformed, column names parsed as: "
f"{columns}"
)
return header, columns
def parse_reference(self, header) -> None:
"""
Parse reference file used from VCF header
Parameters
----------
header : list
lines of vcf header
"""
ref=''
# first check if we can get reference build from VEP command string
vep = [x for x in header if x.startswith('##VEP')]
if vep:
assembly = re.search(r'assembly="[\w\d\.]+"', vep[0])
if assembly:
ref = assembly.group(0).replace('assembly=', '').strip('"\'')
if not ref:
ref = next(
iter([x for x in header if x.startswith('##reference')]), None
)
if ref:
if ref not in self.refs:
# add reference file if found and same not already in list
self.refs.append(Path(ref).name)
# check we don't have a mix of 37 and 38
assert not ('37' in str(self.refs) and '38' in str(self.refs)), (
'References from vcfs appear to be a mix of reference '
f'builds.\n References parsed: {self.refs}'
)
def add_hyperlinks(self) -> None:
"""
Format column value as an Excel hyperlink if URL for column specified
"""
# some URLs are build specific, infer which to use from build in header
build = None
reference = ''
if self.refs:
reference = self.refs[0].lower()
if '37' in reference or 'hg19' in reference:
build = 37
elif '38' in reference:
build = 38
for idx, vcf in enumerate(self.vcfs):
if vcf.empty:
# empty dataframe => nothing to add links to
continue
for column in vcf.columns:
self.vcfs[idx][column] = self.vcfs[idx].apply(
lambda x: buildHyperlink().build(
column=column,
value=x,
build=build
), axis=1
)
def format_strings(self) -> None:
"""
Fix formatting of string values with different encoding and nans
"""
for idx, vcf in enumerate(self.vcfs):
# pass through urllib unqoute and UTF-8 to fix any weird symbols
vcf = vcf.applymap(
lambda x: urllib.parse.unquote(x).encode('UTF-8').decode()
if type(x) == str else x
)
# remove any nans that are strings
vcf = vcf.applymap(
lambda x: x.replace('nan', '')
if x == 'nan' and type(x) == str else x
)
self.vcfs[idx] = vcf
def print_columns(self) -> None:
"""
Simple method to just print the columns from each vcf and exit.
Useful for identify what columns are present in INFO and CSQ fields
for using --include, --exclude and --reorder arguments
"""
for name, vcf in zip(self.args.vcfs, self.vcfs):
print(f"Columns for {Path(name).name}: ")
print(f"\n\t{list(vcf.columns)}\n\n")
sys.exit(0)
def print_header(self, header) -> None:
"""
Simple method to print vcf header(s) after splitting CSQ string with
bcftools to show all available fields and their types
Parameters
----------
header : list
vcf header as list read from file
"""
[print(x) for x in header]
sys.exit(0)
def drop_columns(self) -> None:
"""
If `--exclude` or `--include` passed, drop given columns
(or inverse of) from vcf data if they exist.
If `--include` passed will take the given list of columns and drop the
remaining columns not specified from all dataframes
If `--exclude` passed will take the given list of columns and drop
from all dataframes
Raises
------
AssertionError
Raised when columns specified with --include / --exclude are not
present in one or more of the dataframes
"""
for idx, vcf in enumerate(self.vcfs):
if self.args.include:
# include passed => select all columns not specified to drop
columns = self.args.include
to_drop = list(
set(vcf.columns.tolist()) - set(columns)
)
elif self.args.exclude:
columns = self.args.exclude
to_drop = self.args.exclude
else:
continue
# get any columns passed that aren't present in vcf
invalid = list(set(columns) - set(vcf.columns))
if invalid:
print(
f"WARNING: Columns passed with `--include / --exlcude not "
f"present in vcf ({invalid}), skipping these columns..."
)
if self.args.exclude:
# only need to remove in the case of excluding since
# include has already selected valid columns
for col in invalid:
to_drop.remove(col)
self.vcfs[idx].drop(to_drop, axis=1, inplace=True, errors='ignore')
def order_columns(self) -> None:
"""
Reorder columns by specified order from `--reorder` argument, any not
specified will retain original order after reorder columns
Raises
------
AssertionError
Raised when columns specified with --reorder are not
present in one or more of the dataframes
"""
for idx, vcf in enumerate(self.vcfs):
vcf_columns = list(vcf.columns)
# check columns given are present in vcf
invalid = list(
set(self.args.reorder) - set(vcf_columns) -
set(self.args.additional_columns)
)
if invalid:
print(
f"WARNING: columns passed to --reorder not present in vcf:"
f" {invalid}. Skipping these columns and continuing..."
)
for col in invalid:
self.args.reorder.remove(col)
[vcf_columns.remove(x) for x in self.args.reorder]
column_order = self.args.reorder + vcf_columns
self.vcfs[idx] = vcf[column_order]
def add_additional_columns(self) -> None:
"""
Append empty columns specified from --aditional_columns for adding
additional hyperlinks to external resources (e.g. decipher, oncoKB etc.)
"""
for column in self.args.additional_columns:
if column in ['decipher']:
# column is only for b38, check if vcf also is
if not self.refs:
print(
f'WARNING: {column} specified to --additional_columns '
'but no reference could be parsed from vcf header. '
f'Continuing without adding {column} column.'
)
continue
if 'hg19' in self.refs[0] or '37' in self.refs[0]:
print(
f'WARNING: {column} specified to `--additional_columns '
'but VCF appears to be for b37. Continuing without '
f'adding {column} column.'
)
continue
for idx, vcf in enumerate(self.vcfs):
vcf[column] = column
self.vcfs[idx] = vcf
def rename_columns(self) -> None:
"""
Rename columnns from key value pairs passed from --rename argument,
also remove underscores from all names for nicer reading
Raises
------
AssertionError
Raised when columns specified with --rename do not exist in more
or more of the vcfs columns
AssertionError
Raised when new column names specified are already present in the
vcf
"""
for idx, vcf in enumerate(self.vcfs):
if self.args.rename:
# check the given new name(s) not already a column name
assert all(
x not in vcf.columns for x in self.args.rename.values()
), (
f"Column(s) specified with --rename already present in "
f"one or more of the given vcfs. \n\ Column names: "
f"\n\n\t{vcf.columns}. \n\nNew column names passed to "
f"--rename: \n\n\t{list(self.args.rename.values())}"
)
# check specified columns are present in vcf, if not print
# warning, remove and continue
new_names_dict = self.args.rename.copy()
invalid = list(
set(new_names_dict.keys()) - set(vcf.columns.tolist())
)
if invalid:
print(
f"WARNING: columns passed to --rename not present in vcf:"
f" {invalid}. Skipping these columns and continuing..."
)
for key in invalid:
new_names_dict.pop(key)
self.vcfs[idx].rename(
columns=dict(new_names_dict.items()), inplace=True
)
# strip prefix from column name if present and not already a column
self.vcfs[idx].columns = self.strip_csq_prefix(self.vcfs[idx])
# remove underscores from all column names
self.vcfs[idx].columns = [
x.replace('_', ' ') for x in self.vcfs[idx].columns
]
def strip_csq_prefix(self, vcf) -> list:
"""
Strip CSQ prefix added by bcftools -split-vep from column names
Any conflicts in names with already present columns will retain prefix
Parameters
----------
vcf : pd.DataFrame
dataframe to modify column names of
Returns
-------
list
list of column names with CSQ_ prefixes removed
"""
return [
x.replace('CSQ_', '', 1) if (
x.startswith('CSQ_') and x.replace('CSQ_', '') not in vcf.columns
) else x for x in vcf.columns
]
def merge(self, vcfs) -> None:
"""
Merge all variants into one big dataframe, should be used with
--add_name argument if provenance of variants in merged dataframe
is important
"""
# don't attmept to merge empty vcfs as likely to have diff. columns
vcfs = [x for x in vcfs if not x.empty]
return [pd.concat(vcfs).reset_index(drop=True)]
def split_hgvs(self) -> pd.DataFrame:
"""
If --split_hgvs specified, attempt to split HGVSc and HGVSp columns
into 2 separate ones: c. change (DNA) and p. change (Protein).
"""
for idx, vcf in enumerate(self.vcfs):
# check required columns are in the dataframe
if not all(col in vcf.columns for col in ['CSQ_HGVSc', 'CSQ_HGVSp']):
print(
'WARNING: --split_hgvs specified but CSQ_HGVSc and/or '
'CSQHGVSp not present in VCF fields. Continuing without '
'splitting HGVS.'
)
continue
# ensure columns we're going to create don't already exist
if any(col in vcf.columns for col in ['DNA', 'Protein']):
print(
'WARNING: --split_hgvs specified but DNA and/or Protein '
'already exist in the vcf. Continuing without splitting HGVS.'
)
continue
vcf['DNA'] = vcf['CSQ_HGVSc'].str.split(':').str[1]
vcf['Protein'] = vcf['CSQ_HGVSp'].str.split(':').str[1]
self.vcfs[idx] = vcf
def add_raw_change(self) -> None:
"""
Adds a column named 'rawChange' of the 'raw' genomic change, formatted
as {CHROM}:g.{POS}{REF}>{ALT}. This is analogous to HGVSg output by
VEP, but will not include text such as INV and DEL.
"""
for idx, vcf in enumerate(self.vcfs):
if vcf.empty:
self.vcfs[idx]['rawChange'] = ''
continue
if not all(
col in vcf.columns for col in ['CHROM', 'POS', 'REF', 'ALT']
):
# one or more required columns missing => skip
print(
"WARNING: one or more required columns missing for "
"add_raw_change, continuing without adding"
)
continue
self.vcfs[idx]['rawChange'] = vcf.agg(
'{0[CHROM]}:g.{0[POS]}{0[REF]}>{0[ALT]}'.format, axis=1)