def make_plots(self): """Generate plots of the unit cell clustering.""" uc_params = uc_params_from_experiments(self.data["experiments"]) d = plots.plot_uc_histograms(uc_params) if "dendrogram" in self.data: d["uc_clustering"] = plots.scipy_dendrogram_to_plotly_json( self.data["dendrogram"], title="Unit cell clustering", xtitle="Dataset", ytitle=r"Distance (Å<sup>2</sup>)", help="""\ The results of single-linkage hierarchical clustering on the unit cell parameters using the Andrews-Bernstein NCDist distance metric (Andrews & Bernstein, 2014). The height at which two clusters are merged in the dendrogram is a measure of the similarity between the unit cells in each cluster. A larger separation between two clusters may be indicative of a higher degree of non-isomorphism between the clusters. Conversely, a small separation between two clusters suggests that their unit cell parameters are relatively isomorphous. """, ) graphs = {"unit_cell_graphs": d} return graphs
def unit_cell_analysis(self): from dials.command_line.unit_cell_histogram import uc_params_from_experiments # from dials.command_line.unit_cell_histogram import panel_distances_from_experiments experiments = self._data_manager.experiments uc_params = uc_params_from_experiments(experiments) # panel_distances = panel_distances_from_experiments(experiments) d = OrderedDict() from xia2.Modules.MultiCrystal.plots import plot_uc_histograms d.update(plot_uc_histograms(uc_params)) # self._plot_uc_vs_detector_distance(uc_params, panel_distances, outliers, params.steps_per_angstrom) # self._plot_number_of_crystals(experiments) clustering, dendrogram = self.unit_cell_clustering( experiments, threshold=self.params.unit_cell_clustering.threshold, log=self.params.unit_cell_clustering.log, ) from dials.algorithms.clustering.plots import scipy_dendrogram_to_plotly_json d["uc_clustering"] = scipy_dendrogram_to_plotly_json( dendrogram, title="Unit cell clustering", xtitle="Dataset", ytitle="Distance (Å^2)", ) return d
def test_scipy_dendrogram_to_plotly_json(): # generate some random unit cells sgi = sgtbx.space_group_info("P1") crystal_symmetries = [ sgi.any_compatible_crystal_symmetry(volume=random.uniform(990, 1010)) for i in range(10) ] lattice_ids = flex.int_range(0, len(crystal_symmetries)).as_string() ucs = UnitCellCluster.from_crystal_symmetries(crystal_symmetries, lattice_ids=lattice_ids) _, dendrogram, _ = ucs.ab_cluster(write_file_lists=False, doplot=False) d = plots.scipy_dendrogram_to_plotly_json(dendrogram, title="Unit cell clustering") assert set(d) == {"layout", "data"}
def unit_cell_analysis(self): from dials.command_line.unit_cell_histogram import uc_params_from_experiments # from dials.command_line.unit_cell_histogram import panel_distances_from_experiments experiments = self._data_manager.experiments lattice_ids = [ self._data_manager.identifiers_to_ids_map[i] for i in experiments.identifiers() ] uc_params = uc_params_from_experiments(experiments) # panel_distances = panel_distances_from_experiments(experiments) d = OrderedDict() from xia2.Modules.MultiCrystal.plots import plot_uc_histograms d.update(plot_uc_histograms(uc_params)) # self._plot_uc_vs_detector_distance(uc_params, panel_distances, outliers, params.steps_per_angstrom) # self._plot_number_of_crystals(experiments) clustering, dendrogram = self.unit_cell_clustering( experiments, lattice_ids, threshold=self.params.unit_cell_clustering.threshold, log=self.params.unit_cell_clustering.log, ) from dials.algorithms.clustering.plots import scipy_dendrogram_to_plotly_json d["uc_clustering"] = scipy_dendrogram_to_plotly_json( dendrogram, title="Unit cell clustering", xtitle="Dataset", ytitle="Distance (Å<sup>2</sup>)", help="""\ The results of single-linkage hierarchical clustering on the unit cell parameters using the Andrews–Bernstein NCDist distance metric (Andrews & Bernstein, 2014). The height at which two clusters are merged in the dendrogram is a measure of the similarity between the unit cells in each cluster. A larger separation between two clusters may be indicative of a higher degree of non-isomorphism between the clusters. Conversely, a small separation between two clusters suggests that their unit cell parameters are relatively isomorphous. """, ) return d
def make_plots(self): """Generate plots of the unit cell clustering.""" d = OrderedDict() uc_params = uc_params_from_experiments(self.data["experiments"]) d.update(plots.plot_uc_histograms(uc_params)) if "dendrogram" in self.data: d["uc_clustering"] = plots.scipy_dendrogram_to_plotly_json( self.data["dendrogram"], title="Unit cell clustering", xtitle="Dataset", ytitle=r"Distance (Å<sup>2</sup>)", ) graphs = {"unit_cell_graphs": d} return graphs