Skip to content
Open
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
12 changes: 11 additions & 1 deletion src/segger/data/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,20 @@ def assign_transcripts_to_cells(
logger.debug(f"Processing feature {i+1}/{n_groups} (feature {feature[0]} | transcripts {group.shape[0]/1e3:.1f}K)...")

# sample if too many
arr = group["segger_similarity"]
arr = group["segger_similarity"].drop_nulls()
if arr.shape[0] > n:
arr = arr.sample(n=n, seed=0)
arr = arr.to_numpy()
arr = arr[np.isfinite(arr)]

# Degenerate inputs crash threshold_yen / threshold_li: no finite
# values, or a single constant value (nothing to threshold).
if arr.size == 0:
failed_to_converge.append(feature[0])
continue
if arr.size == 1 or np.allclose(arr, arr[0]):
thresholds.append({tx_fields.feature: feature[0], "similarity_threshold": float(arr[0]), "converged": True})
continue

# threshold
try:
Expand Down