class: center, middle, inverse, title-slide .title[ # PEER Advanced Field School 2023 ] .subtitle[ ## Bipartite Networks ] .author[ ### Eric Brewe
Professor of Physics at Drexel University
] .date[ ### 15 June 2023, last update: 2023-06-29 ] --- # Let's check out bipartite networks I took the network file we have been working on and did two things. 1. I exported it as a tibble, and 2. I added a new variable Ate_Garbage_Plate, and saved it as a csv file in the data folder. This is because we have to rebuild this as a bipartite graph. --- # Let's load this new csv ```` ```r bipartite_df <- read_csv(here("data", "bipartite_df.csv")) ``` ```` --- # Let's take a look at this Bipartite Networks are sometimes known as affiliation networks. In this example we might imagine that people who eat garbage plate (a Rochester classic), like to eat garbage plate together? ```` ```r glimpse(bipartite_df) ``` ```` ``` ## Rows: 60 ## Columns: 5 ## $ name <dbl> 5106, 6633, 7599, 4425, 2495, 6355, 8810, 3877, 1554… ## $ AMPM <chr> "morning person.", "morning person.", "night owl.", … ## $ Dessert <chr> "Brownies", "I don't care for dessert.", "Ice Cream"… ## $ Pages <dbl> 350, 12, 300, 0, 264, 4, 289, 550, 349, 300, 424, 42… ## $ Ate_Garbage_Plate <dbl> 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0… ``` --- #Let's make this a network ```r b_gr <- bipartite_df %>% select(name, Ate_Garbage_Plate) %>% as.matrix(.) %>% graph.incidence(.) %>% as_tbl_graph() ``` --- # Let's treat this as a network There are plenty of things you *can* do with a bipartite network, but mostly *I* focus on the projections. ```r b_gr %>% bipartite_projection() -> b_gr ``` Notice that there are two projections, one which is a person-person projection with 60 nodes, one that is a network of Garbage Plate eaters with 2 nodes. --- # Let's look at the person-person network First, the person-person network ```r p_gr <- b_gr$proj1 p_gr %>% ggraph(.) + geom_edge_link(alpha = .25, aes(width = weight)) + geom_node_point() + theme(legend.position="bottom") ``` ![](PEER_bipartite_graphs_files/figure-html/person_network-1.png)<!-- --> Ugh...way too dense! We need to do some sort of data reduction. That is a different class. But... --- # Let's do some data reduction One common way is to identify the backbone of the network (again, there a bunch of ways to do this, so let's choose an easy one. ) ```r p_gr %>% ggraph(., layout = 'backbone') + geom_edge_link(alpha = .25, aes(width = weight)) + geom_node_point() + theme(legend.position="bottom") ``` ![](PEER_bipartite_graphs_files/figure-html/reduced_person_network-1.png)<!-- --> ...and it doesn't look different (likely because as Rebeckah pointed out is because this is based on a random variable)