示例#1
0
def test_external_reference():
    experiments = fcmcmp.load_experiments(dummy_data / "external_reference.yml")

    assert experiments[0]["label"] == "sgGFP"
    assert experiments[0]["channel"] == "FITC-A"

    check_wells(experiments, before=["A1"], after=["B1"])
示例#2
0
def test_specify_both_plates():
    experiments = fcmcmp.load_experiments(dummy_data / "specify_both_plates.yml")

    assert experiments[0]["label"] == "sgNull"
    assert experiments[0]["channel"] == "FSC-A"

    check_wells(experiments, before=["p1/A1", "p2/A1"], after=["p1/B1", "p2/B1"])
示例#3
0
def test_specify_plate_1():
    experiments = fcmcmp.load_experiments(dummy_data / 'specify_plate_1.yml')

    assert experiments[0]['label'] == 'sgRFP'
    assert experiments[0]['channel'] == 'PE-Texas Red-A'

    check_wells(experiments, before=['A1'], after=['B1'])
示例#4
0
def test_specify_plate_1():
    experiments = fcmcmp.load_experiments(dummy_data / "specify_plate_1.yml")

    assert experiments[0]["label"] == "sgRFP"
    assert experiments[0]["channel"] == "PE-Texas Red-A"

    check_wells(experiments, before=["A1"], after=["B1"])
示例#5
0
def test_infer_plate_1():
    experiments = fcmcmp.load_experiments(dummy_data / 'plate_1.yml')

    assert experiments[0]['label'] == 'sgGFP'
    assert experiments[0]['channel'] == 'FITC-A'

    check_wells(experiments, before=['A1'], after=['B1'])
示例#6
0
def test_infer_plate_1():
    experiments = fcmcmp.load_experiments(dummy_data / "plate_1.yml")

    assert experiments[0]["label"] == "sgGFP"
    assert experiments[0]["channel"] == "FITC-A"

    check_wells(experiments, before=["A1"], after=["B1"])
示例#7
0
def calc_fold_changes(rebuild_cache=False):
    json_path = Path('fold_changes.json')
    fcm_path = Path('../../../data/facs/20180312_library_hits_with_tpp.yml')

    # Cache the fold changes because they take a while to calculate.

    try:
        if rebuild_cache:
            raise FileNotFoundError
        with json_path.open() as file:
            return json.load(file)

    except (FileNotFoundError, json.JSONDecodeError):
        fold_changes = {}
        experiments = fcmcmp.load_experiments(fcm_path)
        shared_steps = analysis_helpers.SharedProcessingSteps()
        shared_steps.process(experiments)
        analysis_helpers.analyze_wells(experiments)

        for pair in analysis_helpers.yield_related_wells(experiments):
            fold_change, _ = pair.calc_fold_change_with_sign()

            if fold_change < 1:
                fold_changes[pair.label] = 1/fold_change, False
            else:
                fold_changes[pair.label] = fold_change, True

        with json_path.open('w') as file:
            json.dump(fold_changes, file)

        return fold_changes
示例#8
0
def test_external_reference():
    experiments = fcmcmp.load_experiments(dummy_data /
                                          'external_reference.yml')

    assert experiments[0]['label'] == 'sgGFP'
    assert experiments[0]['channel'] == 'FITC-A'

    check_wells(experiments, before=['A1'], after=['B1'])
示例#9
0
def test_multiple_experiments():
    experiments = fcmcmp.load_experiments(dummy_data / "multiple_experiments.yml")

    assert experiments[0]["label"] == "sgGFP"
    assert experiments[0]["channel"] == "FITC-A"
    assert experiments[1]["label"] == "sgRFP"
    assert experiments[1]["channel"] == "PE-Texas Red-A"

    check_wells(experiments, before=["A1"], after=["B1"])
示例#10
0
def test_multiple_experiments():
    experiments = fcmcmp.load_experiments(dummy_data /
                                          'multiple_experiments.yml')

    assert experiments[0]['label'] == 'sgGFP'
    assert experiments[0]['channel'] == 'FITC-A'
    assert experiments[1]['label'] == 'sgRFP'
    assert experiments[1]['channel'] == 'PE-Texas Red-A'

    check_wells(experiments, before=['A1'], after=['B1'])
示例#11
0
def test_specify_both_plates():
    experiments = fcmcmp.load_experiments(dummy_data /
                                          'specify_both_plates.yml')

    assert experiments[0]['label'] == 'sgNull'
    assert experiments[0]['channel'] == 'FSC-A'

    check_wells(experiments,
                before=['p1/A1', 'p2/A1'],
                after=['p1/B1', 'p2/B1'])
示例#12
0
def test_unspecified_plate():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / 'unspecified_plate.yml')
    assert "No default plate defined" in str(exc_info.value)
