Skip to content

Commit cfb01bf

Browse files
authored
handle edge cases
1 parent 35b77ac commit cfb01bf

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

0.preprocess-sites/1.process-spots.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,17 +251,28 @@ def handle_excepthook(exc_type, exc_value, exc_traceback):
251251
right_on=id_cols + location_cols,
252252
how="inner",
253253
)
254-
255-
null_spot_df = complete_foci_df.loc[
256-
(complete_foci_df.loc[:, spot_parent_cols] == 0).squeeze(), :
257-
]
258-
cell_spot_df = complete_foci_df.loc[
259-
(complete_foci_df.loc[:, spot_parent_cols] != 0).squeeze(), :
260-
]
254+
255+
try:
256+
null_spot_df = complete_foci_df.loc[
257+
(complete_foci_df.loc[:, spot_parent_cols] == 0).squeeze(), :
258+
]
259+
num_unassigned_spots = null_spot_df.shape[0]
260+
except:
261+
num_unassigned_spots = 0
262+
263+
try:
264+
cell_spot_df = complete_foci_df.loc[
265+
(complete_foci_df.loc[:, spot_parent_cols] != 0).squeeze(), :
266+
]
267+
except:
268+
warnings.warn(f"{site} has no foci in cells. Skiping.")
269+
logging.warning(f"{site} has no foci in cells. Skipping.")
270+
continue
271+
261272
num_assigned_cells = len(
262273
cell_spot_df.loc[:, spot_parent_cols].squeeze().unique()
263274
)
264-
num_unassigned_spots = null_spot_df.shape[0]
275+
265276
num_assigned_spots = cell_spot_df.shape[0]
266277

267278
# Figure 1 - histogram of barcode counts per cell

0 commit comments

Comments
 (0)