Skip to content

Commit 0e89811

Browse files
committed
FIlter data and bypass broken loadData conditions argument
The "conditions" argument for loadData in SSIT.m is not properly filtering by Dex concentration. Have pre-processed data with Python for now.
1 parent ab76439 commit 0e89811

11 files changed

+13385
-15
lines changed

WorkSpace/EricModel/EricData/GR_ALL_gated_with_CytoArea_and_normGR_Feb2825_03_dex_conc_1.csv

+1,944
Large diffs are not rendered by default.

WorkSpace/EricModel/EricData/GR_ALL_gated_with_CytoArea_and_normGR_Feb2825_03_dex_conc_10.csv

+1,767
Large diffs are not rendered by default.

WorkSpace/EricModel/EricData/GR_ALL_gated_with_CytoArea_and_normGR_Feb2825_03_dex_conc_100.csv

+1,825
Large diffs are not rendered by default.

WorkSpace/EricModel/EricData/Gated_dataframe_Ron_020224_NormalizedGR_bins_Dex_Conc_1.csv

+2,656
Large diffs are not rendered by default.

WorkSpace/EricModel/EricData/Gated_dataframe_Ron_020224_NormalizedGR_bins_Dex_Conc_10.csv

+2,516
Large diffs are not rendered by default.

WorkSpace/EricModel/EricData/Gated_dataframe_Ron_020224_NormalizedGR_bins_Dex_Conc_100.csv

+2,552
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import pandas as pd
2+
import numpy as np
3+
4+
# Load the CSV file
5+
file_path = 'pdoCalibrationData_NeuertLab_240925.csv'
6+
data = pd.read_csv(file_path)
7+
8+
# Filter the data based on Condition = '2M_NaCl_Step'
9+
filtered_data = data.loc[data['Condition'].str.contains('2M_NaCl_Step', case=False, na=False),
10+
['Cell_id', 'Condition', 'Replica', 'Conc_mM', 'Time_index_min',
11+
'RNA_STL1_cyto_TS3Full', 'RNA_STL1_nuc_TS3Full', 'Cyto_STL1_avg_int_TS3Full', 'Nuc_STL1_avg_int_TS3Full']]
12+
13+
# Sum 'RNA_STL1_cyto_TS3Full' and 'RNA_STL1_nuc_TS3Full' into new column 'RNA_STL1_total_TS3Full'
14+
filtered_data['RNA_STL1_total_TS3Full'] = filtered_data['RNA_STL1_cyto_TS3Full'] + filtered_data['RNA_STL1_nuc_TS3Full']
15+
16+
# Sum 'Cyto_STL1_avg_int_TS3Full' and 'Nuc_STL1_avg_int_TS3Full' into new column 'STL1_avg_int_TS3Full' and transform it into an integer for SSIT
17+
#filtered_data['STL1_avg_int_TS3Full'] = (filtered_data['Cyto_STL1_avg_int_TS3Full'] + filtered_data['Nuc_STL1_avg_int_TS3Full']).astype(int)
18+
# Fill NaN or inf values with 0, then sum and convert to integer
19+
filtered_data['STL1_avg_int_TS3Full'] = (
20+
filtered_data['Cyto_STL1_avg_int_TS3Full'].replace([np.inf, -np.inf], np.nan).fillna(0) +
21+
filtered_data['Nuc_STL1_avg_int_TS3Full'].replace([np.inf, -np.inf], np.nan).fillna(0)
22+
).astype(int)
23+
24+
25+
# Replace 'Time_index_min' with 'time' to be read by SSIT.m
26+
filtered_data.rename(columns={'Time_index_min': 'time'}, inplace=True)
27+
28+
# Define the output file path
29+
output_file = 'filtered_data_2M_NaCl_Step.csv'
30+
31+
# Save the filtered data to a new CSV file
32+
filtered_data.to_csv(output_file, index=False)
33+
34+
output_file
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import pandas as pd
2+
3+
# Load the CSV file
4+
file_path = "GR_ALL_gated_with_CytoArea_and_normGR_Feb2825_03.csv"
5+
df = pd.read_csv(file_path)
6+
7+
# Check the first few rows to understand the structure
8+
df.head()
9+
10+
# Define the required columns
11+
required_columns = ["nucGRint", "cytoGRint", "time", "dex_conc", "unique_cell_id", "normGRcyt", "normGRnuc"]
12+
13+
# Filter the DataFrame to only include the required columns
14+
df_filtered = df[required_columns]
15+
16+
# Define the output file paths
17+
output_files = {
18+
1: "GR_ALL_gated_with_CytoArea_and_normGR_Feb2825_03_dex_conc_1.csv",
19+
10: "GR_ALL_gated_with_CytoArea_and_normGR_Feb2825_03_dex_conc_10.csv",
20+
100: "GR_ALL_gated_with_CytoArea_and_normGR_Feb2825_03_dex_conc_100.csv"
21+
}
22+
23+
# Filter and save the data for each Dex_Conc value
24+
for conc, path in output_files.items():
25+
df_filtered_conc = df_filtered[df_filtered["dex_conc"] == conc]
26+
df_filtered_conc.to_csv(path, index=False)
27+
28+
# Provide confirmation
29+
output_files

WorkSpace/EricModel/a0_Fit_GR_and_DUSP1_models.m

+55-15
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
else
5959
%% STEP 0.B. -- Create Base Model for GR Only
6060
% Here, I set up the model for the GR translocation dynamics.
61-
fitOptions = optimset('Display','iter','MaxIter',300);
61+
fitOptions = optimset('Display','iter','MaxIter',200);
6262

6363
% Create blank SSIT model.
6464
ModelGR = SSIT;
@@ -115,10 +115,28 @@
115115
ModelGRparameterMap = cell(1,size(GRfitCases,1));
116116
ModelGRfit = cell(1,size(GRfitCases,1));
117117
% ModelGRODEfit = cell(1,size(GRfitCases,1));
118+
119+
% OLD GR DATA
120+
% ModelGRfit{1} = ModelGR.loadData("EricData/Gated_dataframe_Ron_020224_NormalizedGR_bins_Dex_Conc_1.csv",...
121+
% {'nucGR','normgrnuc';'cytGR','normgrcyt'});
122+
% ModelGRfit{2} = ModelGR.loadData("EricData/Gated_dataframe_Ron_020224_NormalizedGR_bins_Dex_Conc_10.csv",...
123+
% {'nucGR','normgrnuc';'cytGR','normgrcyt'});
124+
% ModelGRfit{3} = ModelGR.loadData("EricData/Gated_dataframe_Ron_020224_NormalizedGR_bins_Dex_Conc_100.csv",...
125+
% {'nucGR','normgrnuc';'cytGR','normgrcyt'});
126+
127+
% NEW GR DATA
128+
ModelGRfit{1} = ModelGR.loadData("EricData/GR_ALL_gated_with_CytoArea_and_normGR_Feb2825_03_dex_conc_1.csv",...
129+
{'nucGR','normGRnuc';'cytGR','normGRcyt'});
130+
ModelGRfit{2} = ModelGR.loadData("EricData/GR_ALL_gated_with_CytoArea_and_normGR_Feb2825_03_dex_conc_10.csv",...
131+
{'nucGR','normGRnuc';'cytGR','normGRcyt'});
132+
ModelGRfit{3} = ModelGR.loadData("EricData/GR_ALL_gated_with_CytoArea_and_normGR_Feb2825_03_dex_conc_100.csv",...
133+
{'nucGR','normGRnuc';'cytGR','normGRcyt'});
134+
118135
for i=1:3
119-
ModelGRfit{i} = ModelGR.loadData("EricData/GR_ALL_gated_with_CytoArea_and_normGR_Feb2825_03.csv",... %ModelGRfit{i} = ModelGR.loadData("EricData/Gated_dataframe_Ron_020224_NormalizedGR_bins.csv",... %
120-
{'nucGR','normGRnuc';'cytGR','normGRcyt'},...
121-
{'Dex_Conc',GRfitCases{i,2}});
136+
% ModelGRfit{i} = ModelGR.loadData("EricData/Gated_dataframe_Ron_020224_NormalizedGR_bins.csv",...
137+
% {'nucGR','normgrnuc';'cytGR','normgrcyt'},...
138+
% {'Dex_Conc',GRfitCases{i,2}});
139+
%ModelGRfit{i} = ModelGR.loadData("EricData/GR_ALL_gated_with_CytoArea_and_normGR_Feb2825_03.csv",{'nucGR','normGRnuc';'cytGR','normGRcyt'},
122140
ModelGRfit{i}.parameters(13,:) = {'Dex0', str2num(GRfitCases{i,1})};
123141
ModelGRparameterMap(i) = {(1:8)};
124142
% parameters 1 - 8 refer to the parameter set that is relevant to
@@ -159,12 +177,11 @@
159177

160178
% STEP 1.C. -- Combine all three GR models and fit using a single parameter set.
161179
for jj = 1:fitIters
162-
combinedGRModel = SSITMultiModel(ModelGRfit,ModelGRparameterMap,logPriorGR);
163-
combinedGRModel = combinedGRModel.initializeStateSpaces(boundGuesses);
164-
combinedGRModel = combinedGRModel.updateModels(GRpars,false);
165-
GRpars = combinedGRModel.maximizeLikelihood(...
166-
GRpars, fitOptions);
167-
save('EricModel_MMDex','GRpars')
180+
combinedGRModel = SSITMultiModel(ModelGRfit,ModelGRparameterMap,logPriorGR);
181+
combinedGRModel = combinedGRModel.initializeStateSpaces(boundGuesses);
182+
combinedGRModel = combinedGRModel.updateModels(GRpars,false);
183+
GRpars = combinedGRModel.maximizeLikelihood(GRpars, fitOptions);
184+
save('EricModel_MMDex','GRpars')
168185
end
169186

170187
save('EricModelGR_MMDex','GRpars','combinedGRModel', 'ModelGRfit', 'log10PriorStd')
@@ -213,16 +230,39 @@
213230
end
214231

215232
%%
216-
for i=1:3
217-
combinedGRModel.SSITModels{i} = combinedGRModel.SSITModels{i}.loadData("EricData/GR_ALL_gated_with_CytoArea_and_normGR_Feb2825_03.csv",...
218-
{'nucGR','normGRnuc';'cytGR','normGRcyt'});
219-
end
233+
% dex_conc_values = [1, 10, 100];
234+
%
235+
% for i = 1:3
236+
% % Load the full dataset first
237+
% fullData = readtable("EricData/GR_ALL_gated_with_CytoArea_and_normGR_Feb2825_03.csv");
238+
%
239+
% % Filter based on dex_conc value
240+
% filteredData = fullData(fullData.dex_conc == dex_conc_values(i), :);
241+
%
242+
% % Save filtered data to a temporary file (optional if loadData can take a table directly)
243+
% tempFile = sprintf("temp_filtered_data_%d.csv", dex_conc_values(i));
244+
% writetable(filteredData, tempFile);
245+
%
246+
% % Load the filtered data
247+
% combinedGRModel.SSITModels{i} = combinedGRModel.SSITModels{i}.loadData(tempFile, ...
248+
% {'nucGR','normGRnuc';'cytGR','normGRcyt'});
249+
% end
250+
220251

221252
%% STEP 1.F. -- Make Plots of GR Fit Results
222253
makeGRPlots(combinedGRModel,GRpars)
223254

255+
256+
%combinedGRModel = combinedGRModel.updateModels(GRpars,false);
257+
%for i=1:length(ModelGRfit)
258+
% Update parameters in original models.
259+
% ModelGRfit{i} = combinedGRModel.SSITModels{i};
260+
% ModelGRfit{i}.tSpan = sort(unique([ModelGRfit{i}.tSpan,linspace(0,180,30)]));
261+
% ModelGRfit{i}.makeFitPlot([],1,[],true,'STD')
262+
%end
263+
224264
save('EricModelGR_MMDex','GRpars','combinedGRModel','MHResultsGR')
225-
save('workspaceMay4_2024.mat','GRpars', 'ModelGRfit', 'combinedGRModel','MHResultsGR', 'log10PriorStd', 'ModelGRparameterMap')
265+
save('workspaceMay4_2025.mat','GRpars', 'ModelGRfit', 'combinedGRModel','MHResultsGR', 'log10PriorStd', 'ModelGRparameterMap')
226266

227267
%% STEP 2 -- Extend Model to Include DUSP1 Activation, Production, and Degradation
228268
if loadPrevious
703 KB
Binary file not shown.

src/gui/data_loading/makeSeparatePlotOfData.m

+7
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ function makeSeparatePlotOfData(app,smoothWindow,fignums,usePanels,varianceType,
214214
cols = ['b','r','g','m','c','k'];
215215
cols2 = [.90 .90 1.00; 1.00 .90 .90; .90 1.00 .90; .60 .60 1.00; 1.00 .60 .60; .60 1.00 .60];
216216
LG = {};
217+
218+
%% 1:NdDat can be changed to plot species separately (e.g., separate cytGR and nucGR plots)
217219
for iplt=1:NdDat
220+
%for iplt=2:2
218221
% if Plts_to_make(iplt)
219222
switch varianceType
220223
case 'STD'
@@ -235,7 +238,9 @@ function makeSeparatePlotOfData(app,smoothWindow,fignums,usePanels,varianceType,
235238

236239
%% Add data to trajectory plot.
237240
for iTime = 1:numTimes
241+
%% 1:NdDat can be changed to plot species separately (e.g., separate cytGR and nucGR plots)
238242
for j=1:NdDat
243+
%for j=2:2
239244
mnsDat(iTime,j) = [0:length(dataHistTime{iTime,j})-1]*dataHistTime{iTime,j};
240245
mns2Dat(iTime,j) = [0:length(dataHistTime{iTime,j})-1].^2*dataHistTime{iTime,j};
241246
% Compute the 25% and 75% range from data.
@@ -254,7 +259,9 @@ function makeSeparatePlotOfData(app,smoothWindow,fignums,usePanels,varianceType,
254259
end
255260
varDat = mns2Dat-mnsDat.^2;
256261
T_array = app.DataLoadingAndFittingTabOutputs.fittingOptions.dataTimes;
262+
%% 1:NdDat can be changed to plot species separately (e.g., separate cytGR and nucGR plots)
257263
for j=1:NdDat
264+
%for j=2:2
258265
switch varianceType
259266
case 'STD'
260267
errorbar(meanVarTrajAxis,T_array,...

0 commit comments

Comments
 (0)