Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize #15

Merged
merged 52 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
6664e2e
make dir
eagmon Sep 4, 2023
babcca8
optimization by removing unit operations
eagmon Sep 4, 2023
d28133e
minor refactor of tumor, still using units in next_update
eagmon Sep 4, 2023
1c6396f
minor optimization of diffuse
eagmon Sep 5, 2023
2868413
Editing analysis with new data structure and tumor death options for …
Sep 5, 2023
c8cd3ac
v0.0.30
Sep 5, 2023
100d32e
allow non-master branch to push to pypi
Sep 5, 2023
ecea7a7
v0.0.30
Sep 5, 2023
2a0b693
Additional edits to analysis scripts and trying out slightly larger t…
Sep 5, 2023
8ff25c2
v0.0.31
Sep 5, 2023
2052db2
removed need for saving data within experiment and also changing addi…
Sep 5, 2023
d01b979
v0.0.32
Sep 5, 2023
bb7f70c
additional improvements to handle exceptions for analysis
Sep 6, 2023
c25732c
v0.0.33
Sep 6, 2023
b9e8e29
additional handling of empty death dictionaries
Sep 6, 2023
a16cd02
v0.0.34
Sep 6, 2023
74755f3
Change back parameters to expected values to look at long term behavior
Sep 6, 2023
29ac3e0
v0.0.35
Sep 6, 2023
7827361
set initial in_transit t-cells state to PD1n
eagmon Sep 7, 2023
2c6ee6b
troubleshoot T cells division in LN
Sep 7, 2023
4c62786
v0.0.36
Sep 7, 2023
c587b10
get in_transit tcell initialized correctly
eagmon Sep 7, 2023
3252ae8
optimize tumor process by refactoring units to the constructor
eagmon Sep 7, 2023
3ec99ab
v0.0.37
Sep 7, 2023
c1974ec
remove division from lymph node and bring into T cell process
Sep 11, 2023
5154d97
v0.0.38
Sep 11, 2023
bd51d6f
changed simulation conditions back to normal timescale for longer sim…
Sep 12, 2023
8b8076b
v0.0.39
Sep 12, 2023
0a9aa3a
change DC migration assuming there are a subset of already activated …
Sep 13, 2023
f90766e
v0.0.40
Sep 13, 2023
5272367
Made changes to main and also analysis based on if we are not using a…
Sep 15, 2023
ad5ce1b
v0.0.41
Sep 15, 2023
2f3c038
Found error with T cell division of PD1n cells and put back correct D…
Sep 18, 2023
ea46d6f
v0.0.42
Sep 18, 2023
24ed29c
Force T cells to enter the tumor instead of the outside from the lymp…
Sep 20, 2023
f0e2c7b
v0.0.43
Sep 20, 2023
dcf2cbd
get the timestep through to dendritic process
eagmon Sep 22, 2023
c92da19
v0.0.44
Sep 22, 2023
ee4439e
fixing IFNg internalization rate post changes with removing IFNg dime…
Sep 29, 2023
9fe4230
v0.0.46
Sep 29, 2023
de02874
tumor_tcell_model notebook working again
eagmon Oct 15, 2023
daf1f40
begin work on diagrams
eagmon Oct 15, 2023
208a109
minor code cleanup
eagmon Oct 15, 2023
2e92f91
clean up cell process files
eagmon Oct 16, 2023
e572c82
clean up
eagmon Oct 16, 2023
bc498ba
get no LN composite in same schema, clean up, working on diagram
eagmon Oct 17, 2023
d6ff47b
fix tumor microenvironment test to new schema
eagmon Oct 17, 2023
c2c1c45
rename TumorCellProcess
eagmon Oct 17, 2023
d6ada84
diagrams notebook with individual processes
eagmon Oct 17, 2023
d4cbe88
more process figs
eagmon Oct 17, 2023
4071e59
add individual cell schemas in diagram
eagmon Oct 17, 2023
5306818
tumor environment diagram
eagmon Oct 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ venv/
.python-version
__pycache__/
dist/
.ipynb_checkpoints/*
1,713 changes: 1,713 additions & 0 deletions jupyter_notebooks/diagrams.ipynb

Large diffs are not rendered by default.

264 changes: 111 additions & 153 deletions jupyter_notebooks/tumor_tcell_model.ipynb

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ if [ ! -z "$(git status --untracked-files=no --porcelain)" ]; then
exit 1
fi

# Check that we are on master
branch="$(git rev-parse --abbrev-ref HEAD)"
if [ "$branch" != "master" ]; then
echo "You are on $branch but should be on master for releases."
echo "Aborting."
exit 1
fi
## Check that we are on master
#branch="$(git rev-parse --abbrev-ref HEAD)"
#if [ "$branch" != "master" ]; then
# echo "You are on $branch but should be on master for releases."
# echo "Aborting."
# exit 1
#fi

# Create and push git tag
git tag -m "Version v$version" "v$version"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='tumor-tcell',
version='0.0.29',
version='0.0.46',
packages=[
'tumor_tcell',
'tumor_tcell.composites',
Expand Down
8 changes: 7 additions & 1 deletion tumor_tcell/composites/dendritic_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
class DendriticAgent(Composer):
name = NAME
defaults = {
'time_step': TIMESTEP,
'reuse_processes': False,
'boundary_path': ('boundary',),
'agents_path': ('..', '..', 'agents',),
Expand Down Expand Up @@ -69,6 +70,7 @@ class DendriticAgent(Composer):

def __init__(self, config):
super().__init__(config)
self.config['dendritic_cell']['time_step'] = self.config['time_step']
self.processes_initialized = False

def initialize_processes(self, config):
Expand Down Expand Up @@ -137,10 +139,13 @@ def generate_topology(self, config):
# tests
def test_dendritic_agent(
total_time=1000,
agent_ids=['0'],
agent_ids=None,
agent_timeline=None,
initial_agent_state='PD1n',
):
"""run a test on dendritic cell agents"""
if agent_ids is None:
agent_ids = ['0']
composite = Composite()
for agent_id in agent_ids:
parameters = {'agent_id': agent_id}
Expand Down Expand Up @@ -189,6 +194,7 @@ def test_dendritic_agent(


def run_agent(out_dir='out'):
"""run one agent and plot results"""
agent_ids = ['0', '1']
agent_timeline = []
data = test_dendritic_agent(
Expand Down
9 changes: 8 additions & 1 deletion tumor_tcell/composites/t_cell_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class TCellAgent(Composer):

name = NAME
defaults = {
'time_step': TIMESTEP,
'reuse_processes': False,
'boundary_path': ('boundary',),
'agents_path': ('..', '..', 'agents',),
Expand Down Expand Up @@ -77,6 +78,7 @@ class TCellAgent(Composer):

def __init__(self, config):
super().__init__(config)
self.config['tcell']['time_step'] = self.config['time_step']
self.processes_initialized = False

def initialize_processes(self, config):
Expand Down Expand Up @@ -145,10 +147,13 @@ def generate_topology(self, config):
# tests
def test_tcell_agent(
total_time=1000,
agent_ids=['0'],
agent_ids=None,
agent_timeline=None,
initial_agent_state='PD1n',
):
"""run a test on t cell agents"""
if agent_ids is None:
agent_ids = ['0']
composite = Composite()
for agent_id in agent_ids:
parameters = {
Expand Down Expand Up @@ -215,7 +220,9 @@ def test_tcell_agent(

return output


def run_agent(out_dir='out'):
"""run one agent and plot results"""
agent_ids = ['0', '1']
agent_timeline = [
(500, {
Expand Down
14 changes: 10 additions & 4 deletions tumor_tcell/composites/tumor_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from vivarium.processes.meta_division import MetaDivision
from vivarium.processes.remove import Remove
from vivarium.processes.timeline import TimelineProcess
from tumor_tcell.processes.tumor import TumorProcess, TIMESTEP
from tumor_tcell.processes.tumor import TumorCellProcess, TIMESTEP
from tumor_tcell.processes.local_field import LocalField

# directories/libraries
Expand All @@ -36,6 +36,7 @@ class TumorAgent(Composer):

name = NAME
defaults = {
'time_step': TIMESTEP,
'reuse_processes': False,
'boundary_path': ('boundary',),
'agents_path': ('..', '..', 'agents',),
Expand Down Expand Up @@ -73,14 +74,15 @@ class TumorAgent(Composer):

def __init__(self, config):
super().__init__(config)
self.config['tumor']['time_step'] = self.config['time_step']
self.processes_initialized = False

def initial_state(self, config=None):
process = TumorProcess()
process = TumorCellProcess()
return process.initial_state(config)

def initialize_processes(self, config):
self.tumor_process = TumorProcess(config['tumor'])
self.tumor_process = TumorCellProcess(config['tumor'])
self.local_field = LocalField()

if self.config['reuse_processes']:
Expand Down Expand Up @@ -145,10 +147,13 @@ def generate_topology(self, config):
# tests
def test_tumor_agent(
total_time=1000,
agent_ids=['0'],
agent_ids=None,
agent_timeline=None,
initial_agent_state='PDL1n',
):
"""run a test on tumor agents"""
if agent_ids is None:
agent_ids = ['0']
composite = Composite()
for agent_id in agent_ids:
parameters = {
Expand Down Expand Up @@ -215,6 +220,7 @@ def test_tumor_agent(


def run_agent(out_dir='out'):
"""run one agent and plot results"""
agent_ids = ['0', '1']
agent_timeline = []
data = test_tumor_agent(
Expand Down
66 changes: 51 additions & 15 deletions tumor_tcell/composites/tumor_microenvironment.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class TumorMicroEnvironment(Composer):
"""
name = NAME
defaults = {
'tumor_env_id': 'tumor_environment',
'ln_id': 'lymph_node',
'in_transit_id': 'in_transit',
'neighbors_multibody': {
'name': 'neighbors_multibody',
'bounds': DEFAULT_BOUNDS,
Expand All @@ -54,28 +57,44 @@ class TumorMicroEnvironment(Composer):
def __init__(self, config=None):
super().__init__(config)

def generate_processes(self, config):
def initial_state(self, config):
return {
config['tumor_env_id']: {},
config['ln_id']: {},
config['in_transit_id']: {},
}

def generate_processes(self, config):
# initialize processes
neighbors_multibody = Neighbors(config['neighbors_multibody'])
diffusion_field = Fields(config['diffusion_field'])

# make dictionary of processes
return {
'neighbors_multibody': neighbors_multibody,
'diffusion_field': diffusion_field,
config['tumor_env_id']: {
'neighbors_multibody': neighbors_multibody,
'diffusion_field': diffusion_field,
'agents': {},
},
config['ln_id']: {'agents': {}},
config['in_transit_id']: {'agents': {}},
}

def generate_topology(self, config):
return {
'neighbors_multibody': {
'cells': ('agents',)
},
'diffusion_field': {
'cells': ('agents',),
'fields': ('fields',),
'dimensions': ('dimensions',),
config['tumor_env_id']: {
'neighbors_multibody': {
'cells': ('agents',)
},
'diffusion_field': {
'cells': ('agents',),
'fields': ('fields',),
'dimensions': ('dimensions',),
},
'agents': {}
},
config['ln_id']: {'agents': {}},
config['in_transit_id']: {'agents': {}},
}


Expand All @@ -85,6 +104,7 @@ class TumorAndLymphNodeEnvironment(Composer):
defaults = {
'tumor_env_id': 'tumor_environment',
'ln_id': 'lymph_node',
'in_transit_id': 'in_transit',
'neighbors_multibody': {
'name': 'neighbors_multibody',
'bounds': DEFAULT_BOUNDS,
Expand All @@ -102,6 +122,13 @@ class TumorAndLymphNodeEnvironment(Composer):
def __init__(self, config=None):
super().__init__(config)

def initial_state(self, config):
return {
config['tumor_env_id']: {},
config['ln_id']: {},
config['in_transit_id']: {},
}

def generate_processes(self, config):
# initialize processes
neighbors_multibody = Neighbors(config['neighbors_multibody'])
Expand All @@ -111,9 +138,12 @@ def generate_processes(self, config):
# make dictionary of processes
return {
config['tumor_env_id']: {
'agents': {},
'neighbors_multibody': neighbors_multibody,
'diffusion_field': diffusion_field,
},
config['ln_id']: {'agents': {}},
config['in_transit_id']: {'agents': {}},
'lymph_node_transfer': lymph_node_transfer_process
}

Expand All @@ -128,7 +158,10 @@ def generate_topology(self, config):
'fields': ('fields',),
'dimensions': ('dimensions',),
},
'agents': {},
},
config['ln_id']: {'agents': {}},
config['in_transit_id']: {'agents': {}},
'lymph_node_transfer': {
'cells': (config['tumor_env_id'],),
'lymph_node': (config['ln_id'],),
Expand Down Expand Up @@ -192,6 +225,7 @@ def make_neighbors_config(

return config


def single_agent_config(config):
bounds = config.get('bounds', DEFAULT_BOUNDS)
location = config.get('location')
Expand All @@ -206,13 +240,15 @@ def single_agent_config(config):
'mass': 1339 * units.fg,
}}


def agent_body_config(config):
agent_ids = config['agent_ids']
agent_config = {
agent_id: single_agent_config(config)
for agent_id in agent_ids}
return agent_config


def test_microenvironment(
n_agents=1,
bounds=[25 * units.um, 25 * units.um],
Expand All @@ -221,7 +257,6 @@ def test_microenvironment(
diffusion=1e-1,
end_time=10
):

# configure the compartment
config = make_neighbors_config(
bounds=bounds,
Expand All @@ -235,15 +270,16 @@ def test_microenvironment(
initial_field = np.zeros((n_bins[0], n_bins[1]))
initial_field[:, -1] = 100
initial_state = {
'fields': {'IFNg': initial_field},
'agents': {}}
'tumor_environment': {
'fields': {'IFNg': initial_field},
'agents': {}}}
if n_agents:
agent_ids = [str(agent_id) for agent_id in range(n_agents)]
body_config = {'agent_ids': agent_ids}
if 'neighbors_multibody' in config and 'bounds' in config['neighbors_multibody']:
body_config.update({'bounds': config['neighbors_multibody']['bounds']})
initial_agents_state = agent_body_config(body_config)
initial_state.update({'agents': initial_agents_state})
initial_state['tumor_environment'].update({'agents': initial_agents_state})

# configure experiment
composite = compartment.generate()
Expand All @@ -256,7 +292,7 @@ def test_microenvironment(
data = experiment.emitter.get_data_deserialized()

# assert that the agent remains in the simulation until the end
assert len(data[end_time]['agents']) == n_agents
assert len(data[end_time]['tumor_environment']['agents']) == n_agents
return data


Expand Down
Loading
Loading