spacr 0.3.65__py3-none-any.whl → 0.3.66__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
spacr/io.py CHANGED
@@ -2445,7 +2445,7 @@ def _read_and_merge_data_v1(locs, tables, verbose=False, nuclei_limit=False, pat
2445
2445
 
2446
2446
  return merged_df, obj_df_ls
2447
2447
 
2448
- def _read_and_merge_data(locs, tables, verbose=False, nuclei_limit=10, pathogen_limit=10):
2448
+ def _read_and_merge_data(locs, tables, verbose=False, nuclei_limit=10, pathogen_limit=10, change_plate=False):
2449
2449
  from .io import _read_db
2450
2450
  from .utils import _split_data
2451
2451
 
@@ -2453,8 +2453,10 @@ def _read_and_merge_data(locs, tables, verbose=False, nuclei_limit=10, pathogen_
2453
2453
  data_dict = {table: [] for table in tables}
2454
2454
 
2455
2455
  # Extract plate DataFrames
2456
- for loc in locs:
2456
+ for idx, loc in enumerate(locs):
2457
2457
  db_dfs = _read_db(loc, tables)
2458
+ if change_plate:
2459
+ db_dfs['plate'] = f'plate{idx}'
2458
2460
  for table, df in zip(tables, db_dfs):
2459
2461
  data_dict[table].append(df)
2460
2462
 
spacr/plot.py CHANGED
@@ -3737,7 +3737,7 @@ def graph_importance(settings):
3737
3737
  fig = spacr_graph.get_figure()
3738
3738
  plt.show()
3739
3739
 
3740
- def plot_proportion_stacked_bars(settings, df, group_column, bin_column, prc_column='prc', level='object'):
3740
+ def plot_proportion_stacked_bars(settings, df, group_column, bin_column, prc_column='prc', level='object', cmap='viridis'):
3741
3741
  """
3742
3742
  Generate a stacked bar plot for proportions and perform chi-squared and pairwise tests.
3743
3743
 
@@ -3784,7 +3784,7 @@ def plot_proportion_stacked_bars(settings, df, group_column, bin_column, prc_col
3784
3784
  std_proportions = well_proportions.groupby(group_column).std()
3785
3785
 
3786
3786
  ax = mean_proportions.plot(
3787
- kind='bar', stacked=True, yerr=std_proportions, capsize=5, colormap='viridis', figsize=(12, 8)
3787
+ kind='bar', stacked=True, yerr=std_proportions, capsize=5, colormap=cmap, figsize=(12, 8)
3788
3788
  )
3789
3789
  plt.title('Proportion of Volume Bins by Group (Mean ± SD across wells)')
3790
3790
  else:
@@ -3794,7 +3794,7 @@ def plot_proportion_stacked_bars(settings, df, group_column, bin_column, prc_col
3794
3794
  proportions = group_counts / group_totals
3795
3795
  proportion_df = proportions.unstack(fill_value=0)
3796
3796
 
3797
- ax = proportion_df.plot(kind='bar', stacked=True, colormap='viridis', figsize=(12, 8))
3797
+ ax = proportion_df.plot(kind='bar', stacked=True, colormap=cmap, figsize=(12, 8))
3798
3798
  plt.title('Proportion of Volume Bins by Group')
3799
3799
 
3800
3800
  plt.xlabel('Group')
spacr/settings.py CHANGED
@@ -1415,6 +1415,8 @@ def set_analyze_endodyogeny_defaults(settings):
1415
1415
  settings.setdefault('um_per_px',0.1)
1416
1416
  settings.setdefault('max_bins',None)
1417
1417
  settings.setdefault('save',False)
1418
+ settings.setdefault('change_plate',False)
1419
+ settings.setdefault('cmap','viridis')
1418
1420
  settings.setdefault('verbose',False)
1419
1421
  return settings
1420
1422
 
spacr/submodules.py CHANGED
@@ -952,13 +952,17 @@ def analyze_endodyogeny(settings):
952
952
  for s in settings['src']:
953
953
  loc = os.path.join(s, 'measurements/measurements.db')
954
954
  locs.append(loc)
955
+
956
+ if 'png_list' not in settings['tables']:
957
+ settings['tables'] = settings['tables'] + ['png_list']
955
958
 
956
959
  df, _ = _read_and_merge_data(
957
960
  locs,
958
961
  tables=settings['tables'],
959
962
  verbose=settings['verbose'],
960
963
  nuclei_limit=settings['nuclei_limit'],
961
- pathogen_limit=settings['pathogen_limit']
964
+ pathogen_limit=settings['pathogen_limit'],
965
+ change_plate=settings['change_plate']
962
966
  )
963
967
 
964
968
  if not settings['um_per_px'] is None:
@@ -985,8 +989,15 @@ def analyze_endodyogeny(settings):
985
989
  df = df.dropna(subset=[settings['group_column']])
986
990
  df = _calculate_volume_bins(df, settings['compartment'], settings['min_area_bin'], settings['max_bins'], settings['verbose'])
987
991
  output['data'] = df
992
+
993
+
994
+ if settings['level'] == 'plate':
995
+ prc_column = 'plate'
996
+ else:
997
+ prc_column = 'prc'
998
+
988
999
  # Perform chi-squared test and plot
989
- results_df, pairwise_results_df, fig = plot_proportion_stacked_bars(settings, df, settings['group_column'], bin_column=f"{settings['compartment']}_volume_bin", level=settings['level'])
1000
+ results_df, pairwise_results_df, fig = plot_proportion_stacked_bars(settings, df, settings['group_column'], bin_column=f"{settings['compartment']}_volume_bin", prc_column=prc_column, level=settings['level'], cmap=settings['cmap'])
990
1001
 
991
1002
  # Extract bin labels and indices for formatting the legend in the correct order
992
1003
  bin_labels = df[f"{settings['compartment']}_volume_bin"].cat.categories if pd.api.types.is_categorical_dtype(df[f"{settings['compartment']}_volume_bin"]) else sorted(df[f"{settings['compartment']}_volume_bin"].unique())
@@ -1005,10 +1016,12 @@ def analyze_endodyogeny(settings):
1005
1016
  output_dir = os.path.join(settings['src'][0], 'results', 'analyze_endodyogeny')
1006
1017
  os.makedirs(output_dir, exist_ok=True)
1007
1018
  output_path = os.path.join(output_dir, 'chi_squared_results.csv')
1019
+ output_path_data = os.path.join(output_dir, 'data.csv')
1008
1020
  output_path_pairwise = os.path.join(output_dir, 'chi_squared_results.csv')
1009
1021
  output_path_fig = os.path.join(output_dir, 'chi_squared_results.pdf')
1010
1022
  fig.savefig(output_path_fig, dpi=300, bbox_inches='tight')
1011
1023
  results_df.to_csv(output_path, index=False)
1024
+ df.to_csv(output_path_data, index=False)
1012
1025
  pairwise_results_df.to_csv(output_path_pairwise, index=False)
1013
1026
  print(f"Chi-squared results saved to {output_path}")
1014
1027
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spacr
3
- Version: 0.3.65
3
+ Version: 0.3.66
4
4
  Summary: Spatial phenotype analysis of crisp screens (SpaCr)
5
5
  Home-page: https://github.com/EinarOlafsson/spacr
6
6
  Author: Einar Birnir Olafsson
@@ -15,18 +15,18 @@ spacr/gui.py,sha256=ARyn9Q_g8HoP-cXh1nzMLVFCKqthY4v2u9yORyaQqQE,8230
15
15
  spacr/gui_core.py,sha256=N7R7yvfK_dJhOReM_kW3Ci8Bokhi1OzsxeKqvSGdvV4,41460
16
16
  spacr/gui_elements.py,sha256=EKlvEg_4_je7jciEdR3NTgPrcTraowa2e2RUt-xqd6M,138254
17
17
  spacr/gui_utils.py,sha256=u9RoIOWpAXFEOnUlLpMQZrc1pWSg6omZsJMIhJdRv_g,41211
18
- spacr/io.py,sha256=YlJAT6H8l4ipunMyKzjqoPcf-1AXgUmSyR1YN9WxmDI,142857
18
+ spacr/io.py,sha256=SLJKVqe5c3dFa6a7tXA5KMGhNGjhvLbyqsPlD1AqM3g,142962
19
19
  spacr/logger.py,sha256=lJhTqt-_wfAunCPl93xE65Wr9Y1oIHJWaZMjunHUeIw,1538
20
20
  spacr/measure.py,sha256=2lK-ZcTxLM-MpXV1oZnucRD9iz5aprwahRKw9IEqshg,55085
21
21
  spacr/mediar.py,sha256=FwLvbLQW5LQzPgvJZG8Lw7GniA2vbZx6Jv6vIKu7I5c,14743
22
22
  spacr/ml.py,sha256=GOQJH8jdTrJQwiLlDrcc9-yCxLFaMx4YD4OJs0-R5YI,77947
23
23
  spacr/openai.py,sha256=5vBZ3Jl2llYcW3oaTEXgdyCB2aJujMUIO5K038z7w_A,1246
24
- spacr/plot.py,sha256=LApfosnN9gaF6eGRrPGt3uZIwSwAT7kgRbMnUDuxx0Y,165160
24
+ spacr/plot.py,sha256=XPAabtZjzurL6zlG3KfqLEQTnH_jjo-k2jVajJt9om8,165166
25
25
  spacr/sequencing.py,sha256=ClUfwPPK6rNUbUuiEkzcwakzVyDKKUMv9ricrxT8qQY,25227
26
- spacr/settings.py,sha256=LSoDNuz1m7rySh7MWXEL1xlUU4rFiCRVlGvZCSCOqzU,80085
26
+ spacr/settings.py,sha256=wZcqdTWaRus27wn9P0EGyftcJn_i0IwlM9pyeCVqxr8,80173
27
27
  spacr/sim.py,sha256=1xKhXimNU3ukzIw-3l9cF3Znc_brW8h20yv8fSTzvss,71173
28
28
  spacr/stats.py,sha256=mbhwsyIqt5upsSD346qGjdCw7CFBa0tIS7zHU9e0jNI,9536
29
- spacr/submodules.py,sha256=3hgY8MWQTfajJbUIYmHMzYNd42d80L_0aN6bpoTUnu0,55059
29
+ spacr/submodules.py,sha256=SK8YEs850LAx30YAiwap7ecLpp1_p-bci6H-Or0GLoA,55500
30
30
  spacr/timelapse.py,sha256=KGfG4L4-QnFfgbF7L6C5wL_3gd_rqr05Foje6RsoTBg,39603
31
31
  spacr/toxo.py,sha256=z2nT5aAze3NUIlwnBQcnkARihDwoPfqOgQIVoUluyK0,25087
32
32
  spacr/utils.py,sha256=zojZlZtGwwDVDY0fgRt5XViVuJLuxadRO1IYctWm_SQ,221885
@@ -152,9 +152,9 @@ spacr/resources/icons/umap.png,sha256=dOLF3DeLYy9k0nkUybiZMe1wzHQwLJFRmgccppw-8b
152
152
  spacr/resources/images/plate1_E01_T0001F001L01A01Z01C02.tif,sha256=Tl0ZUfZ_AYAbu0up_nO0tPRtF1BxXhWQ3T3pURBCCRo,7958528
153
153
  spacr/resources/images/plate1_E01_T0001F001L01A02Z01C01.tif,sha256=m8N-V71rA1TT4dFlENNg8s0Q0YEXXs8slIn7yObmZJQ,7958528
154
154
  spacr/resources/images/plate1_E01_T0001F001L01A03Z01C03.tif,sha256=Pbhk7xn-KUP6RSIhJsxQcrHFImBm3GEpLkzx7WOc-5M,7958528
155
- spacr-0.3.65.dist-info/LICENSE,sha256=SR-2MeGc6SCM1UORJYyarSWY_A-JaOMFDj7ReSs9tRM,1083
156
- spacr-0.3.65.dist-info/METADATA,sha256=FHAKN1FrIXWI6vqz43lT8VPSPzBpEwRIC54aQaL0Mr8,6032
157
- spacr-0.3.65.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
158
- spacr-0.3.65.dist-info/entry_points.txt,sha256=BMC0ql9aNNpv8lUZ8sgDLQMsqaVnX5L535gEhKUP5ho,296
159
- spacr-0.3.65.dist-info/top_level.txt,sha256=GJPU8FgwRXGzKeut6JopsSRY2R8T3i9lDgya42tLInY,6
160
- spacr-0.3.65.dist-info/RECORD,,
155
+ spacr-0.3.66.dist-info/LICENSE,sha256=SR-2MeGc6SCM1UORJYyarSWY_A-JaOMFDj7ReSs9tRM,1083
156
+ spacr-0.3.66.dist-info/METADATA,sha256=A5XJI5cR864WLb08NonbMW2BEUHYn-fQgl8RMcdIK8M,6032
157
+ spacr-0.3.66.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
158
+ spacr-0.3.66.dist-info/entry_points.txt,sha256=BMC0ql9aNNpv8lUZ8sgDLQMsqaVnX5L535gEhKUP5ho,296
159
+ spacr-0.3.66.dist-info/top_level.txt,sha256=GJPU8FgwRXGzKeut6JopsSRY2R8T3i9lDgya42tLInY,6
160
+ spacr-0.3.66.dist-info/RECORD,,
File without changes