process_mutation
genie.process_mutation
¶
Process mutation files TODO deprecate this module and spread functions around
Attributes¶
logger = logging.getLogger(__name__)
module-attribute
¶
MAF_COL_MAPPING = {'HUGO_SYMBOL': 'Hugo_Symbol', 'ENTREZ_GENE_ID': 'Entrez_Gene_Id', 'CENTER': 'Center', 'NCBI_BUILD': 'NCBI_Build', 'CHROMOSOME': 'Chromosome', 'START_POSITION': 'Start_Position', 'END_POSITION': 'End_Position', 'STRAND': 'Strand', 'VARIANT_CLASSIFICATION': 'Variant_Classification', 'VARIANT_TYPE': 'Variant_Type', 'REFERENCE_ALLELE': 'Reference_Allele', 'TUMOR_SEQ_ALLELE1': 'Tumor_Seq_Allele1', 'TUMOR_SEQ_ALLELE2': 'Tumor_Seq_Allele2', 'DBSNP_RS': 'dbSNP_RS', 'DBSNP_VAL_STATUS': 'dbSNP_Val_Status', 'TUMOR_SAMPLE_BARCODE': 'Tumor_Sample_Barcode', 'MATCHED_NORM_SAMPLE_BARCODE': 'Matched_Norm_Sample_Barcode', 'MATCH_NORM_SEQ_ALLELE1': 'Match_Norm_Seq_Allele1', 'MATCH_NORM_SEQ_ALLELE2': 'Match_Norm_Seq_Allele2', 'TUMOR_VALIDATION_ALLELE1': 'Tumor_Validation_Allele1', 'TUMOR_VALIDATION_ALLELE2': 'Tumor_Validation_Allele2', 'MATCH_NORM_VALIDATION_ALLELE1': 'Match_Norm_Validation_Allele1', 'MATCH_NORM_VALIDATION_ALLELE2': 'Match_Norm_Validation_Allele2', 'VERIFICATION_STATUS': 'Verification_Status', 'VALIDATION_STATUS': 'Validation_Status', 'MUTATION_STATUS': 'Mutation_Status', 'SEQUENCING_PHASE': 'Sequencing_Phase', 'SEQUENCE_SOURCE': 'Sequence_Source', 'VALIDATION_METHOD': 'Validation_Method', 'SCORE': 'Score', 'BAM_FILE': 'BAM_File', 'SEQUENCER': 'Sequencer', 'T_REF_COUNT': 't_ref_count', 'T_ALT_COUNT': 't_alt_count', 'N_REF_COUNT': 'n_ref_count', 'N_ALT_COUNT': 'n_alt_count', 'ALLELE': 'Allele', 'AMINO_ACID_CHANGE': 'amino_acid_change', 'AMINO_ACIDS': 'Amino_acids', 'CDS_POSITION': 'CDS_position', 'CODONS': 'Codons', 'CONSEQUENCE': 'Consequence', 'EXISTING_VARIATION': 'Existing_variation', 'EXON_NUMBER': 'Exon_Number', 'FEATURE': 'Feature', 'FEATURE_TYPE': 'Feature_type', 'GENE': 'Gene', 'HGVSC': 'HGVSc', 'HGVSP': 'HGVSp', 'HGVSP_SHORT': 'HGVSp_Short', 'HOTSPOT': 'Hotspot', 'MA:FIMPACT': 'MA:FImpact', 'MA:LINK.MSA': 'MA:link.MSA', 'MA:LINK.PDB': 'MA:link.PDB', 'MA:LINK.VAR': 'MA:link.var', 'MA:PROTEIN.CHANGE': 'MA:protein.change', 'POLYPHEN': 'PolyPhen', 'PROTEIN_POSITION': 'Protein_position', 'REFSEQ': 'RefSeq', 'TRANSCRIPT': 'transcript', 'TRANSCRIPT_ID': 'Transcript_ID', 'ALL_EFFECTS': 'all_effects', 'CDNA_CHANGE': 'cdna_change', 'CDNA_POSITION': 'cDNA_position', 'N_DEPTH': 'n_depth', 'T_DEPTH': 't_depth'}
module-attribute
¶
KNOWN_STRING_COLS = ['IS_NEW', 'ALLELE_NUM', 'Chromosome', 'CLIN_SIG', 'MOTIF_NAME', 'HIGH_INF_POS', 'MINIMISED', 'CHROMOSOME', 'VERIFICATION_STATUS', 'VALIDATION_STATUS', 'MUTATION_STATUS', 'SEQUENCE_SOURCE', 'SEQUENCER', 'REPORT_AF', 'CDNA_CHANGE', 'AMINO_ACID_CHANGE', 'TRANSCRIPT', 'transcript', 'STRAND_VEP', 'HGNC_ID', 'PUBMED', 'PICK', 'Exon_Number', 'genomic_location_explanation', 'Annotation_Status', 'Variant_Classification']
module-attribute
¶
Functions¶
_convert_to_str_dtype(column_types, known_string_cols)
¶
Sometimes the deteremined dtype is incorrect based off the first 100 rows, update the incorrect dtypes.
Source code in genie/process_mutation.py
123 124 125 126 127 128 129 130 |
|
determine_dtype(path)
¶
Reads in a dataframe partially and determines the dtype of columns
Source code in genie/process_mutation.py
134 135 136 137 138 139 |
|
move_and_configure_maf(mutation_path, input_files_dir)
¶
Moves maf files into processing directory. Maf file's column headers are renamed if necessary and .0 are stripped.
PARAMETER | DESCRIPTION |
---|---|
mutation_path
|
Mutation file path
TYPE:
|
input_files_dir
|
Input file directory
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
Filepath to moved and configured maf
TYPE:
|
Source code in genie/process_mutation.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
move_mutation(mutation_path, input_files_dir)
¶
Move mutation file into processing directory
Source code in genie/process_mutation.py
169 170 171 172 173 174 175 |
|
process_mutation_workflow(syn, center, validfiles, genie_config, workdir)
¶
Process vcf/maf workflow
PARAMETER | DESCRIPTION |
---|---|
syn
|
Synapse connection
TYPE:
|
center
|
Center name
TYPE:
|
validfiles
|
Center validated files
TYPE:
|
genie_config
|
GENIE configuration.
TYPE:
|
workdir
|
Working directory
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Optional[str]
|
Annotated Maf Path. None if there are no valid mutation files. |
Source code in genie/process_mutation.py
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 |
|
create_annotation_paths(center, workdir)
¶
Creates the filepaths required in the annotation process
PARAMETER | DESCRIPTION |
---|---|
center
|
name of the center
TYPE:
|
workdir
|
work directory to create paths in
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
namedtuple
|
tuple with all the paths
TYPE:
|
Source code in genie/process_mutation.py
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 |
|
concat_annotation_error_reports(center, input_dir)
¶
Concatenates the annotation error reports
PARAMETER | DESCRIPTION |
---|---|
center
|
name of center associated with error report
TYPE:
|
input_dir
|
directory where error reports are
TYPE:
|
Returns: pd.DataFrame: full annotation error report
Source code in genie/process_mutation.py
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 |
|
check_annotation_error_reports(syn, maf_table_synid, full_error_report, center)
¶
A simple QC check to make sure our genome nexus error report failed annotations matches our final processed maf table's failed annotations
PARAMETER | DESCRIPTION |
---|---|
syn
|
synapse client
TYPE:
|
maf_table_synid
|
synapse_id of the narrow maf table
TYPE:
|
full_error_report
|
the failed annotations error report
TYPE:
|
center
|
the center this is for
TYPE:
|
Source code in genie/process_mutation.py
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 |
|
store_annotation_error_reports(full_error_report, full_error_report_path, syn, errors_folder_synid)
¶
Stores the annotation error reports to synapse
PARAMETER | DESCRIPTION |
---|---|
full_error_report
|
full error report to store
TYPE:
|
syn
|
synapse client object
TYPE:
|
errors_folder_synid
|
synapse id of error report folder to store reports in
TYPE:
|
Source code in genie/process_mutation.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
|
annotate_mutation(annotation_paths, mutation_files, genie_annotation_pkg, center)
¶
Process vcf/maf files
PARAMETER | DESCRIPTION |
---|---|
center
|
Center name
TYPE:
|
mutation_files
|
list of mutation files
TYPE:
|
genie_annotation_pkg
|
Path to GENIE annotation package
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
Path to final maf |
Source code in genie/process_mutation.py
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 |
|
append_or_createdf(dataframe, filepath)
¶
Creates a file with the dataframe or appends to a existing file.
PARAMETER | DESCRIPTION |
---|---|
df
|
pandas.dataframe to write out
|
filepath
|
Filepath to append or create
TYPE:
|
Source code in genie/process_mutation.py
426 427 428 429 430 431 432 433 434 435 436 437 |
|
format_maf(mafdf, center)
¶
Format maf file, shortens the maf file length
PARAMETER | DESCRIPTION |
---|---|
mafdf
|
mutation dataframe
TYPE:
|
center
|
Center name
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
Formatted mutation dataframe |
Source code in genie/process_mutation.py
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
|
split_and_store_maf(syn, center, maf_tableid, annotation_paths, flatfiles_synid)
¶
Separates annotated maf file into narrow and full maf and stores them
PARAMETER | DESCRIPTION |
---|---|
syn
|
Synapse connection
TYPE:
|
center
|
Center
TYPE:
|
maf_tableid
|
Mutation table synapse id
TYPE:
|
annotation_paths
|
filepaths in the annotation process
TYPE:
|
flatfiles_synid
|
GENIE flat files folder
TYPE:
|
Source code in genie/process_mutation.py
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 |
|