spacr 0.3.37__py3-none-any.whl → 0.3.38__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/plot.py +7 -1
- spacr/utils.py +10 -10
- {spacr-0.3.37.dist-info → spacr-0.3.38.dist-info}/METADATA +1 -1
- {spacr-0.3.37.dist-info → spacr-0.3.38.dist-info}/RECORD +8 -8
- {spacr-0.3.37.dist-info → spacr-0.3.38.dist-info}/LICENSE +0 -0
- {spacr-0.3.37.dist-info → spacr-0.3.38.dist-info}/WHEEL +0 -0
- {spacr-0.3.37.dist-info → spacr-0.3.38.dist-info}/entry_points.txt +0 -0
- {spacr-0.3.37.dist-info → spacr-0.3.38.dist-info}/top_level.txt +0 -0
spacr/plot.py
CHANGED
@@ -2152,10 +2152,12 @@ class spacrGraph:
|
|
2152
2152
|
def preprocess_data(self):
|
2153
2153
|
"""Preprocess the data: remove NaNs, sort/order the grouping column, and optionally group by 'prc'."""
|
2154
2154
|
# Remove NaNs in both the grouping column and each data column
|
2155
|
-
df = self.df.dropna(subset=[self.grouping_column] + self.data_column)
|
2155
|
+
df = self.df.dropna(subset=[self.grouping_column] + self.data_column)
|
2156
2156
|
# Group by 'prc' column if representation is 'well'
|
2157
2157
|
if self.representation == 'well':
|
2158
2158
|
df = df.groupby(['prc', self.grouping_column])[self.data_column].agg(self.summary_func).reset_index()
|
2159
|
+
if self.representation == 'plate':
|
2160
|
+
df = df.groupby(['plate', self.grouping_column])[self.data_column].agg(self.summary_func).reset_index()
|
2159
2161
|
if self.order:
|
2160
2162
|
df[self.grouping_column] = pd.Categorical(df[self.grouping_column], categories=self.order, ordered=True)
|
2161
2163
|
else:
|
@@ -2653,6 +2655,10 @@ def plot_data_from_db(settings):
|
|
2653
2655
|
|
2654
2656
|
df = df.dropna(subset=settings['column_name'])
|
2655
2657
|
df = df.dropna(subset=settings['grouping_column'])
|
2658
|
+
|
2659
|
+
|
2660
|
+
|
2661
|
+
|
2656
2662
|
#display(df)
|
2657
2663
|
|
2658
2664
|
#df['class'] = df['png_path'].apply(lambda x: 'class_1' if 'class_1' in x else ('class_0' if 'class_0' in x else None))
|
spacr/utils.py
CHANGED
@@ -5047,6 +5047,7 @@ def add_column_to_database(settings):
|
|
5047
5047
|
"""
|
5048
5048
|
Adds a new column to the database table by matching on a common column from the DataFrame.
|
5049
5049
|
If the column already exists in the database, it adds the column with a suffix.
|
5050
|
+
NaN values will remain as NULL in the database.
|
5050
5051
|
|
5051
5052
|
Parameters:
|
5052
5053
|
- settings: A dictionary containing the following keys:
|
@@ -5060,7 +5061,7 @@ def add_column_to_database(settings):
|
|
5060
5061
|
# Read the DataFrame from the provided CSV path
|
5061
5062
|
df = pd.read_csv(settings['csv_path'])
|
5062
5063
|
|
5063
|
-
#
|
5064
|
+
# Replace 0 values with 2 in the update column
|
5064
5065
|
if (df[settings['update_column']] == 0).any():
|
5065
5066
|
print("Replacing all 0 values with 2 in the update column.")
|
5066
5067
|
df[settings['update_column']].replace(0, 2, inplace=True)
|
@@ -5073,12 +5074,10 @@ def add_column_to_database(settings):
|
|
5073
5074
|
cursor.execute(f"PRAGMA table_info({settings['table_name']})")
|
5074
5075
|
columns_in_db = [col[1] for col in cursor.fetchall()]
|
5075
5076
|
|
5076
|
-
#
|
5077
|
+
# Add a suffix if the update column already exists in the database
|
5077
5078
|
if settings['update_column'] in columns_in_db:
|
5078
|
-
# Add a suffix to the column name (e.g., '_new', '_1', or similar)
|
5079
5079
|
suffix = 1
|
5080
5080
|
new_column_name = f"{settings['update_column']}_{suffix}"
|
5081
|
-
# Ensure uniqueness by incrementing the suffix if needed
|
5082
5081
|
while new_column_name in columns_in_db:
|
5083
5082
|
suffix += 1
|
5084
5083
|
new_column_name = f"{settings['update_column']}_{suffix}"
|
@@ -5086,8 +5085,8 @@ def add_column_to_database(settings):
|
|
5086
5085
|
else:
|
5087
5086
|
new_column_name = settings['update_column']
|
5088
5087
|
|
5089
|
-
# Add the new column to the database table
|
5090
|
-
cursor.execute(f"ALTER TABLE {settings['table_name']} ADD COLUMN {new_column_name}
|
5088
|
+
# Add the new column with INTEGER type to the database table
|
5089
|
+
cursor.execute(f"ALTER TABLE {settings['table_name']} ADD COLUMN {new_column_name} INTEGER")
|
5091
5090
|
print(f"Added new column '{new_column_name}' to the table '{settings['table_name']}'.")
|
5092
5091
|
|
5093
5092
|
# Iterate over the DataFrame and update the new column in the database
|
@@ -5095,6 +5094,10 @@ def add_column_to_database(settings):
|
|
5095
5094
|
value_to_update = row[settings['update_column']]
|
5096
5095
|
match_value = row[settings['match_column']]
|
5097
5096
|
|
5097
|
+
# Handle NaN values by converting them to None (SQLite equivalent of NULL)
|
5098
|
+
if pd.isna(value_to_update):
|
5099
|
+
value_to_update = None
|
5100
|
+
|
5098
5101
|
# Prepare and execute the SQL update query
|
5099
5102
|
query = f"""
|
5100
5103
|
UPDATE {settings['table_name']}
|
@@ -5107,7 +5110,4 @@ def add_column_to_database(settings):
|
|
5107
5110
|
conn.commit()
|
5108
5111
|
conn.close()
|
5109
5112
|
|
5110
|
-
print(f"Updated '{new_column_name}' in '{settings['table_name']}' using '{settings['match_column']}'.")
|
5111
|
-
|
5112
|
-
|
5113
|
-
|
5113
|
+
print(f"Updated '{new_column_name}' in '{settings['table_name']}' using '{settings['match_column']}'.")
|
@@ -20,14 +20,14 @@ spacr/measure.py,sha256=BThn_sALgKrwGKnLOGpT4FyoJeRVoTZoP9SXbCtCMRw,54857
|
|
20
20
|
spacr/mediar.py,sha256=FwLvbLQW5LQzPgvJZG8Lw7GniA2vbZx6Jv6vIKu7I5c,14743
|
21
21
|
spacr/ml.py,sha256=ItibDL_q0cKwEsJdwpBtVqfpRQGPXGbb0BX5UB5iH5s,49342
|
22
22
|
spacr/openai.py,sha256=5vBZ3Jl2llYcW3oaTEXgdyCB2aJujMUIO5K038z7w_A,1246
|
23
|
-
spacr/plot.py,sha256=
|
23
|
+
spacr/plot.py,sha256=W6F2Jaxq7WBnB9G3-7AESdQs6foGeyS70-LZwKgKJv8,118214
|
24
24
|
spacr/sequencing.py,sha256=t18mgpK6rhWuB1LtFOsPxqgpFXxuUmrD06ecsaVQ0Gw,19655
|
25
25
|
spacr/settings.py,sha256=AzP9NGiXI1MqT69bHObxwDSCUk0kdstBVvl1JpcD_-w,75960
|
26
26
|
spacr/sim.py,sha256=1xKhXimNU3ukzIw-3l9cF3Znc_brW8h20yv8fSTzvss,71173
|
27
27
|
spacr/submodules.py,sha256=AB7s6-cULsaqz-haAaCtXfGEIi8uPZGT4xoCslUJC3Y,18391
|
28
28
|
spacr/timelapse.py,sha256=FSYpUtAVy6xc3lwprRYgyDTT9ysUhfRQ4zrP9_h2mvg,39465
|
29
29
|
spacr/toxo.py,sha256=us3pQyULtMTyfTq0MWPn4QJTTmQ6BwAJKChNf75jo3I,10082
|
30
|
-
spacr/utils.py,sha256=
|
30
|
+
spacr/utils.py,sha256=j6qE7aTGu7D82_A68md5b5Vgn8UrW2w2saa6nCbANw8,216373
|
31
31
|
spacr/version.py,sha256=axH5tnGwtgSnJHb5IDhiu4Zjk5GhLyAEDRe-rnaoFOA,409
|
32
32
|
spacr/resources/MEDIAR/.gitignore,sha256=Ff1q9Nme14JUd-4Q3jZ65aeQ5X4uttptssVDgBVHYo8,152
|
33
33
|
spacr/resources/MEDIAR/LICENSE,sha256=yEj_TRDLUfDpHDNM0StALXIt6mLqSgaV2hcCwa6_TcY,1065
|
@@ -150,9 +150,9 @@ spacr/resources/icons/umap.png,sha256=dOLF3DeLYy9k0nkUybiZMe1wzHQwLJFRmgccppw-8b
|
|
150
150
|
spacr/resources/images/plate1_E01_T0001F001L01A01Z01C02.tif,sha256=Tl0ZUfZ_AYAbu0up_nO0tPRtF1BxXhWQ3T3pURBCCRo,7958528
|
151
151
|
spacr/resources/images/plate1_E01_T0001F001L01A02Z01C01.tif,sha256=m8N-V71rA1TT4dFlENNg8s0Q0YEXXs8slIn7yObmZJQ,7958528
|
152
152
|
spacr/resources/images/plate1_E01_T0001F001L01A03Z01C03.tif,sha256=Pbhk7xn-KUP6RSIhJsxQcrHFImBm3GEpLkzx7WOc-5M,7958528
|
153
|
-
spacr-0.3.
|
154
|
-
spacr-0.3.
|
155
|
-
spacr-0.3.
|
156
|
-
spacr-0.3.
|
157
|
-
spacr-0.3.
|
158
|
-
spacr-0.3.
|
153
|
+
spacr-0.3.38.dist-info/LICENSE,sha256=SR-2MeGc6SCM1UORJYyarSWY_A-JaOMFDj7ReSs9tRM,1083
|
154
|
+
spacr-0.3.38.dist-info/METADATA,sha256=IfwGcod8ZUdemPlpbdoCoONBap_IZQCfiL-KURN3KuI,5949
|
155
|
+
spacr-0.3.38.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
|
156
|
+
spacr-0.3.38.dist-info/entry_points.txt,sha256=BMC0ql9aNNpv8lUZ8sgDLQMsqaVnX5L535gEhKUP5ho,296
|
157
|
+
spacr-0.3.38.dist-info/top_level.txt,sha256=GJPU8FgwRXGzKeut6JopsSRY2R8T3i9lDgya42tLInY,6
|
158
|
+
spacr-0.3.38.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|