Exemplo n.º 1
0
def test_dropping_all_samples_and_features():
    """Tests Qurro's behavior when > 0 feature(s) and all samples are unsupported.

       In particular, qurro should just throw an error about the
       feature(s) being unsupported -- the feature check should come before the
       sample check (not for any particular reason, that's just how I wrote the
       code).
    """
    run_integration_test(
        "matching_test",
        "matching_test/all_samples_and_one_feature_dropped",
        "differentials.tsv",
        "all_samples_and_one_feature_dropped.biom",
        "sample_metadata.txt",
        feature_metadata_name="feature_metadata.txt",
        expect_all_unsupported_samples=True,
        expected_unsupported_features=1,
    )
    run_integration_test(
        "matching_test",
        "matching_test/all_samples_and_two_features_dropped",
        "differentials.tsv",
        "all_samples_and_two_features_dropped.biom",
        "sample_metadata.txt",
        feature_metadata_name="feature_metadata.txt",
        expect_all_unsupported_samples=True,
        expected_unsupported_features=2,
    )
Exemplo n.º 2
0
def test_dropping_all_samples():
    """Tests that Qurro raises an error when all samples are unsupported."""
    run_integration_test(
        "matching_test",
        "matching_test/all_samples_dropped",
        "differentials.tsv",
        "all_samples_dropped.biom",
        "sample_metadata.txt",
        feature_metadata_name="feature_metadata.txt",
        expect_all_unsupported_samples=True,
    )
Exemplo n.º 3
0
def test_integration_q2_byrd():
    """Tests qurro on songbird output in the context of QIIME 2."""

    run_integration_test(
        "byrd",
        "q2_byrd",
        "byrd_differentials.tsv",
        "byrd_skin_table.biom",
        "byrd_metadata.txt",
        use_q2=True,
        q2_ranking_tool="songbird",
    )
Exemplo n.º 4
0
def test_integration_q2_sleep_apnea():
    """Tests qurro on DEICODE output in the context of QIIME 2."""

    run_integration_test(
        "sleep_apnea",
        "q2_sleep_apnea",
        "ordination.txt",
        "qiita_10422_table.biom",
        "qiita_10422_metadata.tsv",
        feature_metadata_name="taxonomy.tsv",
        use_q2=True,
        q2_ranking_tool="DEICODE",
    )
def test_byrd():
    """Tests Qurro's JSON generation on the Byrd et al. 2017 dataset.

       This is really a test to make sure that qurro can properly handle
       songbird output.
    """
    run_integration_test(
        "byrd",
        "byrd",
        "byrd_differentials.tsv",
        "byrd_skin_table.biom",
        "byrd_metadata.txt",
    )
Exemplo n.º 6
0
def test_moving_pictures():
    """Tests qurro' JSON generation on the "Moving Pictures of the Human
       Microbiome" dataset.
    """
    run_integration_test(
        "moving_pictures",
        "q2_moving_pictures",
        "ordination.txt",
        "feature-table.biom",
        "sample-metadata.tsv",
        feature_metadata_name="taxonomy.tsv",
        use_q2=True,
        q2_ranking_tool="DEICODE",
    )
def test_sleep_apnea():
    """Tests Qurro's JSON generation on a "sleep apnea" dataset.

       This is really a test to make sure that qurro can properly handle
       DEICODE output.
    """
    run_integration_test(
        "sleep_apnea",
        "sleep_apnea",
        "ordination.txt",
        "qiita_10422_table.biom",
        "qiita_10422_metadata.tsv",
        feature_metadata_name="taxonomy.tsv",
    )
def test_red_sea():
    """Tests Qurro's JSON generation on a dataset from a study of the Red
       Sea.

       This is really a test to make sure that qurro can properly handle
       this sort of unconventionally-named-feature data.
    """
    run_integration_test(
        "red_sea",
        "red_sea",
        "differentials.tsv",
        "redsea.biom",
        "redsea_metadata.txt",
        feature_metadata_name="feature_metadata.txt",
    )
def test_mackerel():
    """Tests Qurro's JSON generation on the mackerel dataset (Qiita Study ID
       11721).

       This is less of a test and more of just a way to ensure that we
       continuously update the mackerel demo whenever we update Qurro.
    """
    run_integration_test(
        "mackerel",
        "mackerel",
        "differentials.tsv",
        "feature-table.biom",
        "sample-metadata.tsv",
        feature_metadata_name="taxonomy.tsv",
        expected_unsupported_samples=1067,
    )
Exemplo n.º 10
0
def test_integration_q2_red_sea():
    """Tests qurro on songbird output with non-strictly-16S data in the
       context of QIIME 2.

       (Technically the Byrd data is also from a metagenomic study, but the
       features here are named pretty differently.)
    """
    run_integration_test(
        "red_sea",
        "q2_red_sea",
        "differentials.tsv",
        "redsea.biom",
        "redsea_metadata.txt",
        feature_metadata_name="feature_metadata.txt",
        use_q2=True,
        q2_ranking_tool="songbird",
    )
