context("Determine abundances")
# Generated by gintools:::generate_test_granges()
input_gr <- GenomicRanges::GRanges(
seqnames = S4Vectors::Rle(factor("chr1"), 100),
ranges = IRanges::IRanges(
start = c(
598L, 598L, 599L, 599L, 599L, 599L, 599L, 599L, 600L, 600L, 600L, 600L,
600L, 600L, 600L, 600L, 601L, 601L, 601L, 602L, 657L, 657L, 658L, 658L,
658L, 659L, 659L, 659L, 659L, 659L, 659L, 659L, 660L, 660L, 660L, 660L,
661L, 661L, 661L, 661L, 743L, 743L, 743L, 744L, 744L, 744L, 744L, 745L,
745L, 745L, 745L, 745L, 746L, 746L, 746L, 746L, 746L, 746L, 747L, 747L,
780L, 781L, 781L, 781L, 781L, 781L, 781L, 782L, 782L, 782L, 782L, 782L,
783L, 783L, 783L, 783L, 783L, 783L, 784L, 784L, 834L, 835L, 835L, 835L,
835L, 835L, 835L, 836L, 836L, 837L, 837L, 837L, 837L, 837L, 837L, 837L,
837L, 837L, 838L, 838L
),
width = c(
89L, 99L, 32L, 32L, 41L, 58L, 60L, 95L, 33L, 34L, 39L, 47L, 65L, 72L, 76L,
77L, 55L, 64L, 85L, 45L, 55L, 99L, 32L, 33L, 58L, 45L, 47L, 72L, 76L, 77L,
85L, 95L, 39L, 60L, 65L, 89L, 32L, 34L, 41L, 64L, 41L, 58L, 99L, 32L, 55L,
72L, 95L, 32L, 34L, 39L, 64L, 76L, 45L, 60L, 65L, 77L, 85L, 89L, 33L, 47L,
89L, 32L, 34L, 41L, 55L, 60L, 72L, 32L, 33L, 64L, 85L, 99L, 45L, 47L, 58L,
65L, 76L, 77L, 39L, 95L, 45L, 47L, 55L, 60L, 64L, 76L, 89L, 58L, 72L, 32L,
34L, 39L, 41L, 65L, 77L, 85L, 95L, 99L, 32L, 33L
)
),
strand = S4Vectors::Rle(factor("+", levels = c("+", "-", "*")), lengths = 100)
)
output_df <- data.frame(
posid = factor(c(
"chr1+598", "chr1+599", "chr1+600", "chr1+601", "chr1+602",
"chr1+657", "chr1+658", "chr1+659", "chr1+660", "chr1+661",
"chr1+743", "chr1+744", "chr1+745", "chr1+746", "chr1+747",
"chr1+780", "chr1+781", "chr1+782", "chr1+783", "chr1+784",
"chr1+834", "chr1+835", "chr1+836", "chr1+837", "chr1+838"
)),
group = factor("group1"),
estAbund = c(
2, 5, 8, 3, 1, 2, 3, 7, 4, 4, 3, 4, 5, 6, 2, 1, 6, 5, 6, 2, 1, 6, 2, 9, 2
),
relAbund = c(
0.02, 0.05, 0.08, 0.03, 0.01, 0.02, 0.03, 0.07, 0.04, 0.04,
0.03, 0.04, 0.05, 0.06, 0.02, 0.01, 0.06, 0.05, 0.06, 0.02,
0.01, 0.06, 0.02, 0.09, 0.02
),
relRank = c(
22L, 10L, 2L, 16L, 25L, 22L, 16L, 3L, 13L, 13L,
16L, 13L, 10L, 7L, 22L, 25L, 7L, 10L, 7L, 22L,
25L, 7L, 22L, 1L, 22L
)
)
test_that("Abundance data.frame from input GRanges", {
set.seed(1)
res <- determine_abundance(input_gr)
res <- as.data.frame(res, row.names = NULL)
res$relAbund <- round(res$relAbund, digits = 2)
expect_equal(res, output_df)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.