spacr 0.3.55__py3-none-any.whl → 0.3.60__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/ml.py CHANGED
@@ -191,18 +191,18 @@ def prepare_formula(dependent_variable, random_row_column_effects=False):
191
191
  if random_row_column_effects:
192
192
  # Random effects for row and column + gene weighted by gene_fraction + grna weighted by fraction
193
193
  return f'{dependent_variable} ~ fraction:grna + gene_fraction:gene'
194
- return f'{dependent_variable} ~ fraction:grna + gene_fraction:gene + row + column'
194
+ return f'{dependent_variable} ~ fraction:grna + gene_fraction:gene + row_name + column_name'
195
195
 
196
196
  def fit_mixed_model(df, formula, dst):
197
197
  from .plot import plot_histogram
198
198
 
199
- """Fit the mixed model with plate, row, and column as random effects and return results."""
199
+ """Fit the mixed model with plate, row_name, and column_name as random effects and return results."""
200
200
  # Specify random effects for plate, row, and column
201
201
  model = smf.mixedlm(formula,
202
202
  data=df,
203
203
  groups=df['plate'],
204
- re_formula="1 + row + column",
205
- vc_formula={"row": "0 + row", "column": "0 + column"})
204
+ re_formula="1 + row_name + column_name",
205
+ vc_formula={"row_name": "0 + row_name", "column_name": "0 + column_name"})
206
206
 
207
207
  mixed_model = model.fit()
208
208
 
@@ -284,7 +284,7 @@ def check_and_clean_data(df, dependent_variable):
284
284
  df = handle_missing_values(df, ['fraction', dependent_variable])
285
285
 
286
286
  # Step 2: Ensure grna, gene, plate, row, column, and prc are categorical types
287
- df = ensure_valid_types(df, ['grna', 'gene', 'plate', 'row_name', 'column', 'prc'])
287
+ df = ensure_valid_types(df, ['grna', 'gene', 'plate', 'row_name', 'column_name', 'prc'])
288
288
 
289
289
  # Step 3: Check for multicollinearity in fraction and the dependent variable
290
290
  df_cleaned = check_collinearity(df, ['fraction', dependent_variable])
@@ -295,7 +295,7 @@ def check_and_clean_data(df, dependent_variable):
295
295
  df_cleaned['prc'] = df['prc']
296
296
  df_cleaned['plate'] = df['plate']
297
297
  df_cleaned['row_name'] = df['row_name']
298
- df_cleaned['column'] = df['column']
298
+ df_cleaned['column_name'] = df['column']
299
299
 
300
300
  # Create a new column 'gene_fraction' that sums the fractions by gene within the same well
301
301
  df_cleaned['gene_fraction'] = df_cleaned.groupby(['prc', 'gene'])['fraction'].transform('sum')
@@ -631,9 +631,9 @@ def regression(df, csv_path, dependent_variable='predictions', regression_type=N
631
631
  random_row_column_effects=False, nc='233460', pc='220950', controls=[''],
632
632
  dst=None, cov_type=None, plot=False):
633
633
 
634
- from spacr.plot import volcano_plot, plot_histogram
635
- from spacr.ml import create_volcano_filename, check_and_clean_data, prepare_formula, scale_variables
636
-
634
+ from .plot import volcano_plot, plot_histogram
635
+ #from .ml import create_volcano_filename, check_and_clean_data, prepare_formula, scale_variables
636
+
637
637
  # Generate the volcano filename
638
638
  volcano_path = create_volcano_filename(csv_path, regression_type, alpha, dst)
639
639
 
