Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
186 changes: 186 additions & 0 deletions examples/article_figures/fig1_hiv_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
from vlab4mic import experiments
import matplotlib.pyplot as plt
import os
seed = 1


images, noisless, my_experiment = experiments.image_vsample(
structure="3J3Y",
probe_template="anti-p24_primary_antibody_HIV",
probe_DoL=3,
structural_integrity_small_cluster=20,
structural_integrity_large_cluster=100,
sample_dimensions=[1000,1000,100],
random_orientations=True,
structural_integrity=1,
clear_experiment=True,
number_of_particles=30,
multimodal=["Widefield", "Confocal", "AiryScan", "STED", "SMLM", "Reference"],
random_seed=seed,
run_simulation=False,
)
my_experiment.set_virtualsample_params(minimal_distance=110)
my_experiment.build(modules=["coordinate_field"])
my_experiment.update_modality(modality_name="SMLM",
pixelsize_nm=2,
psf_voxel_nm=2,
depth_of_field_nm=1000,
lateral_resolution_nm=5,
simulate_localistations=True,
lateral_precision=5,
axial_precision=5,
nlocalisations=20)
my_experiment.update_modality(modality_name="STED", depth_of_field_nm=1000, lateral_resolution_nm=30)
my_experiment.set_modality_acq(modality_name="STED", exp_time=0.001)
my_experiment.update_modality(modality_name="Reference",
pixelsize_nm=2,
psf_voxel_nm=2,
depth_of_field_nm=1000,
lateral_resolution_nm=2,
simulate_localistations=True,
lateral_precision=0.001,
axial_precision=0.001,
nlocalisations=30)
my_experiment.set_modality_acq(modality_name="Reference", exp_time=1)
my_experiment.build(modules=["imager"])
images, noiseless = my_experiment.run_simulation()
modalities = list(images.keys())
n_modalities = len(modalities)
fig = plt.figure(figsize=[40,10])

for i, name in enumerate(modalities):
ax = fig.add_subplot(1, n_modalities, i+1)
ax.imshow(images[name]["ch0"][0], cmap="grey")
ax.set_axis_off()

filename = my_experiment.date_as_string + 'vlab4mic_hiv_modalities.png'
filename2 = os.path.join(my_experiment.output_directory, filename)
fig.savefig(filename2,dpi=300, bbox_inches='tight')
plt.close()


target_colour="#01579D"
fig = plt.figure(figsize=[20,10])
ax = fig.add_subplot(1, 2, 1, projection="3d")
total = my_experiment.structure.num_assembly_atoms
fraction = 100000/total
my_experiment.structure.show_target_labels(
with_assembly_atoms=True,
axis_object=ax,
show_axis=False,
assembly_fraction = fraction,
view_init=[20,0,0],
target_size = 0,
atoms_size = 10,
atoms_alpha = 0.01,
reference_point = False,
target_plotcolour=target_colour
)
ax = fig.add_subplot(1, 2, 2, projection="3d")
total = my_experiment.structure.num_assembly_atoms
fraction = 100000/total
my_experiment.structure.show_target_labels(
with_assembly_atoms=True,
axis_object=ax,
show_axis=False,
assembly_fraction = fraction,
view_init=[20,0,0],
target_size = 15,
atoms_size = 10,
atoms_alpha = 0.01,
reference_point = False,
target_plotcolour=target_colour
)
probe_template = list(my_experiment.probe_parameters.keys())[0]
title = "Structure: 3J3Y \n Probe: " + probe_template
title = title + "\n" + "Sequence: " + my_experiment.probe_parameters[probe_template]["target"]["value"]
ax.set_title(title)
filename = my_experiment.date_as_string + 'vlab4mic_hiv_structure_epitopes.png'
filename2 = os.path.join(my_experiment.output_directory, filename)
fig.savefig(filename2,dpi=300, bbox_inches='tight')
plt.close()


fig = plt.figure(figsize=[5,5])
ax = fig.add_subplot(1, 1, 1, projection="3d")
my_experiment.particle.show_probe(
plotcolour="#984ea3", axesoff=True,
with_structural_atoms=True,
emitter_plotsize=70,
atoms_plotalpha=0.05,
atoms_plotsize=10,
atoms_fraction=0.3,
view_init=[0,40,100],
central_axis=False,
use_dol=True,
axis_object = ax,
)