示例#13
0
def test_ambiguous_well():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / 'ambiguous_well.yml')
    assert "Multiple *.fcs files found for well" in str(exc_info.value)
示例#14
0
def test_nonexistent_well():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / 'nonexistent_well.yml')
    assert "No *.fcs files found for well" in str(exc_info.value)
示例#15
0
def test_missing_wells():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / 'missing_wells.yml')
    assert "doesn't have any wells" in str(exc_info.value)
示例#16
0
def test_missing_label():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / 'missing_label.yml')
    assert "missing a label" in str(exc_info.value)
示例#17
0
def test_ambiguous_header():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / "ambiguous_header.yml")
    assert "Too many fields in 'plates' header." in str(exc_info.value)
示例#18
0
def test_missing_label():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / "missing_label.yml")
    assert "missing a label" in str(exc_info.value)
示例#19
0
def test_missing_wells():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / "missing_wells.yml")
    assert "doesn't have any wells" in str(exc_info.value)
示例#20
0
def test_empty_experiment():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / "empty_experiment.yml")
    assert "empty experiment was found" in str(exc_info.value)
示例#21
0
def test_nonexistent_well():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / "nonexistent_well.yml")
    assert "No *.fcs files found for well" in str(exc_info.value)
示例#22
0
def test_ambiguous_well():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / "ambiguous_well.yml")
    assert "Multiple *.fcs files found for well" in str(exc_info.value)
示例#23
0
def test_unspecified_plate():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / "unspecified_plate.yml")
    assert "No default plate defined" in str(exc_info.value)
示例#24
0
def test_undefined_plate():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / 'undefined_plate.yml')
    assert "Plate 'foo' not defined." in str(exc_info.value)
示例#25
0
def test_empty_file():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / 'empty_file.yml')
    assert "is empty" in str(exc_info.value)
示例#26
0
def test_ambiguous_header():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / 'ambiguous_header.yml')
    assert "Too many fields in 'plates' header." in str(exc_info.value)
示例#27
0
def test_empty_experiment():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / 'empty_experiment.yml')
    assert "empty experiment was found" in str(exc_info.value)
示例#28
0
def test_empty_file():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / "empty_file.yml")
    assert "is empty" in str(exc_info.value)
示例#29
0
def test_undefined_plate():
    with pytest.raises(fcmcmp.UsageError) as exc_info:
        fcmcmp.load_experiments(dummy_data / "undefined_plate.yml")
    assert "Plate 'foo' not defined." in str(exc_info.value)
示例#30
0
            if self.verbose:
                label = f"{experiment['label']} {condition} [{well.label}]"
                net_time = times.iloc[-1] - times.iloc[0]
                net_rate = len(times) / net_time
                print(f"{label:40s}\t{net_rate:.2f} evt/sec")

        plt.xlim(min_time, max_time)
        plt.ylim(0, plt.ylim()[1])
        plt.xlabel('Collection time (sec)')
        plt.ylabel('Events/sec')

        if self.keyword:
            plt.title(self.keyword)
        if self.show_legend:
            plt.legend(loc='best')


if __name__ == '__main__':
    args = docopt.docopt(__doc__)
    experiments = fcmcmp.load_experiments(args['<yml_path>'])

    analysis = EventsPerSec(experiments)
    analysis.keyword = args['<keyword>']
    analysis.show_legend = args['--show-legend']
    analysis.time_window = float(args['--time-window'])
    analysis.verbose = args['--verbose']

    with analysis_helpers.plot_or_savefig(args['--output'],
                                          args['<yml_path>']):
        analysis.plot()
示例#31
0
                # Yield a cell for each combination of construct and spacer.
                yield (x, y), construct, spacer

                # See if this construct has any unexpected mutations, and if it
                # does, also yield a cell that excludes them.
                expected_only = construct + ',1'
                y_offset = self.cell_height * (len(self.spacers) + 1 / 2)
                if design_exists(expected_only):
                    yield (x, y - y_offset), expected_only, spacer


class DataMissing(Exception):
    pass


initial_picks = fcmcmp.load_experiments(
    '../../results/facs/20160727_screen_mhf.yml')
recloned_hits = fcmcmp.load_experiments(
    '../../results/facs/20160923_test_mhf_hits.yml')

shared_steps = analysis_helpers.SharedProcessingSteps()
shared_steps.process(initial_picks + recloned_hits)


def get_fold_change(construct, spacer):
    expt = find_experiment(construct, spacer)
    apo_well = analysis_helpers.AnalyzedWell(expt, expt['wells']['apo'][0])
    holo_well = analysis_helpers.AnalyzedWell(expt, expt['wells']['holo'][0])

    xlim = 0, 5
    apo_well.estimate_distribution(xlim)
    holo_well.estimate_distribution(xlim)