Workflow Classes
Use these classes when you want step-wise control, intermediate state, or save/load support.
scTenifoldNet
scTenifoldNet(
x_data: ExpressionData,
y_data: ExpressionData,
x_label: str,
y_label: str,
qc_kws: Optional[Kwargs] = None,
nc_kws: Optional[Kwargs] = None,
td_kws: Optional[Kwargs] = None,
ma_kws: Optional[Kwargs] = None,
dr_kws: Optional[Kwargs] = None,
)
Bases: scBase
Two-sample scTenifoldNet workflow.
Pipeline order: qc → nc (PC network construction) → td
(tensor decomposition) → ma (manifold alignment) → dr
(differential regulation). Each step persists its output on the
instance so it can be inspected, saved, or rerun individually via
:meth:run_step. :meth:build runs the full pipeline and returns
the differential regulation table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_data
|
ExpressionData
|
Genes-by-cells expression DataFrames (or AnnData-like objects;
converted via :func: |
required |
y_data
|
ExpressionData
|
Genes-by-cells expression DataFrames (or AnnData-like objects;
converted via :func: |
required |
x_label
|
str
|
Short labels used as keys in |
required |
y_label
|
str
|
Short labels used as keys in |
required |
qc_kws
|
Optional[Kwargs]
|
Overrides for :func: |
None
|
nc_kws
|
Optional[Kwargs]
|
Overrides for :func: |
None
|
td_kws
|
Optional[Kwargs]
|
Overrides for :func: |
None
|
ma_kws
|
Optional[Kwargs]
|
Overrides for :func: |
None
|
dr_kws
|
Optional[Kwargs]
|
Overrides for :func: |
None
|
See class docstring for parameter descriptions.
Source code in scTenifold/core/_base.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
get_empty_config
classmethod
get_empty_config() -> Dict[str, object]
Return a blank scTenifoldNet config dict populated with step defaults.
Source code in scTenifold/core/_base.py
312 313 314 315 316 317 318 319 | |
load_config
classmethod
load_config(config: Dict[str, object]) -> scTenifoldNet
Build a scTenifoldNet from a config dict, reading data from disk.
x_data_path and y_data_path may be either a 10x folder
(loaded via :func:read_folder) or a CSV/TSV file.
Source code in scTenifold/core/_base.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
save
save(
file_dir: Union[str, Path],
comps: Union[str, List[str]] = "all",
verbose: bool = True,
**kwargs: object,
) -> None
Save state plus x_label/y_label so :meth:load can rebuild.
Source code in scTenifold/core/_base.py
340 341 342 343 344 345 346 347 348 | |
run_step
run_step(
step_name: Literal["qc", "nc", "td", "ma", "dr"],
**kwargs: object,
) -> None
Run a single step of the scTenifoldNet pipeline.
Steps must be invoked in order — each depends on the state produced by the previous one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step_name
|
Literal['qc', 'nc', 'td', 'ma', 'dr']
|
Which step to run. One of:
|
required |
**kwargs
|
object
|
One-shot overrides for the step. When non-empty these
replace the dict stored on the instance ( |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in scTenifold/core/_base.py
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 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 | |
build
build() -> pd.DataFrame
Run the whole pipeline of scTenifoldNet
Returns:
| Name | Type | Description |
|---|---|---|
d_regulation_df |
DataFrame
|
Differential regulation result dataframe |
Source code in scTenifold/core/_base.py
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | |
scTenifoldKnk
scTenifoldKnk(
data: ExpressionData,
strict_lambda: float = 0,
ko_method: KOMethod = "default",
ko_genes: Optional[Union[str, Iterable[str]]] = None,
qc_kws: Optional[Kwargs] = None,
nc_kws: Optional[Kwargs] = None,
td_kws: Optional[Kwargs] = None,
ma_kws: Optional[Kwargs] = None,
dr_kws: Optional[Kwargs] = None,
ko_kws: Optional[Kwargs] = None,
)
Bases: scBase
Single-sample scTenifoldKnk virtual-knockout workflow.
Pipeline order: qc → nc → td → ko → ma → dr.
A wild-type PC network is built from data; the ko step
produces a perturbed tensor and the remaining steps compare WT vs.
KO. Run end-to-end with :meth:build, or step-wise with
:meth:run_step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ExpressionData
|
Genes-by-cells expression matrix ( |
required |
strict_lambda
|
float
|
Pruning strength forwarded to :func: |
0
|
ko_method
|
KOMethod
|
How the KO tensor is generated:
|
'default'
|
ko_genes
|
Optional[Union[str, Iterable[str]]]
|
Gene name or iterable of names to knock out. |
None
|
qc_kws
|
Optional[Kwargs]
|
Overrides for :func: |
None
|
nc_kws
|
Optional[Kwargs]
|
Overrides for :func: |
None
|
td_kws
|
Optional[Kwargs]
|
Overrides for :func: |
None
|
ma_kws
|
Optional[Kwargs]
|
Overrides for :func: |
None
|
dr_kws
|
Optional[Kwargs]
|
Overrides for :func: |
None
|
ko_kws
|
Optional[Kwargs]
|
Extra kwargs forwarded to the KO step (e.g. |
None
|
See class docstring for parameter descriptions.
Source code in scTenifold/core/_base.py
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | |
get_empty_config
classmethod
get_empty_config() -> Dict[str, object]
Return a blank scTenifoldKnk config dict populated with step defaults.
Source code in scTenifold/core/_base.py
503 504 505 506 507 508 509 510 | |
load_config
classmethod
load_config(config: Dict[str, object]) -> scTenifoldKnk
Build a scTenifoldKnk from a config dict, reading data from disk.
Source code in scTenifold/core/_base.py
512 513 514 515 516 517 518 519 520 | |
save
save(
file_dir: Union[str, Path],
comps: Union[str, List[str]] = "all",
verbose: bool = True,
**kwargs: object,
) -> None
Save state plus KO-specific fields so :meth:load can rebuild.
Source code in scTenifold/core/_base.py
522 523 524 525 526 527 528 529 530 531 | |
run_step
run_step(
step_name: Literal["qc", "nc", "td", "ko", "ma", "dr"],
**kwargs: object,
) -> None
Run a single step of the scTenifoldKnk pipeline.
Steps must be invoked in order — each depends on the state produced by the previous one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step_name
|
Literal['qc', 'nc', 'td', 'ko', 'ma', 'dr']
|
Which step to run. One of:
|
required |
**kwargs
|
object
|
One-shot overrides for the step. When non-empty these
replace the corresponding |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in scTenifold/core/_base.py
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 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 | |
build
build() -> pd.DataFrame
Run the whole pipeline of scTenifoldKnk
Returns:
| Name | Type | Description |
|---|---|---|
d_regulation_df |
DataFrame
|
Differential regulation result dataframe |
Source code in scTenifold/core/_base.py
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 | |