filename = my_experiment.date_as_string + 'vlab4mic_hiv_antibody.png'
filename2 = os.path.join(my_experiment.output_directory, filename)
fig.savefig(filename2,dpi=300, bbox_inches='tight')
plt.close()


target_colour="#01579D"
plotmarker="o"
emitter_plotmarker = "o"
hiv_antibody=dict(
source_plotsize=3,
emitter_plotsize=50,
source_plotcolour=target_colour,
source_plotalpha=1,
source_plotmarker=plotmarker,
emitter_plotmarker=emitter_plotmarker
)
fig = plt.figure(figsize=[10,10])
ax = fig.add_subplot(1, 1, 1, projection="3d")
my_experiment.particle.gen_axis_plot(
reference_point=False,
view_init=[20, 0, 0],
axesoff=True,
show_axis=False,
with_sources=True,
axis_object=ax,
with_normals=False,
**hiv_antibody)
filename = my_experiment.date_as_string + 'vlab4mic_hiv_labelled_particle.png'
filename2 = os.path.join(my_experiment.output_directory, filename)
fig.savefig(filename2,dpi=300, bbox_inches='tight')
plt.close()

n_examples = 8
fig = plt.figure(figsize=[20, 10])
row=2
my_experiment.set_structural_integrity(
structural_integrity=1,
structural_integrity_small_cluster=20,
structural_integrity_large_cluster=100,
)
my_experiment.build(modules=["particle",])
for i in range(n_examples):
ax = fig.add_subplot(row, int(n_examples/2), i+1, projection="3d")
if i == 4:
my_experiment.set_structural_integrity(
structural_integrity=0.5
)
my_experiment.build(modules=["particle",])

my_experiment.particle.generate_instance()
my_experiment.particle.gen_axis_plot(
reference_point=False,
view_init=[20, 0, 0],
axesoff=True,
show_axis=False,
with_sources=True,
axis_object=ax,
with_normals=False,
source_plotsize=1,
source_plotalpha=0.4,
emitter_plotsize=5,
)

filename = my_experiment.date_as_string + 'vlab4mic_hiv_labelled_particle_examples.png'
filename2 = os.path.join(my_experiment.output_directory, filename)
fig.savefig(filename2,dpi=300, bbox_inches='tight')
plt.close()
42 changes: 26 additions & 16 deletions examples/article_figures/fig2_EF.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import os
import numpy as np
from vlab4mic.analysis.metrics import zoom_img
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar
np.random.seed(44)
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar

random_seed = 24
modalities = ["STED", "SMLM",]
target_colour="#01579D"

Expand All @@ -18,8 +18,10 @@
probe_template = "GFP_w_nanobody",
probe_target_type = "Sequence",
probe_target_value = "ELAVGSL",
probe_DoL = 2,
multimodal=modalities,
clear_experiment=True
clear_experiment=True,
random_seed=random_seed
)
############ T4 capsid head
image_outputs2, image_outputs_noiseless2, experiment2 = image_vsample(
Expand All @@ -29,14 +31,19 @@
multimodal=modalities,
random_orientations=True,
yz_orientations=[90,],
clear_experiment=True
clear_experiment=True,
random_seed=random_seed
)
############ HIV-capsid
image_outputs3, image_outputs_noiseless3, experiment3 = image_vsample(
structure = "3J3Y",
probe_template = "anti-p24_primary_antibody_HIV",
probe_template = "Antibody",
probe_target_type = "Sequence",
probe_target_value = "SPRTLNA",
probe_DoL = 6,
multimodal=modalities,
clear_experiment=True
clear_experiment=True,
random_seed=random_seed
)
############ Clathrin coated pit, primary and secodnary labelling

Expand All @@ -50,15 +57,17 @@
probe_template = "Antibody",
probe_name="Secondary-clathrin",
probe_target_type = "Primary",
probe_target_value = "Primary-clathrin"
probe_target_value = "Primary-clathrin",
probe_DoL = 1.5
)
image_outputs4, image_outputs_noiseless4, experiment4 = image_vsample(
structure = "1XI5",
primary_probe = primary,
secondary_probe = secondary,
multimodal=modalities,
clear_experiment=True,
run_simulation=True
run_simulation=True,
random_seed=random_seed
)


