Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Variable Names #81

Merged
merged 18 commits into from
Oct 28, 2024
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
2 changes: 1 addition & 1 deletion docs/source/notebooks/paste_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@
"start = time.time()\n",
"\n",
"center_slice, pis = center_align(\n",
" initial_slice, slices, lmbda, random_seed=5, pis_init=b\n",
" initial_slice, slices, lmbda, random_seed=5, pi_inits=b\n",
")\n",
"\n",
"print(\"Runtime: \" + str(time.time() - start))"
Expand Down
4 changes: 2 additions & 2 deletions scripts/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def find_pis(self, overlap_fraction: float, max_iters: int = 1000):
pairwise_align(
self.slices[i].adata,
self.slices[i + 1].adata,
s=overlap_fraction,
overlap_fraction=overlap_fraction,
numItermax=max_iters,
maxIter=max_iters,
)
Expand All @@ -109,7 +109,7 @@ def find_center_slice(
if reference_slice is None:
reference_slice = self.slices[0]
center_slice, pis = center_align(
reference_slice.adata, self.slices_adata, pis_init=pis
reference_slice.adata, self.slices_adata, pi_inits=pis
)
return Slice(adata=center_slice), pis

Expand Down
32 changes: 16 additions & 16 deletions src/paste3/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ def align(
cost_matrix = np.genfromtxt(cost_matrix, delimiter=",", dtype="float64")

if start is None:
pis_init = [None] * (n_slices - 1) if mode == "pairwise" else None
pi_inits = [None] * (n_slices - 1) if mode == "pairwise" else None
elif mode == "pairwise" and not (len(start) == n_slices - 1):
raise ValueError(
f"Number of slices {n_slices} is not equal to number of start pi files {len(start)}"
)
else:
pis_init = [np.genfromtxt(pi, delimiter=",") for pi in start]
pi_inits = [np.genfromtxt(pi, delimiter=",") for pi in start]

# make output directory if it doesn't exist
output_directory = Path(output_directory)
Expand All @@ -87,15 +87,15 @@ def align(
pis = []
for i in range(n_slices - 1):
pi = pairwise_align(
sliceA=slices[i],
sliceB=slices[i + 1],
s=overlap_fraction,
M=cost_matrix,
a_slice=slices[i],
b_slice=slices[i + 1],
overlap_fraction=overlap_fraction,
exp_dissim_matrix=cost_matrix,
alpha=alpha,
dissimilarity=cost,
G_init=pis_init[i],
a_distribution=slices[i].obsm["weights"],
b_distribution=slices[i + 1].obsm["weights"],
exp_dissim_metric=cost,
pi_init=pi_inits[i],
a_spots_weight=slices[i].obsm["weights"],
b_spots_weight=slices[i + 1].obsm["weights"],
norm=norm,
numItermax=numItermax,
backend=ot.backend.TorchBackend(),
Expand All @@ -104,7 +104,7 @@ def align(
maxIter=max_iter,
optimizeTheta=optimizeTheta,
eps=eps,
is_histology=is_histology,
do_histology=is_histology,
armijo=armijo,
)
pis.append(pi)
Expand All @@ -124,18 +124,18 @@ def align(
initial_slice = slices[initial_slice - 1].copy()

center_slice, pis = center_align(
A=initial_slice,
initial_slice=initial_slice,
slices=slices,
lmbda=lmbda,
slice_weights=lmbda,
alpha=alpha,
n_components=n_components,
threshold=threshold,
max_iter=max_iter,
dissimilarity=cost,
exp_dissim_metric=cost,
norm=norm,
random_seed=seed,
pis_init=pis_init,
distributions=[slice.obsm["weights"] for slice in slices],
pi_inits=pi_inits,
spots_weights=[slice.obsm["weights"] for slice in slices],
backend=ot.backend.TorchBackend(),
use_gpu=use_gpu,
)
Expand Down
Loading
Loading