Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion RISE/factorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def pf2(
doEmbedding: bool = True,
tolerance=1e-6,
max_iter: int = 100,
normalize_slices: bool = False,
):
"""Perform PARAFAC2 tensor decomposition on single-cell RNA-seq data.

Expand Down Expand Up @@ -83,6 +84,9 @@ def pf2(
increase precision but may require more iterations.
max_iter : int, optional (default: 100)
Maximum number of iterations for the optimization algorithm.
normalize_slices : bool, optional (default: False)
If True, normalizes per-condition slices by their Frobenius norm during
factor updates to prevent conditions with large cell counts from dominating.

Returns
-------
Expand All @@ -100,7 +104,12 @@ def pf2(
if doEmbedding=True
"""
pf_out, _ = parafac2_nd(
X, rank=rank, random_state=random_state, tol=tolerance, n_iter_max=max_iter
X,
rank=rank,
random_state=random_state,
tol=tolerance,
n_iter_max=max_iter,
normalize_slices=normalize_slices,
)

X = store_pf2(X, pf_out)
Expand Down
9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ dependencies = [
"pandas>=3.0.0",
"pyarrow>=19.0",
"tensorly>=0.9.0",
"parafac2 @ git+https://github.com/meyer-lab/parafac2.git@v1.4.0",
"parafac2",
"anndata>=0.13",
"pacmap>=0.9",
"tqdm>=4.66.1",
"vcsc",
]

readme = "README.md"

[project.optional-dependencies]
gpu = [
"parafac2[gpu] @ git+https://github.com/meyer-lab/parafac2.git@v1.4.0",
"parafac2[gpu]",
]


Expand All @@ -39,6 +40,10 @@ build-backend = "uv_build"
module-name = ["RISE", "analysis"]
module-root = ""

[tool.uv.sources]
vcsc = { git = "https://github.com/meyer-lab/anndata-VCSC.git" }
parafac2 = { git = "https://github.com/meyer-lab/parafac2.git" }


[dependency-groups]
analysis = [
Expand Down
Loading
Loading