scsplice.io¶
Input / output functions for STARsolo output. Three readers, one consistent API shape:
| Function | STARsolo source | Output |
|---|---|---|
read_starsolo |
Solo.out/SJ/ |
Splicing AnnData (layers["M1"], layers["M2"]) |
read_starsolo_gene |
Solo.out/Gene/ |
Gene-expression AnnData (X = raw counts) |
read_starsolo_velocyto |
Solo.out/Velocyto/ |
Velocity AnnData (layers["spliced/unspliced/ambiguous"]) |
All three accept tissue_positions= for Visium / spatial samples and populate squidpy-compatible obsm["spatial"] and uns["spatial"].
See STARsolo readers and AnnData data layouts for design rationale and the full AnnData schema.
io
¶
scsplice.io — readers for STARsolo / 10x output.
read_starsolo
¶
read_starsolo(sj_dirs: str | Path | Sequence[str | Path], sample_ids: str | Sequence[str], *, barcode_whitelists: Sequence[str | Path | Sequence[str] | None] | None = None, use_internal_whitelist: bool = True, keep_multi_mapped: bool = False, min_counts: int = 1, ljv_kind: Literal['start_end', 'start', 'end'] = 'start_end', tissue_positions: Sequence[str | Path | None] | None = None, spatial_library_ids: Sequence[str | None] | None = None, verbose: bool = False) -> AnnData
Read STARsolo splice-junction output and assemble a splicing AnnData.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sj_dirs
|
str | Path | Sequence[str | Path]
|
One or more |
required |
sample_ids
|
str | Sequence[str]
|
Per-directory unique sample identifier; appears in
|
required |
barcode_whitelists
|
Sequence[str | Path | Sequence[str] | None] | None
|
Optional per-sample whitelist of raw 16-mer barcodes. Each entry
may be a path to a one-barcode-per-line file, a sequence of
barcodes, or |
None
|
use_internal_whitelist
|
bool
|
When no explicit whitelist is supplied for a sample, fall back to
STARsolo's per-sample whitelist at |
True
|
keep_multi_mapped
|
bool
|
Default |
False
|
min_counts
|
int
|
Minimum row-sum (across all cells of all samples) required for an
event row to survive in the final AnnData. Applied after LJV
grouping. Default |
1
|
ljv_kind
|
Literal['start_end', 'start', 'end']
|
Which LJV-grouped event rows to emit: |
'start_end'
|
tissue_positions
|
Sequence[str | Path | None] | None
|
Per-sample optional path to a Space Ranger
|
None
|
spatial_library_ids
|
Sequence[str | None] | None
|
Per-sample squidpy library_id key for |
None
|
verbose
|
bool
|
Print per-sample progress to stdout. |
False
|
Notes
Whitelist precedence per sample:
tissue_positions[i](when given)barcode_whitelists[i](when given)use_internal_whitelist=TrueandGene/filtered/barcodes.tsvexists- otherwise no whitelist (use all raw barcodes)
The SJ feature has only raw/ available (no per-feature filtered
dir), so the "read raw and intersect" step is the only mode regardless
of which precedence rule fires; the rule still affects WHICH barcodes
are kept.
Returns:
| Type | Description |
|---|---|
AnnData
|
Cells × events. |
Source code in src/scsplice/io/_starsolo.py
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 | |
read_starsolo_gene
¶
read_starsolo_gene(sample_dirs: str | Path | Sequence[str | Path], sample_ids: str | Sequence[str], *, barcode_whitelists: Sequence[str | Path | Sequence[str] | None] | None = None, use_internal_whitelist: bool = True, var_names: Literal['gene_ids', 'gene_symbols'] = 'gene_ids', tissue_positions: Sequence[str | Path | None] | None = None, spatial_library_ids: Sequence[str | None] | None = None, verbose: bool = False) -> AnnData
Read STARsolo Gene-feature output and assemble a cell × gene AnnData.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_dirs
|
str | Path | Sequence[str | Path]
|
One or more sample directories. Each may be the sample root (parent
of |
required |
sample_ids
|
str | Sequence[str]
|
Per-sample unique identifier; appears in |
required |
barcode_whitelists
|
Sequence[str | Path | Sequence[str] | None] | None
|
Per-sample whitelist of barcodes. |
None
|
use_internal_whitelist
|
bool
|
When neither an external whitelist nor |
True
|
var_names
|
Literal['gene_ids', 'gene_symbols']
|
|
'gene_ids'
|
tissue_positions
|
Sequence[str | Path | None] | None
|
Per-sample optional path to a Space Ranger
|
None
|
spatial_library_ids
|
Sequence[str | None] | None
|
Per-sample squidpy library_id used as the key in
|
None
|
verbose
|
bool
|
Print per-sample diagnostics to stdout. |
False
|
Returns:
| Type | Description |
|---|---|
AnnData
|
Cells × genes. |
Notes
Whitelist precedence per sample:
tissue_positions[i](read raw/, intersect)barcode_whitelists[i](read raw/, intersect)use_internal_whitelist=Trueand filtered/ exists (read filtered/)- otherwise raw/ unfiltered
The reader does not run min_counts filtering — gene expression
workflows have their own QC (e.g. scanpy.pp.calculate_qc_metrics).
Validated against STARsolo 2.7.10+ and Cell Ranger 6/7/8 features.tsv
(3-col); 2-col v2 features.tsv is supported via the column-count
dispatch in _read_features.
Source code in src/scsplice/io/_starsolo_gene.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 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 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 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 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 | |
read_starsolo_velocyto
¶
read_starsolo_velocyto(sample_dirs: str | Path | Sequence[str | Path], sample_ids: str | Sequence[str], *, barcode_whitelists: Sequence[str | Path | Sequence[str] | None] | None = None, use_internal_whitelist: bool = True, var_names: Literal['gene_ids', 'gene_symbols'] = 'gene_ids', tissue_positions: Sequence[str | Path | None] | None = None, spatial_library_ids: Sequence[str | None] | None = None, verbose: bool = False) -> AnnData
Read STARsolo Velocyto output and assemble a cell × gene AnnData with three layers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_dirs
|
str | Path | Sequence[str | Path]
|
|
required |
sample_ids
|
str | Path | Sequence[str | Path]
|
|
required |
barcode_whitelists
|
str | Path | Sequence[str | Path]
|
|
required |
use_internal_whitelist
|
str | Path | Sequence[str | Path]
|
|
required |
var_names
|
Literal['gene_ids', 'gene_symbols']
|
Same shape as :func: |
'gene_ids'
|
tissue_positions
|
Literal['gene_ids', 'gene_symbols']
|
Same shape as :func: |
'gene_ids'
|
spatial_library_ids
|
Literal['gene_ids', 'gene_symbols']
|
Same shape as :func: |
'gene_ids'
|
verbose
|
Literal['gene_ids', 'gene_symbols']
|
Same shape as :func: |
'gene_ids'
|
Returns:
| Type | Description |
|---|---|
AnnData
|
|
Notes
Both wire formats are auto-detected:
- Modern: three separate
spliced.mtx/unspliced.mtx/ambiguous.mtxfiles. - Legacy: a stacked
matrix.mtxwith rows[0..n_genes)spliced,[n_genes..2*n_genes)unspliced,[2*n_genes..3*n_genes)ambiguous.
The Velocyto feature has only a raw/ directory in stock STARsolo
output, so the filtered/ fallback is not applicable here. Internal
whitelist (when enabled) reads from
Solo.out/Gene/filtered/barcodes.tsv next door.
The reader does not run velocity smoothing or moments — that's
scvelo.pp.filter_and_normalize / scvelo.tl.velocity.
Source code in src/scsplice/io/_starsolo_velocyto.py
378 379 380 381 382 383 384 385 386 387 388 389 390 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 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 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 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 | |