Exemplo n.º 1
0
def make_merging_stats_plots(script):
    """Make merging stats plots for HTML report"""
    d = {
        "scaling_tables": ([], []),
        "resolution_plots": {},
        "batch_plots": {},
        "misc_plots": {},
        "anom_plots": {},
        "image_range_tables": [],
    }
    (
        batches,
        rvb,
        isigivb,
        svb,
        batch_data,
    ) = reflection_tables_to_batch_dependent_properties(  # pylint: disable=unbalanced-tuple-unpacking
        script.reflections,
        script.experiments,
        script.scaled_miller_array,
    )
    bm = batch_manager(batches, batch_data)
    image_range_tables = make_image_range_table(script.experiments, bm)

    if script.merging_statistics_result:
        stats = script.merging_statistics_result
        anom_stats = script.anom_merging_statistics_result
        is_centric = script.scaled_miller_array.space_group().is_centric()
        # Now calculate batch data
        plotter = ResolutionPlotsAndStats(stats, anom_stats, is_centric)
        d["resolution_plots"].update(plotter.make_all_plots())
        d["scaling_tables"] = plotter.statistics_tables()
        d["batch_plots"].update(scale_rmerge_vs_batch_plot(bm, rvb, svb))
        d["batch_plots"].update(i_over_sig_i_vs_batch_plot(bm, isigivb))
        plotter = IntensityStatisticsPlots(
            script.scaled_miller_array, run_xtriage_analysis=False
        )
        d["resolution_plots"].update(plotter.generate_resolution_dependent_plots())
        if d["resolution_plots"]["cc_one_half"]["data"][2]:
            cc_anom = d["resolution_plots"]["cc_one_half"]["data"][2]["y"]
            significance = d["resolution_plots"]["cc_one_half"]["data"][3]["y"]
            sig = flex.double(cc_anom) > flex.double(significance)
            max_anom = 0
            for i, v in enumerate(sig):
                if v:
                    max_anom = i
                else:
                    break
            d_min = uctbx.d_star_sq_as_d(plotter.binner.limits())[max_anom + 1]
        else:
            d_min = 0.0
        d["misc_plots"].update(plotter.generate_miscellanous_plots())
        intensities_anom = script.scaled_miller_array.as_anomalous_array()
        intensities_anom = intensities_anom.map_to_asu().customized_copy(
            info=script.scaled_miller_array.info()
        )
        anom_plotter = AnomalousPlotter(intensities_anom, strong_cutoff=d_min)
        d["anom_plots"].update(anom_plotter.make_plots())
    d["image_range_tables"] = [image_range_tables]
    return d
Exemplo n.º 2
0
 def make_plots(self):
     """Generate tables of overall and resolution-binned merging statistics."""
     d = {
         "scaling_tables": ([], []),
         "resolution_plots": OrderedDict(),
         "batch_plots": OrderedDict(),
         "misc_plots": OrderedDict(),
         "anom_plots": OrderedDict(),
         "image_range_tables": [],
     }
     if "statistics" in self.data:
         plotter = ResolutionPlotsAndStats(
             self.data["statistics"],
             self.data["anomalous_statistics"],
             is_centric=self.data["is_centric"],
         )
         d["resolution_plots"].update(plotter.make_all_plots())
         d["scaling_tables"] = plotter.statistics_tables()
         d["batch_plots"].update(
             scale_rmerge_vs_batch_plot(
                 self.data["bm"],
                 self.data["r_merge_vs_batch"],
                 self.data["scale_vs_batch"],
             ))
         d["batch_plots"].update(
             i_over_sig_i_vs_batch_plot(self.data["bm"],
                                        self.data["isigivsbatch"]))
         plotter = IntensityStatisticsPlots(
             self.data["scaled_miller_array"], run_xtriage_analysis=False)
         d["resolution_plots"].update(
             plotter.generate_resolution_dependent_plots())
         if d["resolution_plots"]["cc_one_half"]["data"][2]:
             cc_anom = d["resolution_plots"]["cc_one_half"]["data"][2]["y"]
             significance = d["resolution_plots"]["cc_one_half"]["data"][3][
                 "y"]
             sig = flex.double(cc_anom) > flex.double(significance)
             max_anom = 0
             for i, v in enumerate(sig):
                 if v:
                     max_anom = i
                 else:
                     break
             d_min = uctbx.d_star_sq_as_d(
                 plotter.binner.limits())[max_anom + 1]
         else:
             d_min = 0.0
         d["misc_plots"].update(plotter.generate_miscellanous_plots())
         intensities_anom = self.data[
             "scaled_miller_array"].as_anomalous_array()
         intensities_anom = intensities_anom.map_to_asu().customized_copy(
             info=self.data["scaled_miller_array"].info())
         anom_plotter = AnomalousPlotter(intensities_anom,
                                         strong_cutoff=d_min)
         d["anom_plots"].update(anom_plotter.make_plots())
         d["image_range_tables"] = self.data["image_range_tables"]
     return d
Exemplo n.º 3
0
def test_AnomalousPlotter():

    "Make a larger array to allow all plots to be made"
    cs = crystal.symmetry(space_group_symbol="P1", unit_cell=(6, 6, 6, 90, 90, 90))
    ms = miller.build_set(cs, anomalous_flag=True, d_min=1.0)
    indices = ms.indices()
    new_indices = flex.miller_index(list(indices) * 10)
    new_ms = miller.set(crystal_symmetry=cs, indices=new_indices, anomalous_flag=True)
    data = flex.double(float(random.randrange(1, 100)) for _ in range(new_ms.size()))
    iobs = miller.array(new_ms, data, sigmas=data)
    iobs.change_symmetry(space_group_symbol="P222", merge_non_unique=False)
    iobs.set_info(miller.array_info(source="DIALS", source_type="reflection_tables"))
    iobs.set_observation_type_xray_intensity()

    plotter = AnomalousPlotter(iobs)
    d = plotter.make_plots()
    expected = ["normal_distribution_plot_highres", "anom_correl_plot"]
    keys = d.keys()
    for k in expected:
        assert k in keys
        assert d[k]["data"][0]["x"]  # check some data there

    plotter = AnomalousPlotter(iobs, strong_cutoff=3.0)
    d = plotter.make_plots()
    expected = [
        "anom_correl_plot",
        "anom_scatter_plot_lowres",
        "normal_distribution_plot_lowres",
    ]
    keys = list(d.keys())
    for k in expected:
        assert k in keys
        assert d[k]["data"][0]["x"]  # check some data there