Skip to content

Commit

Permalink
update to heatmap
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Aug 2, 2024
1 parent ba52deb commit 8256859
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 10,957 deletions.
34 changes: 31 additions & 3 deletions bio_check/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def get_verify_output(self, job_id: str) -> Union[Dict[str, Union[str, Dict]], R
except Exception as e:
return RequestError(error=str(e))

def visualize(
def visualize_outputs(
self,
data: dict,
simulators: list[str],
Expand Down Expand Up @@ -251,13 +251,40 @@ def visualize(

return fig

def visualize_comparison(self, data: dict, simulators: list[str], comparison_type: str = 'proximity'):
# grid plot params
species_data_content = data['content']['results']['results']
species_names = list(species_data_content.keys())
num_species = len(species_names)

fig, axes = plt.subplots(nrows=num_species, ncols=3, figsize=(20, 6 * num_species))

if num_species == 1:
axes = [axes]

for i, species_name in enumerate(species_names):
for j, simulator_name in enumerate(simulators):
ax = axes[i][j]
species_data = data['content']['results']['results'][species_name]
comparison_data = np.array(list(species_data[comparison_type].values()))
print(comparison_data.shape)
# sns.heatmap(ax=ax, data=comparison_data, label=f"Comparison matrix for {species_names}")
# ax.set_title(f"{species_name} simulation outputs for {simulator_name}")
# ax.legend()

# TODO: adjust this
plt.tight_layout()
plt.show()

return fig

def save_plot(self, fig: Figure, save_dest: str) -> None:
with PdfPages(save_dest) as pdf:
pdf.savefig(fig)

return plt.close(fig)

def export_csv(self, data: dict, save_dest: str):
def export_csv(self, data: dict, save_dest: str, simulators: list[str]):
species_data_content = data['content']['results']['results']
species_names = list(species_data_content.keys())
# TODO: Finish this here: one df where rows are num points and cols are each observable: one for each simulator for each species name. Flattened.
Expand Down Expand Up @@ -292,9 +319,10 @@ def _test_root(self) -> dict:
except RequestException as e:
return {'bio-check-error': f"A connection to that endpoint could not be established: {e}"}


# tests

def test_service():
def test_verifier():
# TODO: replace this
verifier = Verifier()
simulators = ['copasi', 'tellurium']
Expand Down
Loading

0 comments on commit 8256859

Please sign in to comment.