Skip to content

Commit

Permalink
add metrics from ActinAnalyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
blairlyons committed May 3, 2022
1 parent 7fbf78f commit 57a4dfa
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 1 deletion.
77 changes: 76 additions & 1 deletion vivarium_models/processes/readdy_actin_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
from vivarium.core.control import run_library_cli

from tqdm import tqdm
from simularium_models_util.actin import ActinSimulation, ActinUtil, ActinTestData
from simularium_models_util.actin import (
ActinSimulation,
ActinUtil,
ActinTestData,
ActinAnalyzer,
)
from simularium_models_util import ReaddyUtil
from vivarium_models.util import create_monomer_update
from vivarium_models.util import create_monomer_update, format_monomer_results
from vivarium_models.library.scan import Scan

NAME = "ReaDDy_actin"
Expand Down Expand Up @@ -318,10 +324,79 @@ def filament_lengths(results):
length = np.linalg.norm(difference)
return length

def percent_filamentous_actin(results):
monomer_data = [list(results.values())[-1]["monomers"]]
return (
100.0
* ActinAnalyzer.analyze_ratio_of_filamentous_to_total_actin(monomer_data)[0]
)

def percent_bound_arp23(results):
monomer_data = [list(results.values())[-1]["monomers"]]
return (
100.0 * ActinAnalyzer.analyze_ratio_of_bound_to_total_arp23(monomer_data)[0]
)

def percent_daughter_actin(results):
monomer_data = [list(results.values())[-1]["monomers"]]
return (
100.0
* ActinAnalyzer.analyze_ratio_of_daughter_to_total_actin(monomer_data)[0]
)

def mother_filament_lengths(results):
monomer_data = [list(results.values())[-1]["monomers"]]
return ActinAnalyzer.analyze_average_over_time(
ActinAnalyzer.analyze_mother_filament_lengths(monomer_data)
)[0]

def daughter_filament_lengths(results):
monomer_data = [list(results.values())[-1]["monomers"]]
return ActinAnalyzer.analyze_daughter_filament_lengths(monomer_data)[0]

def branch_angles(results):
box_size = list(results.values())[-1]["monomers"]["box_size"]
monomer_data = [list(results.values())[-1]["monomers"]]
periodic_boundary = False # TODO get from parameters
return ActinAnalyzer.analyze_branch_angles(
monomer_data, box_size, periodic_boundary
)[0]

def short_helix_pitches(results):
monomer_data = format_monomer_results(results)
periodic_boundary = False # TODO get from parameters
return ActinAnalyzer.analyze_short_helix_pitches(
monomer_data, monomer_data[0]["box_size"], periodic_boundary
)

def long_helix_pitches(results):
monomer_data = format_monomer_results(results)
periodic_boundary = False # TODO get from parameters
return ActinAnalyzer.analyze_long_helix_pitches(
monomer_data, monomer_data[0]["box_size"], periodic_boundary
)

def filament_straightness(results):
monomer_data = format_monomer_results(results)
periodic_boundary = False # TODO get from parameters
return ActinAnalyzer.analyze_filament_straightness(
monomer_data, monomer_data[0]["box_size"], periodic_boundary
)

metrics = {
'count_monomers': count_monomers,
'count_monomer_types': count_monomer_types,
'filament_lengths': filament_lengths}
"percent_filamentous_actin": percent_filamentous_actin,
"percent_bound_arp23": percent_bound_arp23,
"percent_daughter_actin": percent_daughter_actin,
"mother_filament_lengths": mother_filament_lengths,
"daughter_filament_lengths": daughter_filament_lengths,
"branch_angles": branch_angles,
"short_helix_pitches": short_helix_pitches,
"long_helix_pitches": long_helix_pitches,
"filament_straightness": filament_straightness,
}

scan = Scan(
parameters,
Expand Down
24 changes: 24 additions & 0 deletions vivarium_models/util.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import numpy as np


def agents_update(existing, projected):
update = {"_add": [], "_delete": []}

Expand Down Expand Up @@ -26,3 +29,24 @@ def create_monomer_update(previous_monomers, new_monomers):
return {
"monomers": {"topologies": topologies_update, "particles": particles_update}
}


def format_monomer_results(results):
"""
Workaround since numpy arrays are not preserved in Vivarium?
"""
monomer_data = list(results.values())[-1]["monomers"]
formatted_results = {
"box_center": monomer_data["box_center"],
"box_size": monomer_data["box_size"],
"topologies": monomer_data["topologies"],
"particles": {},
}
for particle_id in monomer_data["particles"]:
particle = monomer_data["particles"][particle_id]
formatted_results["particles"][particle_id] = {
"type_name": particle["type_name"],
"position": np.array(particle["position"]),
"neighbor_ids": particle["neighbor_ids"],
}
return [formatted_results]

0 comments on commit 57a4dfa

Please sign in to comment.