VariantManager
This class is designed to extract Variant objects from a pandas DataFrame that represents the input data. It will work out of the box for dataframes created by the CaseTemplateEncoder, and can be adapted to work with other datasets. The assumption is that there is one column per allele. For autosomal dominant, there would thus be one column. For recessive, there would be two columns. We do not try to automatically map non-HGVS (i.e., chromosomal variants). Instead, we first map HGVS using VariantValidator, and then we return a Pandas DataFrame that shows the other variants. These can be use to create chromosomal deletions, duplications, and inversions. Finally, the class can be used to add variants to a list of Individual objects.
If the Excel template is used, this class will be called internally and users do not need to use the code. If the data is ingested manually, the class can be used as follows.
gnas_symbol = "GNAS"
gnas_id = "HGNC:4392"
gnas_MANE_transcript = "NM_000516.7"
vmanager = VariantManager(df=df,
individual_column_name="individual",
transcript=gnas_MANE_transcript,
gene_id=gnas_id,
gene_symbol=gnas_symbol,
allele_1_column_name="allele_1")
See also variant_manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
DataFrame representing the input data |
required |
individual_column_name
|
str
|
Name of the individual (patient) column |
required |
transcript
|
str
|
accession number and version of the transcript, e.g., "NM_000342.3" |
required |
allele_1_column_name
|
str
|
name of the column with alleles (#1) |
required |
allele_2_column_name
|
str
|
name of the column with alleles (#2), optional |
None
|
gene_symbol
|
str
|
Symbol of affected gene (only required if chromosomal variants need to be coded) |
required |
gene_id
|
str
|
HGNC identifier of affected gene (only required if chromosomal variants need to be coded) |
None
|
Source code in pyphetools/creation/variant_manager.py
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 |
|
add_variants_to_individuals(individual_list, hemizygous=False)
Add Variant objects to individuals. Here, we use the map self._individual_to_alleles_d that relates the individual IDs to the allele strings in the original data, together with the map self._var_d, which relates the allele strings to Variant objects. If anything is missing, then we raise an Exception. Note currently this method cannot be used for X-dominant MOI.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
individual_list
|
List[Individual]
|
list of Individuals to which we will add Variant objects |
required |
hemizygous
|
bool
|
If True, this is an X-chromosomal gene and we assume hemizygous |
False
|
Source code in pyphetools/creation/variant_manager.py
code_as_chromosomal_deletion(allele_set)
Code variants with the identifiers in "allele_set" as Structural variants (chromosomal deletion)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
allele_set
|
Set of alleles (strings) for coding as Structural variants (chromosomal deletion) |
required |
Source code in pyphetools/creation/variant_manager.py
code_as_chromosomal_duplication(allele_set)
Code variants with the identifiers in "allele_set" as Structural variants (chromosomal duplication)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
allele_set
|
Set of alleles (strings) for coding as Structural variants (chromosomal duplication) |
required |
Source code in pyphetools/creation/variant_manager.py
code_as_chromosomal_inversion(allele_set)
Code variants with the identifiers in "allele_set" as Structural variants (chromosomal inversion)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
allele_set
|
Set of alleles (strings) for coding as Structural variants (chromosomal inversion) |
required |
Source code in pyphetools/creation/variant_manager.py
code_as_chromosomal_translocation(allele_set)
Code variants with the identifiers in "allele_set" as Structural variants (chromosomal translocation)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
allele_set
|
Set of alleles (strings) for coding as Structural variants (chromosomal translocation) |
required |
Source code in pyphetools/creation/variant_manager.py
get_var(v)
Get a Variant object that corresponds to v.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v
|
str
|
an HGVS string or free-text representation of a chromosomal variant |
required |
Returns:
Type | Description |
---|---|
Variant
|
corresponding Variant |
Source code in pyphetools/creation/variant_manager.py
get_variant_d()
Returns:
Type | Description |
---|---|
Dict[str, Variant]
|
dictionary with key: original string for allele, value: Variant object |
to_summary()
Create and return a DataFrame with current status of mapping efforts. The resulting dataframe can be used to check mapping and to retrieve the allele strings that could not be mapped (and therefore probably need to be mapped with one of the chromosomal methods)