How to use the bioframe.subtract function in bioframe

To help you get started, we’ve selected a few bioframe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mirnylab / bioframe / tests / test_ops.py View on Github external
bioframe.subtract(df1, df2)
            .sort_values(['chrom','start','end'])
            .reset_index(drop=True)
    )

    df2 = pd.DataFrame(
        [["chrX", 0, 4], ["chr1", 6, 6], ["chrX", 4, 9]],
        columns=["chrom", "start", "end"],
    )

    df1["animal"] = "sea-creature"
    df_result = pd.DataFrame(
        [["chr1", 4, 6, "sea-creature"], ["chr1", 6, 7, "sea-creature"]],
        columns=["chrom", "start", "end", "animal"],
    )
    print(bioframe.subtract(df1, df2))
    pd.testing.assert_frame_equal(
        df_result, 
        bioframe.subtract(df1, df2)
            .sort_values(['chrom','start','end'])
            .reset_index(drop=True)
    )
github mirnylab / bioframe / tests / test_ops.py View on Github external
)

    df2 = pd.DataFrame(
        [["chrX", 0, 4], ["chr1", 6, 6], ["chrX", 4, 9]],
        columns=["chrom", "start", "end"],
    )

    df1["animal"] = "sea-creature"
    df_result = pd.DataFrame(
        [["chr1", 4, 6, "sea-creature"], ["chr1", 6, 7, "sea-creature"]],
        columns=["chrom", "start", "end", "animal"],
    )
    print(bioframe.subtract(df1, df2))
    pd.testing.assert_frame_equal(
        df_result, 
        bioframe.subtract(df1, df2)
            .sort_values(['chrom','start','end'])
            .reset_index(drop=True)
    )
github mirnylab / bioframe / tests / test_ops.py View on Github external
def test_subtract():
    df1 = pd.DataFrame(
        [["chrX", 3, 8], ["chr1", 4, 7], ["chrX", 1, 5]],
        columns=["chrom", "start", "end"],
    )
    assert len(bioframe.subtract(df1, df1)) == 0

    df2 = pd.DataFrame(
        [["chrX", 0, 18], ["chr1", 5, 6],], columns=["chrom", "start", "end"]
    )

    df1["animal"] = "sea-creature"
    df_result = pd.DataFrame(
        [["chr1", 4, 5, "sea-creature"], ["chr1", 6, 7, "sea-creature"]],
        columns=["chrom", "start", "end", "animal"],
    )
    pd.testing.assert_frame_equal(
        df_result, 
        bioframe.subtract(df1, df2)
            .sort_values(['chrom','start','end'])
            .reset_index(drop=True)
    )