@@ -1286,6 +1286,92 @@ test_that("testing works", {
12861286 expect_equal(out $ tests [[1 ]]$ logFC / out $ tests [[1 ]]$ se.logFC ,
12871287 out $ tests [[1 ]]$ t , ignore_attr = TRUE )
12881288
1289+ # # -------------------------------------------------------------------------
1290+ # # Merged groups, with batch effect, with sample weights
1291+ args <- args0
1292+ args $ groupComposition <- list (rbc_adnp = c(" RBC_ctrl" , " Adnp" ))
1293+ args $ comparisons <- list (c(" Adnp" , " RBC_ctrl" ), c(" rbc_adnp" , " Chd4BF" ))
1294+ args $ sce $ batch <- c(" B1" , " B2" , " B3" , " B1" , " B2" , " B3" , " B1" , " B2" , " B3" )
1295+ args $ sce $ sampleweight <-
1296+ c(Adnp_IP04 = 1 , Adnp_IP05 = 6 , Adnp_IP06 = 2 ,
1297+ Chd4BF_IP07 = 6 , Chd4BF_IP08 = 1 , Chd4BF_IP09 = 5 ,
1298+ RBC_ctrl_IP01 = 7 , RBC_ctrl_IP02 = 1 , RBC_ctrl_IP03 = 2 )[colnames(args $ sce )]
1299+ out <- do.call(runTest , args )
1300+ expect_type(out , " list" )
1301+ expect_length(out , 9 )
1302+ expect_named(out , c(" plottitles" , " plotsubtitles" , " plotnotes" ,
1303+ " tests" , " curveparams" , " topsets" , " messages" ,
1304+ " design" , " featureCollections" ))
1305+ expect_s3_class(out $ tests [[1 ]], " data.frame" )
1306+ expect_type(out $ plotnotes [[1 ]], " character" )
1307+ expect_type(out $ plottitles [[1 ]], " character" )
1308+ expect_s3_class(out $ tests [[2 ]], " data.frame" )
1309+ expect_type(out $ plotnotes [[2 ]], " character" )
1310+ expect_type(out $ plottitles [[2 ]], " character" )
1311+ expect_type(out $ featureCollections , " list" )
1312+ expect_type(out $ design , " list" )
1313+ expect_named(out $ design , c(" RBC_ctrl_vs_Adnp" , " Chd4BF_vs_rbc_adnp" ))
1314+ expect_type(out $ design $ RBC_ctrl_vs_Adnp , " list" )
1315+ expect_named(out $ design $ RBC_ctrl_vs_Adnp , c(" design" , " sampleData" , " contrast" ,
1316+ " sampleWeights" ))
1317+ expect_named(out $ design $ RBC_ctrl_vs_Adnp $ sampleData , c(" fc" , " bc" ))
1318+ expect_equal(out $ design $ RBC_ctrl_vs_Adnp $ contrast , c(0 , 0 , 0 , 1 ))
1319+ expect_equal(out $ design $ RBC_ctrl_vs_Adnp $ sampleWeights ,
1320+ args $ sce $ sampleweight [rownames(out $ design $ RBC_ctrl_vs_Adnp $ sampleData )])
1321+ expect_type(out $ design $ Chd4BF_vs_rbc_adnp , " list" )
1322+ expect_named(out $ design $ Chd4BF_vs_rbc_adnp , c(" design" , " sampleData" , " contrast" ,
1323+ " sampleWeights" ))
1324+ expect_named(out $ design $ Chd4BF_vs_rbc_adnp $ sampleData , c(" fc" , " bc" ))
1325+ expect_equal(out $ design $ Chd4BF_vs_rbc_adnp $ contrast , c(0 , 0 , 0 , 1 ))
1326+ expect_equal(out $ design $ Chd4BF_vs_rbc_adnp $ sampleWeights ,
1327+ args $ sce $ sampleweight [rownames(out $ design $ Chd4BF_vs_rbc_adnp $ sampleData )])
1328+ expect_type(out $ curveparams [[1 ]], " list" )
1329+ expect_equal(nrow(out $ tests [[1 ]]), 150 )
1330+ expect_type(out $ curveparams [[2 ]], " list" )
1331+ expect_equal(nrow(out $ tests [[2 ]]), 150 )
1332+ expect_true(all(c(" adj.P.Val" , " iBAQ.Adnp_IP04" ,
1333+ " showInVolcano" , " IDsForSTRING" ) %in% colnames(out $ tests [[1 ]])))
1334+ expect_true(all(c(" adj.P.Val" , " iBAQ.Adnp_IP04" ,
1335+ " showInVolcano" , " IDsForSTRING" ) %in% colnames(out $ tests [[2 ]])))
1336+ expect_equal(out $ tests [[1 ]]$ pid , rownames(sce_mq_final ))
1337+ expect_equal(out $ tests [[2 ]]$ pid , rownames(sce_mq_final ))
1338+ expect_equal(substr(out $ plotnotes [[1 ]], 1 , 8 ), " df.prior" )
1339+ expect_equal(substr(out $ plotnotes [[2 ]], 1 , 8 ), " df.prior" )
1340+ expect_equal(out $ plottitles [[1 ]], " RBC_ctrl vs Adnp, limma" )
1341+ expect_equal(out $ plottitles [[2 ]], " Chd4BF vs rbc_adnp, limma" )
1342+ expect_s4_class(out $ featureCollections $ complexes , " CharacterList" )
1343+ expect_s4_class(S4Vectors :: mcols(out $ featureCollections $ complexes ), " DFrame" )
1344+ expect_true(" RBC_ctrl_vs_Adnp_FDR" %in%
1345+ colnames(S4Vectors :: mcols(out $ featureCollections $ complexes )))
1346+ expect_equal(out $ tests [[1 ]]$ iBAQ.Adnp_IP04 ,
1347+ SummarizedExperiment :: assay(args $ sce , " iBAQ" )[, " Adnp_IP04" ],
1348+ ignore_attr = TRUE )
1349+ expect_equal(out $ tests [[2 ]]$ iBAQ.Adnp_IP04 ,
1350+ SummarizedExperiment :: assay(args $ sce , " iBAQ" )[, " Adnp_IP04" ],
1351+ ignore_attr = TRUE )
1352+ # # Compare to values calculated manually
1353+ expect_equal(out $ tests [[2 ]][c(" Mbd3" , " Mta1.F8WHY8" , " Pogz" , " Zfp462.B1AWL2" ), " logFC" ],
1354+ c(13.237967 , 15.502178 , 9.519576 , 10.742178 ),
1355+ tolerance = 0.001 )
1356+ expect_equal(out $ tests [[2 ]][c(" Mbd3" , " Mta1.F8WHY8" , " Pogz" , " Zfp462.B1AWL2" ), " t" ],
1357+ c(10.793285 , 10.408011 , 8.845311 , 8.634606 ),
1358+ tolerance = 0.001 )
1359+ # # Check consistency of values
1360+ # # logFC +/- t * se = CI.R/CI.L
1361+ expect_equal(out $ tests [[1 ]]$ logFC + qt(p = 0.975 , df = out $ tests [[1 ]]$ df.total ) *
1362+ out $ tests [[1 ]]$ se.logFC ,
1363+ out $ tests [[1 ]]$ CI.R , ignore_attr = TRUE )
1364+ expect_equal(out $ tests [[1 ]]$ logFC - qt(p = 0.975 , df = out $ tests [[1 ]]$ df.total ) *
1365+ out $ tests [[1 ]]$ se.logFC ,
1366+ out $ tests [[1 ]]$ CI.L , ignore_attr = TRUE )
1367+ # # p-values
1368+ expect_equal(2 * stats :: pt(abs(out $ tests [[1 ]]$ t ),
1369+ out $ tests [[1 ]]$ df.total , lower.tail = FALSE ),
1370+ out $ tests [[1 ]]$ P.Value , ignore_attr = TRUE )
1371+ # # t-statistics
1372+ expect_equal(out $ tests [[1 ]]$ logFC / out $ tests [[1 ]]$ se.logFC ,
1373+ out $ tests [[1 ]]$ t , ignore_attr = TRUE )
1374+
12891375 # # -------------------------------------------------------------------------
12901376 # # Merged groups, with batch effect, single fit
12911377 args <- args0
0 commit comments