@@ -1085,7 +1085,12 @@ def process_scores(df, dependent_variable, plate, min_cell_count=25, agg_type='m
1085
1085
  if 'plate_name' in df.columns:
1086
1086
  df.drop(columns=['plate'], inplace=True)
1087
1087
  df = df.rename(columns={'plate_name': 'plate'})
1088
-
1088
+
1089
+ if 'row' in df.columns:
1090
+ df = df.rename(columns={'row': 'row_name'})
1091
+ if 'col' in df.columns:
1092
+ df = df.rename(columns={'row': 'column_name'})
1093
+
1089
1094
  if plate is not None:
1090
1095
  df['plate'] = plate
1091
1096
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spacr
3
- Version: 0.3.55
3
+ Version: 0.3.60
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
@@ -19,7 +19,7 @@ spacr/io.py,sha256=VHs6h8o0gBEyKxfdNqEhpzjQXPrj7UGG47DwHeUyUDw,143390
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
- spacr/ml.py,sha256=MpoHjziUM35GVuoYQCXN5DI77u1r7m7rtv7j3xqMNUc,68044
22
+ spacr/ml.py,sha256=aberLbvUM9F6uNpEOFHzn8_w-fiW0sDG3jVb6TDxakI,68275
23
23
  spacr/openai.py,sha256=5vBZ3Jl2llYcW3oaTEXgdyCB2aJujMUIO5K038z7w_A,1246
24
24
  spacr/plot.py,sha256=Y5_VuRHNsIH7iezK8kWXHg9fwh5sW3S34ncIFshbBco,157893
25
25
  spacr/sequencing.py,sha256=ClUfwPPK6rNUbUuiEkzcwakzVyDKKUMv9ricrxT8qQY,25227
@@ -151,9 +151,9 @@ spacr/resources/icons/umap.png,sha256=dOLF3DeLYy9k0nkUybiZMe1wzHQwLJFRmgccppw-8b
151
151
  spacr/resources/images/plate1_E01_T0001F001L01A01Z01C02.tif,sha256=Tl0ZUfZ_AYAbu0up_nO0tPRtF1BxXhWQ3T3pURBCCRo,7958528
152
152
  spacr/resources/images/plate1_E01_T0001F001L01A02Z01C01.tif,sha256=m8N-V71rA1TT4dFlENNg8s0Q0YEXXs8slIn7yObmZJQ,7958528
153
153
  spacr/resources/images/plate1_E01_T0001F001L01A03Z01C03.tif,sha256=Pbhk7xn-KUP6RSIhJsxQcrHFImBm3GEpLkzx7WOc-5M,7958528
154
- spacr-0.3.55.dist-info/LICENSE,sha256=SR-2MeGc6SCM1UORJYyarSWY_A-JaOMFDj7ReSs9tRM,1083
155
- spacr-0.3.55.dist-info/METADATA,sha256=7MVci9IvzjK-fdFuASU8NAo3oOccK_g6cAYd06_IZLY,6032
156
- spacr-0.3.55.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
157
- spacr-0.3.55.dist-info/entry_points.txt,sha256=BMC0ql9aNNpv8lUZ8sgDLQMsqaVnX5L535gEhKUP5ho,296
158
- spacr-0.3.55.dist-info/top_level.txt,sha256=GJPU8FgwRXGzKeut6JopsSRY2R8T3i9lDgya42tLInY,6
159
- spacr-0.3.55.dist-info/RECORD,,
154
+ spacr-0.3.60.dist-info/LICENSE,sha256=SR-2MeGc6SCM1UORJYyarSWY_A-JaOMFDj7ReSs9tRM,1083
155
+ spacr-0.3.60.dist-info/METADATA,sha256=UF63-vN6-XEslhGhnotkQz6JanIajbV56bKcSEaEIjE,6032
156
+ spacr-0.3.60.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
157
+ spacr-0.3.60.dist-info/entry_points.txt,sha256=BMC0ql9aNNpv8lUZ8sgDLQMsqaVnX5L535gEhKUP5ho,296
158
+ spacr-0.3.60.dist-info/top_level.txt,sha256=GJPU8FgwRXGzKeut6JopsSRY2R8T3i9lDgya42tLInY,6
159
+ spacr-0.3.60.dist-info/RECORD,,
File without changes