Exemplo n.º 1
0
    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
Exemplo n.º 2
0
def test_plot_uc_histograms():
    sgi = sgtbx.space_group_info("P1")
    unit_cells = [
        sgi.any_compatible_unit_cell(
            volume=random.uniform(990, 1010)).parameters() for i in range(10)
    ]
    uc_params = [flex.double(a) for a in zip(*unit_cells)]
    d = plots.plot_uc_histograms(uc_params)
    assert set(d) == {"uc_scatter", "uc_hist"}
    assert len(d["uc_scatter"]["data"]) == 3
    assert len(d["uc_hist"]["data"]) == 3
Exemplo n.º 3
0
def make_cluster_plots(large_clusters: List[Cluster]) -> dict:
    cluster_plots = {}
    for n, cluster in enumerate(large_clusters):
        uc_params = [flex.double() for i in range(6)]
        for c in cluster.members:
            ucp = c.crystal_symmetry.unit_cell().parameters()
            for i in range(6):
                uc_params[i].append(ucp[i])
        d_this = cluster_plotter.plot_uc_histograms(uc_params)
        d_this["uc_scatter"]["layout"]["title"] += f" cluster {n+1}"
        d_this["uc_hist"]["layout"]["title"] += f" cluster {n+1}"
        d_this[f"uc_scatter_{n}"] = d_this.pop("uc_scatter")
        d_this[f"uc_hist_{n}"] = d_this.pop("uc_hist")
        cluster_plots.update(d_this)
    return cluster_plots
Exemplo n.º 4
0
    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