@@ -112,6 +112,37 @@ test_that("[DRAGON] dragon() exported function works on simulated data",
112112
113113})
114114
115+ # test that output matrices carry input variable names (issue #319)
116+ test_that(" [DRAGON] output matrices preserve input column names" ,
117+ {
118+ toy_layer1 = matrix (c(1 ,2 ,3 ,1 ,5 ,12 ),nrow = 3 ,byrow = T )
119+ toy_layer2 = matrix (c(9 ,7 ,8 ),nrow = 3 ,byrow = T )
120+ colnames(toy_layer1 ) = c(" gene1" ," gene2" )
121+ colnames(toy_layer2 ) = c(" methyl1" )
122+
123+ res = dragon(layer1 = toy_layer1 , layer2 = toy_layer2 , pval = F )
124+ expected_names = c(" gene1" ," gene2" ," methyl1" )
125+
126+ expect_equal(rownames(res $ cov ), expected_names )
127+ expect_equal(colnames(res $ cov ), expected_names )
128+ expect_equal(rownames(res $ prec ), expected_names )
129+ expect_equal(colnames(res $ prec ), expected_names )
130+ expect_equal(rownames(res $ ggm ), expected_names )
131+ expect_equal(colnames(res $ ggm ), expected_names )
132+ })
133+
134+ # test that dragon still works when inputs have no column names
135+ test_that(" [DRAGON] output matrices work without input column names" ,
136+ {
137+ toy_layer1 = matrix (c(1 ,2 ,3 ,1 ,5 ,12 ),nrow = 3 ,byrow = T )
138+ toy_layer2 = matrix (c(9 ,7 ,8 ),nrow = 3 ,byrow = T )
139+
140+ res = dragon(layer1 = toy_layer1 , layer2 = toy_layer2 , pval = F )
141+
142+ expect_null(rownames(res $ cov ))
143+ expect_null(colnames(res $ cov ))
144+ })
145+
115146# test log likelihood function
116147# test_that("[DRAGON] Log likelihood function for estimation of kappa is correct",{
117148# # log_lik_shrunken = function(kappa, p, lambda, rhos)
0 commit comments