def test_empty_sample_integration_basic():
    rpj, spj, cj = run_integration_test(
        *params, feature_metadata_name="feature_metadata.txt")
    # look at sample plot json -- verify that just Sample2 dropped (due to
    # being empty: having a count of 0 for every feature)
    sample_data = get_data_from_plot_json(spj)
    for s in ("Sample1", "Sample3", "Sample5", "Sample6", "Sample7"):
        assert s in sample_data
    assert "Sample4" not in sample_data
    assert "Sample2" not in sample_data
Exemplo n.º 12
0
def test_dropping_features():
    """Tests that Qurro raises an error when > 0 feature(s) are unsupported."""

    # Test that dropping 1 feature produces an error
    run_integration_test(
        "matching_test",
        "matching_test/dropped_feature",
        "differentials.tsv",
        "dropped_feature.biom",
        "sample_metadata.txt",
        feature_metadata_name="feature_metadata.txt",
        expected_unsupported_features=1,
    )
    # Test that dropping 2 features produces an error
    run_integration_test(
        "matching_test",
        "matching_test/dropped_features",
        "differentials.tsv",
        "dropped_features.biom",
        "sample_metadata.txt",
        feature_metadata_name="feature_metadata.txt",
        expected_unsupported_features=2,
    )
Exemplo n.º 13
0
def test_sample_dropping_stats():
    """Tests Qurro's JSON generation on a dataset with weird sample
       metadata.
    """
    rank_json, sample_json, count_json = run_integration_test(
        "sample_stats_test",
        "q2_sample_stats_test",
        "differentials.tsv",
        "sst.biom",
        "sample_metadata.txt",
        expected_unsupported_samples=1,
        use_q2=True,
        q2_ranking_tool="songbird",
        q2_table_biom_format="BIOMV100Format",
    )
    validate_sample_stats_test_sample_plot_json(sample_json)
def test_sample_dropping_stats():
    """Tests Qurro's JSON generation on a dataset with weird sample
       metadata.

       The output from this test will be used in JS tests -- this verifies that
       both the python and JS parts of Qurro can handle weird metadata
       appropriately.
    """
    rank_json, sample_json, count_json = run_integration_test(
        "sample_stats_test",
        "sample_stats_test",
        "differentials.tsv",
        "sst.biom",
        "sample_metadata.txt",
        expected_unsupported_samples=1,
    )
    validate_sample_stats_test_sample_plot_json(sample_json)
def test_empty_sample_integration_extreme_feature_count():
    params_copy = params[:]
    params_copy[1] = "empty_samples_yes_efc"
    rpj2, spj2, cj2 = run_integration_test(
        *params_copy,
        feature_metadata_name="feature_metadata.txt",
        extreme_feature_count=1,
    )
    # look at sample plot json -- verify that Sample2 + 3 dropped
    # (Sample2 due to being empty, and Sample3 due to being empty after the one
    # feature it had a count for, Taxon3, was removed due to -x.)
    # (Also, verify that most of the features were dropped due to -x.)
    sample_data_2 = get_data_from_plot_json(spj2)
    for s2 in ("Sample1", "Sample5", "Sample6", "Sample7"):
        assert s2 in sample_data_2
    assert "Sample4" not in sample_data_2
    assert "Sample2" not in sample_data_2
    assert "Sample3" not in sample_data_2
Exemplo n.º 16
0
def test_feature_metadata_and_dropped_sample():
    """Tests the behavior of Qurro in matching sample metadata, feature
       metadata, ranks, and the BIOM table together.
    """

    rank_json, sample_json, count_json = run_integration_test(
        "matching_test",
        "matching_test",
        "differentials.tsv",
        "mt.biom",
        "sample_metadata.txt",
        feature_metadata_name="feature_metadata.txt",
        expected_unsupported_samples=1,
    )

    data_name = rank_json["data"]["name"]

    # Check that feature metadata annotations were done correctly
    for feature in rank_json["datasets"][data_name]:
        txid = feature["Feature ID"]
        if feature["Feature ID"] == "Taxon3":
            assert feature["FeatureMetadata1"] == "Yeet"
            # this should be interpreted this as a string, since "lol" is in
            # the same column
            assert feature["FeatureMetadata2"] == "100"
        elif feature["Feature ID"] == "Taxon5":
            # This should be interpeted as a string, also
            assert feature["FeatureMetadata1"] == "null"
            assert feature["FeatureMetadata2"] == "lol"
        else:
            # Check that the other taxa haven't been annotated with any
            # metadata.
            assert feature["FeatureMetadata1"] is None
            assert feature["FeatureMetadata2"] is None

    # Assert that Sample4 was dropped from the "main" dataset of the plot
    data_name = sample_json["data"]["name"]
    for sample in sample_json["datasets"][data_name]:
        assert sample["Sample ID"] != "Sample4"

    for txid in count_json:
        # Assert that Sample4 was also dropped from the counts data in the JSON
        assert "Sample4" not in count_json[txid]