unravel.cluster_stats.org_data module#

Use cstats_org_data (cod) from UNRAVEL to aggregate and organize csv outputs from cstats_validation.

Prereqs:
  • cstats_validation (cstats_val) to generate the cluster validation

Inputs:
  • clusters/cluster_validation_results_`*` (glob pattern matching cstats_validation output dirs)

  • CSVs with validation metric data (e.g., cell_density_data.csv, label_density_data.csv, mean_in_cluster_data.csv, or mean_in_seg_in_cluster_data.csv from cstats_validation)

  • Optional: path/vstats to copy p val, info, and index files

Outputs:
  • target_dir/<cluster_validation_results_* >/sample??__<metric>_data__<cluster_validation_results_* >.csv

  • or, with –by_subregion: target_dir/<cluster_validation_results_* >/sample??__<metric>_by_subregion_data__<cluster_validation_results_* >.csv

Notes

  • If the cluster_validation_results_`*` directory name contains “_gt_” or “_lt_”, the script will attempt to replace it with “_v_” to match the vstats directory.

  • This is useful when non-directional maps were made as directional.

  • If the cluster_validation_results_`*` directory name contains “_LH” or “_RH”, the script will attempt to remove it to match the vstats directory.

Usage#

cstats_org_data -cvd ‘<asterisk>’ -me <metric> [-vd path/vstats_dir] [-td target_dir] [-pvt p_value_threshold.txt] [-d list of paths] [-p sample??] [-v]

unravel.cluster_stats.org_data.parse_args()[source]#
unravel.cluster_stats.org_data.resolve_cluster_correction_dir(validation_dir_name)[source]#
unravel.cluster_stats.org_data.find_matching_directory(base_path, long_name)[source]#
unravel.cluster_stats.org_data.cp(src, dest)[source]#

Copy a file from src path to a dest path, optionally printing the action.

Parameters:
  • src (-) – the source path

  • dest (-) – the destination path

unravel.cluster_stats.org_data.copy_stats_files(validation_dir, dest_path, vstats_path, p_val_txt)[source]#

Copy the cluster info, p value threshold, and rev_cluster_index files to the target directory.

Parameters:
  • validation_dir (-) – the path to the validation directory

  • dest_path (-) – the path to the new directory

  • vstats_path (-) – the path to the vstats directory

  • p_val_txt (-) – the name of the file with the corrected p value threshold

unravel.cluster_stats.org_data.organize_validation_data(sample_path, clusters_path, validation_dir_pattern, metric, target_dir, vstats_path, p_val_txt, by_subregion=False)[source]#

Copy the cluster validation, p value, cluster info, and rev_cluster_index files to the target directory.

Parameters:
  • sample_path (-) – the path to the sample directory

  • clusters_path (-) – the path to the clusters directory

  • validation_dir_pattern (-) – the pattern to match the validation directories

  • metric (-) – the type of metric data to aggregate (e.g., cell_density, label_density, mean_in_cluster, mean_in_seg_in_cluster)

  • target_dir (-) – the path to the target directory

  • vstats_path (-) – the path to the vstats directory

  • p_val_txt (-) – the name of the file with the corrected p value threshold

  • by_subregion (-) – whether to copy <metric>_by_subregion_data.csv instead of <metric>_data.csv

unravel.cluster_stats.org_data.main()[source]#