Skip to content

Commit

Permalink
Merge branch 'cell_label_add' of https://github.com/angelolab/ark-ana…
Browse files Browse the repository at this point in the history
…lysis into cell_label_add
  • Loading branch information
alex-l-kong committed May 27, 2022
2 parents f07eaa2 + 1839807 commit ef7a83b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions ark/phenotyping/som_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,12 @@ def train_pixel_som(fovs, channels, base_dir,
if output:
print(output.strip())

if process.returncode != 0:
raise MemoryError(
"Process terminated: you likely have a memory-related error. Try increasing "
"your Docker memory limit."
)


def cluster_pixels(fovs, channels, base_dir, pre_dir='pixel_mat_preprocessed',
norm_vals_name='norm_vals.feather', weights_name='pixel_weights.feather',
Expand Down Expand Up @@ -875,6 +881,12 @@ def cluster_pixels(fovs, channels, base_dir, pre_dir='pixel_mat_preprocessed',
if output:
print(output.strip())

if process.returncode != 0:
raise MemoryError(
"Process terminated: you likely have a memory-related error. Try increasing "
"your Docker memory limit."
)

# compute average channel expression for each pixel SOM cluster
# and the number of pixels per SOM cluster
print("Computing average channel expression across pixel SOM clusters")
Expand Down Expand Up @@ -974,6 +986,12 @@ def pixel_consensus_cluster(fovs, channels, base_dir, max_k=20, cap=3,
if output:
print(output.strip())

if process.returncode != 0:
raise MemoryError(
"Process terminated: you likely have a memory-related error. Try increasing "
"your Docker memory limit."
)

# compute average channel expression for each pixel meta cluster
# and the number of pixels per meta cluster
print("Computing average channel expression across pixel meta clusters")
Expand Down Expand Up @@ -1272,6 +1290,12 @@ def train_cell_som(fovs, channels, base_dir, pixel_consensus_dir, cell_table_nam
if output:
print(output.strip())

if process.returncode != 0:
raise MemoryError(
"Process terminated: you likely have a memory-related error. Try increasing "
"your Docker memory limit."
)

# read in the pixel channel averages table
print("Computing the weighted channel expression per cell")
pixel_cluster_channel_avg = pd.read_csv(os.path.join(base_dir, pc_chan_avg_name))
Expand Down Expand Up @@ -1370,6 +1394,12 @@ def cluster_cells(base_dir, cluster_counts_norm_name='cluster_counts_norm.feathe
if output:
print(output.strip())

if process.returncode != 0:
raise MemoryError(
"Process terminated: you likely have a memory-related error. Try increasing "
"your Docker memory limit."
)

# compute the average pixel SOM/meta counts per cell SOM cluster
print("Computing the average number of pixel SOM/meta cluster counts per cell SOM cluster")
cell_som_cluster_avgs_and_counts = compute_cell_cluster_count_avg(
Expand Down Expand Up @@ -1492,6 +1522,12 @@ def cell_consensus_cluster(fovs, channels, base_dir, pixel_cluster_col, max_k=20
if output:
print(output.strip())

if process.returncode != 0:
raise MemoryError(
"Process terminated: you likely have a memory-related error. Try increasing "
"your Docker memory limit."
)

# compute the average pixel SOM/meta counts per cell meta cluster
print("Compute the average number of pixel SOM/meta cluster counts per cell meta cluster")
cell_meta_cluster_avgs_and_counts = compute_cell_cluster_count_avg(
Expand Down

0 comments on commit ef7a83b

Please sign in to comment.