@@ -24,3 +24,32 @@ test_that("test add_uniqueness_attributes", {
24
24
expect_equal(igraph :: V(G_new2 )$ uniqueness , c(NA , NA , TRUE , FALSE , TRUE ))
25
25
26
26
})
27
+
28
+
29
+ test_that(" test add_average_pep_ratio" , {
30
+
31
+ library(igraph )
32
+
33
+ # Create graph
34
+ edges <- c(" prot_1" , " pep_1" ,
35
+ " prot_1" , " pep_2" ,
36
+ " prot_1" , " pep_3" ,
37
+ " prot_2" , " pep_2" ,
38
+ " prot_3" , " pep_2" ,
39
+ " prot_3" , " pep_3" ,
40
+ " prot_3" , " pep_4" )
41
+ types <- c(TRUE , FALSE , FALSE , FALSE , TRUE , TRUE , FALSE )
42
+ pep_ratios <- c(NA , " 1.05;0.9" , NA , " 0.95;1.1" , NA , NA , " 1.15" )
43
+ bipartite_graph <- igraph :: make_graph(edges = edges , directed = FALSE )
44
+ V(bipartite_graph )$ type <- types
45
+ V(bipartite_graph )$ pep_ratio <- pep_ratios
46
+
47
+ # Check attribute creation
48
+ bipartite_graph <- add_average_pep_ratio(bipartite_graph )
49
+
50
+ expect_equal(V(bipartite_graph )$ nr_sequences ,
51
+ c(1 , 2 , 1 , 2 , 1 , 1 , 1 ))
52
+ expect_equal(round(V(bipartite_graph )$ pep_ratio_aggr , digits = 5 ),
53
+ c(NA , 0.97211 , NA , 1.02225 , NA , NA , 1.15000 ))
54
+
55
+ })
0 commit comments