Notebook source
Rendered from notebooks/getting_started/5_Exploring_the_CnvTranslator.ipynb.
5. Exploring the CnvTranslator
The vrs-python model supports two classes of copy number variation: * CopyNumberChange - an assessment of loss or gain relative to a location within a system, where loss or gain is represented by the following EMBL-EBI Experimental Factor Ontology (EFO) codes: * EFO:0030064 - regional base ploidy * EFO:0030067 - loss * EFO:0030068 - low-level loss * EFO:0030069 - complete genomic loss * EFO:0030070 - gain * EFO:0030071 - low level gain * EFO:0030072 - high-level gain * EFO:0020073 - high-level loss * CopyNumberCount - an absolute count of discrete copies of a location within a gene or system For the CnvTranslator, only HGVS nomenclature is used to describe the variation.
Step 1 - Setup Data Proxy Access
The DataProxy provides access to sequence references.
from ga4gh.vrs.dataproxy import create_dataproxy
seqrepo_rest_service_url = "seqrepo+https://services.genomicmedlab.org/seqrepo"
seqrepo_dataproxy = create_dataproxy(uri=seqrepo_rest_service_url)
Import the CnvTranslator class.
The UTA server is required in the environment since we are translating from/to HGVS.
import os
os.environ["UTA_DB_URL"] = "postgresql://anonymous:anonymous@uta.biocommons.org:5432/uta/uta_20241220"
Step 2 - CopyNumberChange examples
This example depicts a CopyNumberChange representing a deletion, or copy number loss. The Experimental Factor Ontology code specifying the type of copy number change is passed as a keyword argument "copy_change" to to_vrs. This variant can be viewed in ClinVar.
cnv_translator = CnvTranslator(data_proxy=seqrepo_dataproxy)
cnc = cnv_translator.to_vrs("NC_000014.9:g.45002867_45015056del", "hgvs", copy_change="loss")
cnc.model_dump(exclude_none=True)
Output:
{'id': 'ga4gh:CX.SlJJkuXM8b0b63ADyDMxV-MpLBi7BhfI',
'type': 'CopyNumberChange',
'digest': 'SlJJkuXM8b0b63ADyDMxV-MpLBi7BhfI',
'location': {'id': 'ga4gh:SL.GSJAEJXFDz7Nq6VlJj5NTEku48MmteUU',
'type': 'SequenceLocation',
'digest': 'GSJAEJXFDz7Nq6VlJj5NTEku48MmteUU',
'sequenceReference': {'type': 'SequenceReference',
'refgetAccession': 'SQ.eK4D2MosgK_ivBkgi6FVPg5UXs1bYESm'},
'start': 45002866,
'end': 45015056},
'copyChange': 'loss'}
This example depicts a CopyNumberChange* representing a duplication, or copy number gain. This variant can be viewed in ClinVar.
cnx = cnv_translator.to_vrs("NC_000009.12:g.75502958_76045032dup", "hgvs", copy_change="gain")
cnx.model_dump(exclude_none=True)
Output:
{'id': 'ga4gh:CX.jPS3b_jC01NchtIA13jc6bSGgxE0UTkt',
'type': 'CopyNumberChange',
'digest': 'jPS3b_jC01NchtIA13jc6bSGgxE0UTkt',
'location': {'id': 'ga4gh:SL.tydo6UFL8Y60L5Me3k8AJfljURO9vYn9',
'type': 'SequenceLocation',
'digest': 'tydo6UFL8Y60L5Me3k8AJfljURO9vYn9',
'sequenceReference': {'type': 'SequenceReference',
'refgetAccession': 'SQ.KEO-4XBcm1cxeo_DIQ8_ofqGUkp4iZhI'},
'start': 75502957,
'end': 76045032},
'copyChange': 'gain'}
Step 3 - CopyNumberCount examples
This example depicts a CopyNumberCount with a copy number gain. With copy number count variation, the "copies" keyword argument is passed to to_vrs with the appropriate "EFO" ontology code. This variant can be viewed in ClinVar.
cnc = cnv_translator.to_vrs("NC_000004.12:g.85624_57073230dup", "hgvs", copies="3")
cnc.model_dump(exclude_none=True)
Output:
{'id': 'ga4gh:CN.O_QHImmfErh9jDFkJaypPPvUmnj7EM70',
'type': 'CopyNumberCount',
'digest': 'O_QHImmfErh9jDFkJaypPPvUmnj7EM70',
'location': {'id': 'ga4gh:SL.hBVWalem_rNclxjmUuT9CHbEGCdlqW9L',
'type': 'SequenceLocation',
'digest': 'hBVWalem_rNclxjmUuT9CHbEGCdlqW9L',
'sequenceReference': {'type': 'SequenceReference',
'refgetAccession': 'SQ.HxuclGHh0XCDuF8x6yQrpHUBL7ZntAHc'},
'start': 85623,
'end': 57073230},
'copies': 3}
This example depicts a CopyNumberCount with a copy number loss. This variant can be viewed in ClinVar.
cnc = cnv_translator.to_vrs("NC_000021.9:g.46111353_46119948del", "hgvs", copies="1")
cnc.model_dump(exclude_none=True)
Output:
{'id': 'ga4gh:CN.WDzlT9oUq4IcQrVRWGH0dZnARnFBotCS',
'type': 'CopyNumberCount',
'digest': 'WDzlT9oUq4IcQrVRWGH0dZnARnFBotCS',
'location': {'id': 'ga4gh:SL.H1Zh5xdBqamBjwVE9orWdY_uBkpEMH1V',
'type': 'SequenceLocation',
'digest': 'H1Zh5xdBqamBjwVE9orWdY_uBkpEMH1V',
'sequenceReference': {'type': 'SequenceReference',
'refgetAccession': 'SQ.5ZUqxCmDDgN4xTRbaSjN8LwgZironmB8'},
'start': 46111352,
'end': 46119948},
'copies': 1}