You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Mantis is super useful in order to evaluate the quality of the clustering reuslts, but requires a specific formatting
Describe the solution you'd like
Add the option to automatically create the required structure at the end of the pixel and cell clustering notebooks. Here's a quick function I wrote. This can get cleaned up, tested, etc
def create_mantis_project(mantis_project_path, img_data_path, mask_output_dir, mask_suffix, mapping_path,
seg_dir, img_sub_folder='normalized'):
if not os.path.exists(mantis_project_path):
os.makedirs(mantis_project_path)
# create key from cluster number to cluster name
map_df = pd.read_csv(mapping_path)
map_df = map_df.loc[:, ['metacluster', 'mc_name']]
# remove duplicates from df
map_df = map_df.drop_duplicates()
map_df = map_df.sort_values(by=['metacluster'])
# rename for mantis names
map_df = map_df.rename({'metacluster': 'region_id', 'mn_name': 'region_name'}, axis=1)
# get names of fovs with masks
mask_names = io_utils.list_files(mask_output_dir, mask_suffix)
fov_names = io_utils.extract_delimited_names(mask_names, delimiter=mask_suffix)
# create a folder with image data, pixel masks, and segmentation mask
for idx, val in enumerate(fov_names):
# set up paths
img_source_dir = os.path.join(img_data_path, val, img_sub_folder)
output_dir = os.path.join(mantis_project_path, val)
# copy image data if not already copied in from previous round of clustering
if not os.path.exists(output_dir):
os.makedirs(output_dir)
# copy all channels into new folder
chans = io_utils.list_files(img_source_dir, '.tiff')
for chan in chans:
shutil.copy(os.path.join(img_source_dir, chan), os.path.join(output_dir, chan))
# copy mask into new folder
mask_name = mask_names[idx]
shutil.copy(os.path.join(mask_output_dir, mask_name), os.path.join(output_dir, 'population{}.tiff'.format(mask_suffix)))
# copy segmentations into directory
seg_name = val + '_feature_0.tif'
shutil.copy(os.path.join(seg_dir, seg_name), os.path.join(output_dir, 'cell_segmentation.tiff'))
# copy mapping into directory
map_df.to_csv(os.path.join(output_dir, 'population{}.csv'.format(mask_suffix)), index=False)
Here's what it looks like when run from the cell clustering nb
Is your feature request related to a problem? Please describe.
Mantis is super useful in order to evaluate the quality of the clustering reuslts, but requires a specific formatting
Describe the solution you'd like
Add the option to automatically create the required structure at the end of the pixel and cell clustering notebooks. Here's a quick function I wrote. This can get cleaned up, tested, etc
Here's what it looks like when run from the cell clustering nb
The text was updated successfully, but these errors were encountered: