Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Commit

Permalink
Build is running again (#947)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarmey authored Sep 7, 2023
1 parent 78bc0b1 commit 491a422
Show file tree
Hide file tree
Showing 16 changed files with 683 additions and 611 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: poetry install --no-root
run: poetry install
- name: Build figures
run: make all -j 3
- name: Upload files
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: poetry install --no-root
run: poetry install
- name: Test with pytest
run: poetry run pytest --junitxml=junit.xml --cov-branch --cov=ckine --cov-report xml:coverage.xml
2 changes: 1 addition & 1 deletion ckine/FCimports.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path
import pandas as pd
import numpy as np
from FlowCytometryTools import FCMeasurement, PolyGate
from FlowCytometryTools import FCMeasurement

path_here = dirname(dirname(__file__))

Expand Down
10 changes: 5 additions & 5 deletions ckine/MBmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def cytBindingModel(mut, val, doseVec, cellType, x=False, date=False):

mutAffDF = pd.read_csv(join(path_here, "ckine/data/WTmutAffData.csv"))
Affs = mutAffDF.loc[(mutAffDF.Mutein == mut)]
Affs = np.power(np.array([Affs["IL2RaKD"].values, Affs["IL2RBGKD"].values]) / 1e9, -1)
Affs = np.power(np.array([Affs["IL2RaKD"].values, Affs["IL2RBGKD"].values], dtype=float) / 1e9, -1)
Affs = np.reshape(Affs, (1, -1))
Affs = np.repeat(Affs, 2, axis=0)
np.fill_diagonal(Affs, 1e2) # Each cytokine can only bind one a and one b
Expand Down Expand Up @@ -109,8 +109,8 @@ def runFullModel(x=False, time=[0.5], saveDict=False, singleCell=False):
statDF = statDF.loc[(statDF.Ligand != "H16L N-term (Mono)") & (statDF.Ligand != "IL15 (Mono)")]
statDF = statDF.loc[(statDF.Time.isin(time))]

dateConvDF = pd.DataFrame(columns={"Date", "Scale", "Cell"})
masterSTAT = pd.DataFrame(columns={"Ligand", "Date", "Cell", "Time", "Dose", "Valency", "Experimental", "Predicted"})
dateConvDF = pd.DataFrame(columns=["Date", "Scale", "Cell"])
masterSTAT = pd.DataFrame(columns=["Ligand", "Date", "Cell", "Time", "Dose", "Valency", "Experimental", "Predicted"])
dates = statDF.Date.unique()

for (date, lig, conc, cell, time), group in statDF.groupby(["Date", "Ligand", "Dose", "Cell", "Time"]):
Expand Down Expand Up @@ -156,8 +156,8 @@ def runFullModelMeyer(x=False, saveDict=False):
"""Runs model for all data points and outputs date conversion dict for binding to pSTAT. Can be used to fit Kx"""
statDF = import_pstat_all_meyer()

dateConvDF = pd.DataFrame(columns={"Date", "Scale", "Cell"})
masterSTAT = pd.DataFrame(columns={"Ligand", "Date", "Cell", "Dose", "Valency", "Experimental", "Predicted"})
dateConvDF = pd.DataFrame(columns=["Date", "Scale", "Cell"])
masterSTAT = pd.DataFrame(columns=["Ligand", "Date", "Cell", "Dose", "Valency", "Experimental", "Predicted"])
dates = statDF.Date.unique()

for (date, lig, val, conc, cell), group in statDF.groupby(["Date", "Ligand", "Valency", "Dose", "Cell"]):
Expand Down
2 changes: 1 addition & 1 deletion ckine/PCA.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def StatGini(sampleType, ax, cell_type, date, Tcells=True):

def nllsq_EC50(x0, xdata, ydata):
""" Performs nonlinear least squares on activity measurements to determine parameters of Hill equation and outputs EC50. """
lsq_res = least_squares(residuals, x0, args=(xdata, ydata), bounds=([0.0, 0.0, 0.0], [10, 10.0, 10 ** 5.0]), jac="3-point")
lsq_res = least_squares(residuals, x0, method="dogbox", args=(xdata, ydata), bounds=([0.0, 0.0, 0.0], [10, 10.0, 10 ** 5.0]), jac="3-point")
return lsq_res.x[0]


Expand Down
4 changes: 2 additions & 2 deletions ckine/figures/figureC1.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def fullHeatMap(ax, respDF):
def dosePlot(ax, respDF, time, cell, ligList=False, legend=False):
"""Plots the various affinities for IL-2 Muteins"""
doses = np.log10(np.logspace(np.log10(respDF.Dose.min()), np.log10(respDF.Dose.max()), 100)) + 4
x0 = [4, 1, 2]
x0 = [4.0, 1.0, 2.0]
hillDF = pd.DataFrame()
if not ligList:
Ligands = respDF.Ligand.unique()
Expand All @@ -125,7 +125,7 @@ def dosePlot(ax, respDF, time, cell, ligList=False, legend=False):
isoData = respDF.loc[(respDF.Ligand == ligand) & (respDF.Valency == valency)]
xData = np.nan_to_num(np.log10(isoData.Dose.values)) + 4
yData = np.nan_to_num(isoData.Mean.values)
fit = least_squares(hill_residuals, x0, args=(xData, yData), bounds=([0.0, 0.0, 2], [5, 10.0, 6]), jac="3-point")
fit = least_squares(hill_residuals, x0, method="dogbox", args=(xData, yData), bounds=([0.0, 0.0, 2], [5, 10.0, 6]), jac="3-point")
hillDF = pd.concat([hillDF, pd.DataFrame({"Ligand": ligand, "Valency": valency, "Dose": np.power(10, doses - 4), "pSTAT": hill_equation(fit.x, doses)})])

maxobs = hillDF.loc[(hillDF.Ligand == "IL2")].pSTAT.max()
Expand Down
3 changes: 1 addition & 2 deletions ckine/figures/figureC2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import least_squares
from os.path import join
from copy import copy
from .figureCommon import subplotLabel, getSetup, getLigDict, get_cellTypeDict, getLigandLegend, Wass_KL_Dist, CITE_RIDGE, hillRatioDosePlot
from .figureCommon import subplotLabel, getSetup, getLigDict, get_cellTypeDict, getLigandLegend, Wass_KL_Dist, hillRatioDosePlot
from ..imports import import_pstat_all

path_here = os.path.dirname(os.path.dirname(__file__))
Expand Down
11 changes: 5 additions & 6 deletions ckine/figures/figureC4.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.metrics import r2_score
from scipy.optimize import minimize
from copy import copy
from .figureCommon import subplotLabel, getSetup, get_cellTypeDict, get_doseLimDict, get_cellTypeDict, get_valency_dict, ligand_ratio_plot
from ..PCA import nllsq_EC50
Expand Down Expand Up @@ -67,7 +66,7 @@ def Pred_Exp_plot(ax, df):

def R2_Plot_Cells(ax, df):
"""Plots all accuracies per cell"""
accDF = pd.DataFrame(columns={"Cell Type", "Valency", "Accuracy"})
accDF = pd.DataFrame(columns=["Cell Type", "Valency", "Accuracy"])
cellTypes = ['Treg $IL2Ra^{hi}$', 'Treg', 'Treg $IL2Ra^{lo}$', 'Thelper $IL2Ra^{hi}$', 'Thelper', 'Thelper $IL2Ra^{lo}$', 'CD8', 'NK', 'NKBright']
for cell in cellTypes:
for val in df.Valency.unique():
Expand All @@ -84,7 +83,7 @@ def R2_Plot_Cells(ax, df):

def R2_Plot_Ligs(ax, df):
"""Plots all accuracies per ligand"""
accDF = pd.DataFrame(columns={"Ligand", "Valency", "Accuracy"})
accDF = pd.DataFrame(columns=["Ligand", "Valency", "Accuracy"])
for ligand in df.Ligand.unique():
for val in df.loc[df.Ligand == ligand].Valency.unique():
preds = df.loc[(df.Ligand == ligand) & (df.Valency == val)].Predicted.values
Expand All @@ -100,7 +99,7 @@ def R2_Plot_Ligs(ax, df):

def R2_Plot_Conc(ax, df):
"""Plots all accuracies per concentration"""
accDF = pd.DataFrame(columns={"Concentration", "Valency", "Accuracy"})
accDF = pd.DataFrame(columns=["Concentration", "Valency", "Accuracy"])
for conc in df.Dose.unique():
for val in df.loc[(df.Dose == conc)].Valency.unique():
preds = df.loc[(df.Dose == conc) & (df.Valency == val)].Predicted.values
Expand Down Expand Up @@ -148,7 +147,7 @@ def MonVsBivalent(ax, dfAll, ligs=True):
df.loc[(df.Date == date) & (df.Cell == cell), "MonPredict"] = predVec * slope

if ligs:
accDF = pd.DataFrame(columns={"Ligand", "Prediction Label", "Accuracy"})
accDF = pd.DataFrame(columns=["Ligand", "Prediction Label", "Accuracy"])
for ligand in df.Ligand.unique():
BivPreds = df.loc[(df.Ligand == ligand)].Predicted.values
MonPreds = df.loc[(df.Ligand == ligand)].MonPredict.values
Expand Down Expand Up @@ -219,7 +218,7 @@ def EC50comp(ax, dfAll, time):
def timePlot(ax):
"""Plots all experimental vs. Predicted Values"""
times = [[0.5], [1.], [2.], [4.]]
accDF = pd.DataFrame(columns={"Time", "Valency", "Accuracy"})
accDF = pd.DataFrame(columns=["Time", "Valency", "Accuracy"])
for time in times:
df = runFullModel(time=time, saveDict=False)
for val in df.Valency.unique():
Expand Down
5 changes: 2 additions & 3 deletions ckine/figures/figureC5.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from .figureCommon import subplotLabel, getSetup, ligand_ratio_plot
from ..MBmodel import polyc, getKxStar, runFullModelMeyer
from ..imports import getBindDict, importReceptors
from ..flow_meyer import make_flow_df, make_flow_df_ILCs

path_here = dirname(dirname(__file__))
plt.rcParams['svg.fonttype'] = 'none'
Expand Down Expand Up @@ -91,10 +90,10 @@ def optimizeDesign(ax, targCell, offTcells, IL7=False, legend=True):
sigDF = pd.DataFrame()

if IL7:
optDF = pd.DataFrame(columns={"Valency", "Selectivity", "IL7Rα"})
optDF = pd.DataFrame(columns=["Valency", "Selectivity", "IL7Rα"])
X0 = [8] # Ka IL7
else:
optDF = pd.DataFrame(columns={"Valency", "Selectivity", "IL2Rα", r"IL-2Rβ/γ$_c$"})
optDF = pd.DataFrame(columns=["Valency", "Selectivity", "IL2Rα", r"IL-2Rβ/γ$_c$"])
if targCell[0] == "NK":
X0 = [6.0, 8] # IL2Ra, IL2Rb
else:
Expand Down
6 changes: 3 additions & 3 deletions ckine/figures/figureCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,12 @@ def hillRatioDosePlot(ax, respDF, time, targCell, offTargCell, pseudo=0.2, plot=
targIsoData = respDF.loc[(respDF.Ligand == ligand) & (respDF.Valency == valency) & (respDF.Cell == targCell)]
targXData = np.nan_to_num(np.log10(targIsoData.Dose.values)) + 4
targYData = np.nan_to_num(targIsoData.Mean.values)
targFit = least_squares(hill_residuals, x0, args=(targXData, targYData), bounds=([0.0, 0.0, 2], [5, 10.0, 6]), jac="3-point")
targFit = least_squares(hill_residuals, x0, method="dogbox", args=(targXData, targYData), bounds=([0.0, 0.0, 2], [5, 10.0, 6]), jac="3-point")

offTIsoData = respDF.loc[(respDF.Ligand == ligand) & (respDF.Valency == valency) & (respDF.Cell == offTargCell)]
offTargXData = np.nan_to_num(np.log10(offTIsoData.Dose.values)) + 4
offTargYData = np.nan_to_num(offTIsoData.Mean.values)
offTargFit = least_squares(hill_residuals, x0, args=(offTargXData, offTargYData), bounds=([0.0, 0.0, 2], [5, 10.0, 6]), jac="3-point")
offTargFit = least_squares(hill_residuals, x0, method="dogbox", args=(offTargXData, offTargYData), bounds=([0.0, 0.0, 2], [5, 10.0, 6]), jac="3-point")
hillDF = pd.concat([hillDF, pd.DataFrame({"Ligand": ligand, "Valency": valency, "Cell": targCell, "Dose": np.power(
10, doses - 4), targCell: hill_equation(targFit.x, doses), offTargCell: hill_equation(offTargFit.x, doses)})])

Expand Down Expand Up @@ -519,7 +519,7 @@ def make_EC50_DF(respDF, time, meyer=False):
targIsoData = respDF.loc[(respDF.Ligand == ligand) & (respDF.Valency == valency) & (respDF.Cell == cell)]
targXData = np.nan_to_num(np.log10(targIsoData.Dose.values)) + 4
targYData = np.nan_to_num(targIsoData.Mean.values)
targFit = least_squares(hill_residuals, x0, args=(targXData, targYData), bounds=([0.0, 0.0, 2], [5, 10.0, 6]), jac="3-point")
targFit = least_squares(hill_residuals, x0, method="dogbox", args=(targXData, targYData), bounds=([0.0, 0.0, 2], [5, 10.0, 6]), jac="3-point")
EC50_DF = pd.concat([EC50_DF, pd.DataFrame({"Cell": cell, "Ligand": ligand, "Valency": valency, "EC50": [np.power(10, targFit.x[2] - 4)]})])

EC50_DF.loc[(EC50_DF.Valency == 1), "Ligand"] = (EC50_DF.loc[(EC50_DF.Valency == 1)].Ligand + " (Mono)").values
Expand Down
1 change: 0 additions & 1 deletion ckine/figures/figureS2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import least_squares
from os.path import join
from copy import copy
from .figureCommon import subplotLabel, getSetup, getLigDict, get_cellTypeDict, hillRatioDosePlot
Expand Down
6 changes: 0 additions & 6 deletions ckine/figures/figureS3.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
"""

import os
import pandas as pd
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import least_squares
from os.path import join
from copy import copy
from .figureCommon import subplotLabel, getSetup, getLigDict, get_cellTypeDict, CITE_RIDGE, CITE_SVM


Expand Down
2 changes: 0 additions & 2 deletions ckine/figures/figureS8.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

import os
import pandas as pd
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import least_squares
from os.path import join
from copy import copy
from .figureCommon import subplotLabel, getSetup, getLigDict, get_cellTypeDict, make_EC50_DF
Expand Down
4 changes: 2 additions & 2 deletions ckine/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
import pandas as pd
import warnings
from FlowCytometryTools import FCMeasurement, QuadGate, ThresholdGate, PolyGate
from FlowCytometryTools import FCMeasurement, QuadGate, ThresholdGate

path_here = dirname(dirname(__file__))

Expand Down Expand Up @@ -175,7 +175,7 @@ def nllsq(x, y):
upper = np.array([1.0, 1.1, 1.0e6, 1.0e9])
x0 = (upper - lower) / 2.0 + lower

lsq = least_squares(lambda pp: exp_dec(x, pp) - y, x0, bounds=(lower, upper), jac="3-point")
lsq = least_squares(lambda pp: exp_dec(x, pp) - y, x0, method="dogbox", bounds=(lower, upper), jac="3-point")
return lsq.x


Expand Down
Loading

0 comments on commit 491a422

Please sign in to comment.