Documentation for lanctools Python API
Classes
LancData
lanctools.core.LancData
The genotype and local ancestry data for a single chromosome/dataset.
Attributes:
pgen (PgenReader): A pgenlib PgenReader object.
pvar: A pgenlib PVarReader object.
lanc: A FlatLanc object with local ancestry data.
ancestries: An ordered list of ancestry names. The integer codes in
the .lanc file and self.lanc correspond to indices in this list (e.g.
0 -> ancestries[0]).
plink_prefix: The prefix for the corresponding plink2 fileset.
Source code in src/lanctools/core.py
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 | |
__init__(plink_prefix, lanc_file, ancestries=None)
Constructs a LancData from plink2 files.
Args: plink_prefix: A string with the prefix for a plink2 fileset. lanc_file: A string with the path to a .lanc file. ancestries: An optional list of ordered ancestry names corresponding to the .lanc file.
Source code in src/lanctools/core.py
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 | |
get_geno(indices)
Query phased genotypes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
NDArray[uint32]
|
Array of variant indices in pvar order (0-based), shape |
required |
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
Phased genotypes, shape |
Source code in src/lanctools/core.py
368 369 370 371 372 373 374 375 376 377 378 | |
get_info(indices)
Query info for a set of variants.
Args:
indices: Array of variant indices in pvar order (0-based), shape
(V,), dtype int32.
Returns:
A pandas DataFrame with one row per variant and the following columns:
- chrom (str): Chromosome name
- pos (uint32): 1-based genomic position
- ref (str): Reference allele
- alt (str): Alternate allele
- rsid (str): Variant identifier
Source code in src/lanctools/core.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
get_lanc(indices)
Query phased local ancestry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
NDArray[unsignedinteger]
|
Array of variant indices in pvar order (0-based), shape |
required |
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
Local ancestries, shape |
Source code in src/lanctools/core.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
get_lanc_dosage(indices)
Query local ancestry dosage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
NDArray[uint32]
|
Array of variant indices in pvar order (0-based), shape |
required |
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
Local ancestry dosages, shape |
Source code in src/lanctools/core.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
get_lanc_geno(indices)
Query genotypes deconvoluted/masked by ancestry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
NDArray[unsignedinteger]
|
Array of variant indices in pvar order (0-based), shape |
required |
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
Genotypes masked by ancestry, shape |
Source code in src/lanctools/core.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |