8000 fix 940 - qualify QueryRate_Assess by chelseadickens · Pull Request #999 · Gilead-BioStats/gsm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix 940 - qualify QueryRate_Assess #999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions inst/qualification/spec_QueryRate_Assess.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
- ID: SX_1
Description: Given correct input data a Query Rate assessment can be done using the poisson method
Risk: High
Impact: High
Tests:
- TX_X
- ID: SX_2
Description: Given correct input data a Query Rate assessment can be done using the identity method
Risk: High
Impact: High
Tests:
- TX_X
- ID: SX_3
Description: Given correct input data a Query Rate assessment can be done using the normal approximation method
Risk: High
Impact: High
Tests:
- TX_X
- ID: SX_4
Description: Assessments are correctly grouped by a grouping variable such as site or country for KRIs and study for QTLs when applicable
Risk: Low
Impact: High
Tests:
- TX_X
- ID: SX_5
Description: Given correct input data flags will correctly be applied to records that meet flagging criteria, including custom thresholding
Risk: Medium
Impact: High
Tests:
- TX_X
- ID: S1_6
Description: Given subset input data a Query Rate assessment can be done
Risk: Medium
Impact: Medium
Tests:
- TX_X
45 changes: 45 additions & 0 deletions tests/testqualification/qualification/test_qual_T10_1.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
test_that("Query rate assessment can return a correctly assess 10000 ed data frame for the identity test grouped by the site variable when given correct input data from clindata and the results should be flagged correctly using a custom threshold.", {
# gsm analysis
dfInput <- gsm::QueryRate_Map_Raw()

test10_1 <- QueryRate_Assess(
dfInput = dfInput,
strMethod = "Identity",
strGroup = "Site",
vThreshold = c(0.005, 0.05)
)

# double programming
t10_1_input <- dfInput

t10_1_transformed <- dfInput %>%
qualification_transform_counts(countCol = "Count",
exposureCol = "DataPoint")

t10_1_analyzed <- t10_1_transformed %>%
mutate(
Score = Metric
) %>%
arrange(Score)

class(t10_1_analyzed) <- c("tbl_df", "tbl", "data.frame")

t10_1_flagged <- t10_1_analyzed %>%
qualification_flag_identity(threshold = c(0.005, 0.05))

t10_1_summary <- t10_1_flagged %>%
select(GroupID, Numerator, Denominator, Metric, Score, Flag) %>%
arrange(desc(abs(Metric))) %>%
arrange(match(Flag, c(2, -2, 1, -1, 0)))


t10_1 <- list(
"dfTransformed" = t10_1_transformed,
"dfAnalyzed" = t10_1_analyzed,
"dfFlagged" = t10_1_flagged,
"dfSummary" = t10_1_summary
)

# compare results
expect_equal(test10_1$lData, t10_1)
})
49 changes: 49 additions & 0 deletions tests/testqualification/qualification/test_qual_T10_2.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
test_that("Query rate assessment can return a correctly assessed data frame for the identity test grouped by a custom variable when given subset input data from clindata and the results should be flagged correctly.", {
# gsm analysis
dfInput <- gsm::QueryRate_Map_Raw(dfs = list(
dfQUERY = clindata::edc_queries %>% filter(foldername == "Week 120"),
dfSUBJ = clindata::rawplus_dm,
dfDATACHG = clindata::edc_data_change_rate
))

test10_2 <- QueryRate_Assess(
dfInput = dfInput,
strMethod = "Identity",
strGroup = "CustomGroup"
)

# double programming
t10_2_input <- dfInput

t10_2_transformed <- dfInput %>%
qualification_transform_counts(countCol = "Count",
exposureCol = "DataPoint",
GroupID = "CustomGroupID")

t10_2_analyzed <- t10_2_transformed %>%
mutate(
Score = Metric
) %>%
arrange(Score)

class(t10_2_analyzed) <- c("tbl_df", "tbl", "data.frame")

t10_2_flagged <- t10_2_analyzed %>%
qualification_flag_identity(threshold = c(0.00006, 0.01))

t10_2_summary <- t10_2_flagged %>%
select(GroupID, Numerator, Denominator, Metric, Score, Flag) %>%
arrange(desc(abs(Metric))) %>%
arrange(match(Flag, c(2, -2, 1, -1, 0)))


t10_2 <- list(
"dfTransformed" = t10_2_transformed,
"dfAnalyzed" = t10_2_analyzed,
"dfFlagged" = t10_2_flagged,
"dfSummary" = t10_2_summary
)

# compare results
expect_equal(test10_2$lData, t10_2)
})
46 changes: 46 additions & 0 deletions tests/testqualification/qualification/test_qual_T10_3.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
test_that("Query rate assessment can return a correctly assessed data frame for the identity test grouped by the country variable when given correct input data from clindata and the results should be flagged correctly.", {
# gsm analysis
dfInput <- gsm::QueryRate_Map_Raw()

test10_3 <- QueryRate_Assess(
dfInput = dfInput,
strMethod = "Identity",
strGroup = "Country"
)

# double programming
t10_3_input <- dfInput

t10_3_transformed <- dfInput %>%
qualification_transform_counts(countCol = "Count",
exposureCol = "DataPoint",
GroupID = "CountryID")

t10_3_analyzed <- t10_3_transformed %>%
mutate(
Score = Metric
) %>%
arrange(Score)

class(t10_3_analyzed) <- c("tbl_df", "tbl", "data.frame")


t10_3_flagged <- t10_3_analyzed %>%
qualification_flag_identity(threshold = c(0.00006, 0.01))

t10_3_summary <- t10_3_flagged %>%
select(GroupID, Numerator, Denominator, Metric, Score, Flag) %>%
arrange(desc(abs(Metric))) %>%
arrange(match(Flag, c(2, -2, 1, -1, 0)))


t10_3 <- list(
"dfTransformed" = t10_3_transformed,
"dfAnalyzed" = t10_3_analyzed,
"dfFlagged" = t10_3_flagged,
"dfSummary" = t10_3_summary
)

# compare results
expect_equal(test10_3$lData, t10_3)
})
42 changes: 42 additions & 0 deletions tests/testqualification/qualification/test_qual_T10_4.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
test_that("Query rate assessment can return a correctly assessed data frame for the poisson test grouped by the site variable when given correct input data from clindata and the results should be flagged correctly using a custom threshold.", {
# gsm analysis
dfInput <- gsm::QueryRate_Map_Raw()

test10_4 <- QueryRate_Assess(
dfInput = dfInput,
strMethod = "Poisson",
strGroup = "Site",
vThreshold = c(-6, -4, 4, 6)
)

# double programming
t10_4_input <- dfInput

t10_4_transformed <- dfInput %>%
qualification_transform_counts(countCol = "Count",
exposureCol = "DataPoint")

t10_4_analyzed <- t10_4_transformed %>%
qualification_analyze_poisson()

class(t10_4_analyzed) <- c("tbl_df", "tbl", "data.frame")

t10_4_flagged <- t10_4_analyzed %>%
qualification_flag_poisson(threshold = c(-6, -4, 4, 6))

t10_4_summary <- t10_4_flagged %>%
select(GroupID, Numerator, Denominator, Metric, Score, Flag) %>%
arrange(desc(abs(Metric))) %>%
arrange(match(Flag, c(2, -2, 1, -1, 0)))


t10_4 <- list(
"dfTransformed" = t10_4_transformed,
"dfAnalyzed" = t10_4_analyzed,
"dfFlagged" = t10_4_flagged,
"dfSummary" = t10_4_summary
)

# compare results
expect_equal(test10_4$lData[names(test10_4$lData) != "dfBounds"], t10_4)
})
46 changes: 46 additions & 0 deletions tests/testqualification/qualification/test_qual_T10_5.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
test_that("Query rate assessment can return a correctly assessed data frame for the poisson test grouped by a custom variable when given subset input data from clindata and the results should be flagged correctly.", {
# gsm analysis
dfInput <- gsm::QueryRate_Map_Raw(dfs = list(
dfQUERY = clindata::edc_queries %>% filter(foldername == "Week 120"),
dfSUBJ = clindata::rawplus_dm,
dfDATACHG = clindata::edc_data_change_rate
))

test10_5 <- QueryRate_Assess(
dfInput = dfInput,
strMethod = "Poisson",
strGroup = "CustomGroup"
)

# double programming
t10_5_input <- dfInput

t10_5_transformed <- dfInput %>%
qualification_transform_counts(countCol = "Count",
exposureCol = "DataPoint",
GroupID = "CustomGroupID")

t10_5_analyzed <- t10_5_transformed %>%
qualification_analyze_poisson()

class(t10_5_analyzed) <- c("tbl_df", "tbl", "data.frame")

t10_5_flagged <- t10_5_analyzed %>%
qualification_flag_poisson()

t10_5_summary <- t10_5_flagged %>%
select(GroupID, Numerator, Denominator, Metric, Score, Flag) %>%
arrange(desc(abs(Metric))) %>%
arrange(match(Flag, c(2, -2, 1, -1, 0)))


t10_5 <- list(
"dfTransformed" = t10_5_transformed,
"dfAnalyzed" = t10_5_analyzed,
"dfFlagged" = t10_5_flagged,
"dfSummary" = t10_5_summary
)

# compare results
expect_equal(test10_5$lData[names(test10_5$lData) != "dfBounds"], t10_5)
})
43 changes: 43 additions & 0 deletions tests/testqualification/qualification/test_qual_T10_6.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
test_that("Query rate assessment can return a correctly assessed data frame for the poisson test grouped by the country variable when given correct input data from clindata and the results should be flagged correctly.", {
# gsm analysis
dfInput <- gsm::QueryRate_Map_Raw()

test10_6 <- QueryRate_Assess(
dfInput = dfInput,
strMethod = "Poisson",
strGroup = "Country"
)

# double programming
t10_6_input <- dfInput

t10_6_transformed <- dfInput %>%
qualification_transform_counts(countCol = "Count",
exposureCol = "DataPoint",
GroupID = "CountryID")

t10_6_analyzed <- t10_6_transformed %>%
qualification_analyze_poisson()

class(t10_6_analyzed) <- c("tbl_df", "tbl", "data.frame")


t10_6_flagged <- t10_6_analyzed %>%
qualification_flag_poisson()

t10_6_summary <- t10_6_flagged %>%
select(GroupID, Numerator, Denominator, Metric, Score, Flag) %>%
arrange(desc(abs(Metric))) E804 %>%
arrange(match(Flag, c(2, -2, 1, -1, 0)))


t10_6 <- list(
"dfTransformed" = t10_6_transformed,
"dfAnalyzed" = t10_6_analyzed,
"dfFlagged" = t10_6_flagged,
"dfSummary" = t10_6_summary
)

# compare results
expect_equal(test10_6$lData[names(test10_6$lData) != "dfBounds"], t10_6)
})
42 changes: 42 additions & 0 deletions tests/testqualification/qualification/test_qual_T10_7.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
test_that("Query rate assessment can return a correctly assessed data frame for the normal approximation test grouped by the site variable when given correct input data from clindata and the results should be flagged correctly using a custom threshold.", {
# gsm analysis
dfInput <- gsm::QueryRate_Map_Raw()

test10_7 <- QueryRate_Assess(
dfInput = dfInput,
strMethod = "NormalApprox",
strGroup = "Site",
vThreshold = c(-2, -1, 1, 2)
)

# double programming
t10_7_input <- dfInput

t10_7_transformed <- dfInput %>%
qualification_transform_counts(countCol = "Count",
exposureCol = "DataPoint")

t10_7_analyzed <- t10_7_transformed %>%
qualification_analyze_normalapprox(strType = "rate")

class(t10_7_analyzed) <- c("tbl_df", "tbl", "data.frame")

t10_7_flagged <- t10_7_analyzed %>%
qualification_flag_normalapprox(threshold = c(-2, -1, 1, 2))

t10_7_summary <- t10_7_flagged %>%
select(GroupID, Numerator, Denominator, Metric, Score, Flag) %>%
arrange(desc(abs(Metric))) %>%
arrange(match(Flag, c(2, -2, 1, -1, 0)))


t10_7 <- list(
"dfTransformed" = t10_7_transformed,
"dfAnalyzed" = t10_7_analyzed,
"dfFlagged" = t10_7_flagged,
"dfSummary" = t10_7_summary
)

# compare results
expect_equal(test10_7$lData[names(test10_7$lData) != "dfBounds"], t10_7)
})
Loading
0