Skip to content

Commit

Permalink
add comments, changes
Browse files Browse the repository at this point in the history
  • Loading branch information
armaan-abraham committed May 30, 2024
1 parent 214d975 commit be0d2f2
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,5 @@ dmypy.json

.vscode
output

.DS_Store
2 changes: 0 additions & 2 deletions bicytok/MBmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ def cytBindingModel(
Return:
output: amount of receptor bound of each kind of receptor
"""
print(recCount)
print()
Kx = getKxStar()
ligandConc = dose / (vals[0][0] * 1e9)

Expand Down
10 changes: 10 additions & 0 deletions bicytok/figures/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
matplotlib.rcParams["legend.borderpad"] = 0.35


# Armaan: When declaring constants at the top of a file, it is good practice to
# choose a descriptive name, use ALL CAPS (e.g. DOSE_MAT), and possibly add a
# brief comment. Also, this particular variable isn't used anywhere.
dosemat = np.array(
[
84,
Expand Down Expand Up @@ -90,6 +93,10 @@ def genFigure():

exec("from bicytok.figures." + nameOut + " import makeFigure", globals())
ff = makeFigure() # noqa: F821

# Armaan: add function argument here to toggle the commented code if it's
# needed else delete the comment.

# for non cluster maps:
# ff.savefig(fdir + nameOut + ".svg", dpi=ff.dpi, bbox_inches="tight", pad_inches=0)
# for cluster maps:
Expand All @@ -98,6 +105,7 @@ def genFigure():
print(f"Figure {sys.argv[1]} is done after {time.time() - start} seconds.\n")


# Armaan: resolve this (delete the function or the comment)
# NOTE: CHECK IF WE NEED THIS
def subplotLabel(axs: list[Axes]):
"""Place subplot labels on figure."""
Expand All @@ -119,9 +127,11 @@ def subplotLabel(axs: list[Axes]):
"CD8": (6200, 7500),
"NK": (4000, 5000),
}
# Armaan: Unused variable
ratioSTATlimDict = {"Treg/NK": (0, 4000), "Treg/CD8": (0, 1500)}


# Armaan: resolve this
# NOTE: CHECK IF WE NEED THIS
def plotBispecific(ax: Axes, df, cellType: str, val=False):
"""Plots all experimental vs. Predicted Values"""
Expand Down
3 changes: 0 additions & 3 deletions bicytok/figures/figure1.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def makeFigure():
df = pd.DataFrame(columns=["Dose", "Selectivity", "Target Bound", "Ligand"])

for targetPairs in allTargets:
print(targetPairs)
prevOptAffs = [8.0]
valencies = [signal[1]]
targets = []
Expand Down Expand Up @@ -105,8 +104,6 @@ def makeFigure():
)
df = pd.concat([df, df_temp], ignore_index=True)

print(df)

sns.lineplot(data=df, x="Dose", y="Selectivity", hue="Ligand", ax=ax[0])
sns.lineplot(data=df, x="Dose", y="Target Bound", hue="Ligand", ax=ax[1])
ax[0].set(xscale="log")
Expand Down
26 changes: 26 additions & 0 deletions bicytok/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
path_here = os.path.dirname(os.path.dirname(__file__))


# Armaan: don't use lru_cache if function returns mutable value. See my
# explanation here: https://github.com/meyer-lab/tensordata/pull/26.
# Will you be calling this function multiple times throughout a single program?
# I would just recommend calling it once, and then using `deepcopy` to create
# copies which you can change if you need to. You may consider passing the data
# as a function argument if this is called in separate spots throughout the
# codebase.
@lru_cache(maxsize=None)
def getBindDict():
"""Gets binding to pSTAT fluorescent conversion dictionary"""
Expand All @@ -23,9 +30,25 @@ def getBindDict():
return bindingDF


# Armaan: lru_cache mutable return value
@lru_cache(maxsize=None)
def importReceptors():
"""Makes Complete receptor expression Dict"""
# Armaan: it is bad practice to hard-code path separators into strings,
# because path separators differ by OS. Instead use os.path.join or, even
# better, use pathlib.Path. I would highly recommend replacing all uses of
# os.path.join with the pathlib.Path equivalent. This is also gradually
# becoming standard practice.
"""
# Usage of pathlib.Path:
from pathlib import Path
THIS_DIR = Path(__file__).parent
recDF = THIS_DIR / "bicytok" / "data" / "RecQuantitation.csv" # You can use
slashes outside of the string, as the pathlib.Path object has overloaded the
`/` operator to automatically generate the correct path separator.
"""
recDF = pd.read_csv(join(path_here, "bicytok/data/RecQuantitation.csv"))
recDFbin = pd.read_csv(join(path_here, "bicytok/data/BinnedReceptorData.csv"))
recDFbin = recDFbin.loc[recDFbin["Bin"].isin([1, 3])]
Expand All @@ -35,6 +58,7 @@ def importReceptors():
return recDF


# Armaan: lru_cache mutable return value
@lru_cache(maxsize=None)
def makeCITEdf():
"""Makes cite surface epitope csv for given cell type, DON'T USE THIS UNLESS DATA NEEDS RESTRUCTURING"""
Expand Down Expand Up @@ -154,6 +178,8 @@ def makeTregSC():
return


# Armaan: Move this to the top of the file (and add a brief comment) or into
# the function `makeTregSC`.
SC_Stims = [
"control",
"IL2_100pM",
Expand Down
2 changes: 0 additions & 2 deletions bicytok/selectivityFuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def optimizeDesign(
targRecs, offTRecs = get_rec_vecs(
selectedDF, targCell, offTCells, signal, targets, cellCat
)
print("Optimize")
optimized = minimize(
minSelecFunc,
X0,
Expand All @@ -140,7 +139,6 @@ def optimizeDesign(
),
jac="3-point",
)
print("Done")
optSelectivity = optimized.fun
optAffs = optimized.x

Expand Down
16 changes: 14 additions & 2 deletions general_comments.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
1. File naming should be consistent. The convention for python files is lower
case letters with '_' to separate words. E.g., `BindingMod.py` ->
case letters with `_` to separate words. E.g., `BindingMod.py` ->
`binding_mod.py`.
2. Sort imports with Ruff (I did this for you)
2. Sort imports with Ruff (I did this for you)
3. Run `ruff check` again with the rules I declared in `pyproject.toml`. There
are a few small issues outlined in the output.
4. When possible, use `snake_case` for variable and function naming. Officially,
the PEP8 convention specifies that variable names should only include lower case
letters, but it makes sense for us to ignore that part of the convention
sometimes, particularly when we're implementing mathematical functions which
were described in a math paper elsewhere, where uppercase variable names were
used (e.g. binding model paper uses R_eq).
5. I believe `bicytok/data/epitopeSelectivityList.csv`,
`bicytok/data/MonomericMutSingleCellData.csv`,
`bicytok/data/WTDimericMutSingleCellData.csv`, `bicytok/data/WTmutAffData.csv`
are unused.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@ select = [
"SIM",
# isort
"I",
# Unused arguments
"ARG",
]

0 comments on commit be0d2f2

Please sign in to comment.