Expand All @@ -71,17 +80,17 @@
#ax_general = fig.add_subplot(111, projection="3d")
hide_axes=True
experiment1.particle.transform_translate(np.array([0,0,0]))
experiment1.particle.gen_axis_plot(axesoff=hide_axes, with_sources=True, axis_object=ax_general,target_colour=target_colour, source_plotsize=5, emitter_plotsize=5)
experiment1.particle.gen_axis_plot(axesoff=hide_axes, with_sources=True, axis_object=ax_general,target_colour=target_colour, source_plotsize=5, emitter_plotsize=5, source_plotmarker="o")

experiment4.particle.transform_translate(np.array([0,1400,0]))
experiment4.particle.gen_axis_plot(axesoff=hide_axes,with_sources=True, axis_object=ax_general,target_colour=target_colour, source_plotsize=2, emitter_plotsize=0.5, source_plotalpha=1)
experiment4.particle.gen_axis_plot(axesoff=hide_axes,with_sources=True, axis_object=ax_general,target_colour=target_colour, source_plotsize=2, emitter_plotsize=0.5, source_plotalpha=1, source_plotmarker="o")

experiment2.particle.transform_translate(np.array([0,2600,0]))

experiment2.particle.gen_axis_plot(axesoff=hide_axes, with_sources=True, axis_object=ax_general,target_colour=target_colour, source_plotsize=0.5, emitter_plotsize=10, source_plotalpha=0.05)
experiment2.particle.gen_axis_plot(axesoff=hide_axes, with_sources=True, axis_object=ax_general,target_colour=target_colour, source_plotsize=0.5, emitter_plotsize=10, source_plotalpha=0.05, source_plotmarker="o")

experiment3.particle.transform_translate(np.array([0,3800,0]))
experiment3.particle.gen_axis_plot(axesoff=hide_axes, with_sources=True, axis_object=ax_general,target_colour=target_colour, source_plotsize=1, emitter_plotsize=0.5, source_plotalpha=1)
experiment3.particle.gen_axis_plot(axesoff=hide_axes, with_sources=True, axis_object=ax_general,target_colour=target_colour, source_plotsize=1, emitter_plotsize=0.5, source_plotalpha=1, source_plotmarker="o")
ax_general.set_zlim3d(bottom=-300, top=1000)
ax_general.set_ylim3d(bottom=-500, top=4500)
ax_general.set_xlim3d(left=0, right=1000)
Expand All @@ -98,10 +107,10 @@
y0,y1 = figy*0.64, figy*0.82

bbox = Bbox([[x0,y0],[x1,y1]])
filename1 = os.path.join(experiment1.output_directory, 'vlab4mic_fig2_E.png')

#bbox = bbox.transformed(ax_general.transData).transformed(fig.dpi_scale_trans.inverted())
filename_ = experiment1.date_as_string + 'vlab4mic_fig2_E.png'
filename1 = os.path.join(experiment1.output_directory, filename_)
fig.savefig(filename1, dpi=300, bbox_inches=bbox)

fig = plt.figure(figsize=[figy,figx])
ax = fig.add_subplot(141)
img_zoom = 0.6
Expand Down Expand Up @@ -142,5 +151,6 @@
y0,y1 = figy*0.6, figy*0.89

bbox = Bbox([[x0,y0],[x1,y1]])
filename2 = os.path.join(experiment1.output_directory, 'vlab4mic_fig2_F.png')
filename = experiment1.date_as_string + 'vlab4mic_fig2_F.png'
filename2 = os.path.join(experiment1.output_directory, filename)
fig.savefig(filename2,dpi=300, bbox_inches=bbox)
4 changes: 2 additions & 2 deletions examples/article_figures/fig3F.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def render_from_localisations(localisations, crop_size_nm = 3000, centerx = None
axs[0,0].set_ylabel("Thevathasan, et al. 2019", fontsize=24)
axs[1,0].set_ylabel("VLab4Mic simulation", fontsize=24)
plt.tight_layout(h_pad=0, w_pad=3)

filename = os.path.join(my_experiment.output_directory, 'vlab4mic_fig3F_url.png')
name = my_experiment.date_as_string + 'vlab4mic_fig3F_url.png'
filename = os.path.join(my_experiment.output_directory, name)
fig.savefig(filename, dpi=300, bbox_inches='tight')
plt.close()
Loading
Loading