Chromosome Display
The function that displays a chromosome is a method named display_chromosome,
defined in the PeakViewerApp class.
The method is called whenver the user clicks the left or right button next to the chromosome name or edits the chromosome name.
To break the code into manageable pieces there are two "helper methods":
_make_patchesbuilds a list of rectangles for the "ribbon" display_make_gridbuilds the column of blocks, interleaving graphical representations of the SNPs with a text view of the dataframe
display_chromosome
Update the chromosome display. Called whenever the chromosome ID changes. Shows a set of rectangular patches where the color is based on the region identified by the HMM. Below that is a grid with one row for each block of SNPs identifed by the peak finder. Draw a vertical line at the crossover location (if there is one).
Source code in src/xo/gui.py
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 | |
_make_patches
Create a horizontal bar as a collection of rectangular patches, with one patch for each row in the data frame. The rows have the starting coordinates lengths, and HMM states of chromosome regions, used to define the width and color of a patch. Add black dots to indicate the locations of blocks.
Source code in src/xo/gui.py
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | |
_make_grid
Make a Column object that has a collection of figures, one for each block in a chromosome (saved in an instance var). The figures are saved in a grid. Below each figure is a text widget containing the data frame with the filtered SNPs in the block, i.e. the grid for a chromosome with N blocks as 2*N rows. The frames are initially hidden. The rows that have figures also have a toggle button; clicking this button will show or hide the frame.
Source code in src/xo/gui.py
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 | |