setwd(getwd()) library('igraph') library('dplyr') nfdi_seed <- function() { set.seed(1234) } nfdi_conference_colors <- function() { nfdi_color_code <<- c("#f5ac9f", # Medizin "#e43516", # Lebenswissenschaften "#f9b900", # Geisteswissenschaften "#007aaf", # Ingenieurwissenschaften "#6ca11d" # Chemie und Physik ) nfdi_color_groups <<- nfdi_color_code[as.numeric(as.factor(V(nfdi_network_year)$group))] } nfdi_plot_settings <- function(){ nfdi_conference_colors() graph_attr(nfdi_network_year, "layout") <<- norm_coords(layout.graphopt(nfdi_network_year), ymin = -1, ymax = 1, xmin = -1, xmax = 1)*2 vertex_attr(nfdi_network_year, "label.cex") <<- .7 vertex_attr(nfdi_network_year, "label.color") <<- "black" vertex_attr(nfdi_network_year, "label.font") <<- 1 vertex_attr(nfdi_network_year, "label.family") <<- "Helvetica" vertex_attr(nfdi_network_year, "color") <<- nfdi_color_groups vertex_attr(nfdi_network_year, "frame.color") <<- nfdi_color_groups vertex_attr(nfdi_network_year, "size") <<- rescale_vertices(degree(nfdi_network_year, mode="total"))*20 edge_attr(nfdi_network_year, "color") <- "#808080" edge_attr(nfdi_network_year, "curved") <<- 0.1 edge_attr(nfdi_network_year, "arrow.size") <<- .5 edge_attr(nfdi_network_year, "arrow.width") <<- .5 rescale = F } rescale_vertices <- function(x){(x - 3)/(20 - 3)} # min-max normalization; min = (min - 1) to omit zeroes nfdi_presettings <- function(nfdi_edges_year,nfdi_directed_graph){ nfdi_seed() nfdi_edges <<- get(paste0("nfdi_edges_",nfdi_edges_year)) nfdi_nodes <<- get(paste0("nfdi_nodes_",nfdi_edges_year)) nfdi_network_year <<- graph_from_data_frame( d = nfdi_edges, vertices = nfdi_nodes, directed = nfdi_directed_graph) nfdi_plot_settings() } nfdi_edges_2019 <- read.table( header=TRUE, sep=",", text=" from,to Astro-NFDI,PAHN-PaN Astro-NFDI,DAPHNE Astro-NFDI,NFDI4Earth BERD\\@NFDI,KonsortSWD BERD\\@NFDI,ForumX BERD\\@NFDI,Text+ DAPHNE,FAIRmat DAPHNE,NFDI4Chem DAPHNE,NFDI4Ing DAPHNE,NFDI4MSE DAPHNE,NFDI4Cat DAPHNE,PAHN-PaN DAPHNE,Astro-NFDI DataPLANT,NFDI4BioDiversity DataPLANT,NFDI4Agri DataPLANT,NFDI4Chem FAIRmat,DAPHNE FAIRmat,MaRDI FAIRmat,NFDI4Chem FAIRmat,NFDI4Cat FAIRmat,NFDI4Ing FAIRmat,NFDI4MSE ForumX,NFDI4Medicine ForumX,KonsortSWD ForumX,BERD\\@NFDI ForumX,NFDI4Culture ForumX,Text+ GHGA,NFDI4Medicine GHGA,NFDI4Health KonsortSWD,BERD\\@NFDI KonsortSWD,NFDI4BioDiversity KonsortSWD,NFDI4Earth KonsortSWD,NFDI4Health KonsortSWD,Text+ MaRDI,NFDI4MSE MaRDI,PAHN-PaN MaRDI,FAIRmat MaRDI,NFDI4Ing MaRDI,NFDI4Chem MaRDI,NFDI4Culture NFDI4Agri,NFDI4Health NFDI4Agri,DataPLANT NFDI4Agri,NFDI4BioDiversity NFDI4Agri,KonsortSWD NFDI4Agri,NFDI4Earth NFDI4BioDiversity,NFDI4Earth NFDI4BioDiversity,NFDI4Agri NFDI4BioDiversity,NFDI4Chem NFDI4BioDiversity,NFDI4Health NFDI4BioDiversity,KonsortSWD NFDI4BioDiversity,NFDI4Crime NFDI4BioDiversity,DataPLANT NFDI4BioDiversity,NFDI4Medicine NFDI4Cat,FAIRmat NFDI4Cat,NFDI4Chem NFDI4Cat,NFDI4Ing NFDI4Cat,DAPHNE NFDI4Chem,FAIRmat NFDI4Chem,NFDI4Ing NFDI4Chem,NFDI4Cat NFDI4Chem,DAPHNE NFDI4Chem,PAHN-PaN NFDI4Chem,NFDI4Health NFDI4Chem,NFDI4BioDiversity NFDI4Crime,NFDI4BioDiversity NFDI4Crime,NFDI4Medicine NFDI4Crime,Text+ NFDI4Culture,Text+ NFDI4Culture,MaRDI NFDI4Culture,NFDI4Ing NFDI4Earth,Astro-NFDI NFDI4Earth,KonsortSWD NFDI4Earth,NFDI4Agri NFDI4Earth,NFDI4BioDiversity NFDI4Earth,NFDI4Ing NFDI4Health,NFDI4Medicine NFDI4Health,GHGA NFDI4Health,KonsortSWD NFDI4Health,NFDI4Chem NFDI4Health,NFDI4Agri NFDI4Health,NFDI4Earth NFDI4Health,NFDI4BioDiversity NFDI4Ing,NFDI4MSE NFDI4Ing,FAIRmat NFDI4Ing,NFDI4MobilTech NFDI4Ing,NFDI4Chem NFDI4Ing,NFDI4Earth NFDI4Ing,MaRDI NFDI4Ing,NFDI4Medicine NFDI4Ing,Text+ NFDI4Ing,NFDI4Culture NFDI4Medicine,GHGA NFDI4Medicine,NFDI4Health NFDI4Medicine,NFDI4Ing NFDI4Medicine,NFDI4Crime NFDI4Medicine,ForumX NFDI4Medicine,KonsortSWD NFDI4Medicine,NFDI4Agri NFDI4MobilTech,NFDI4Ing NFDI4MobilTech,ForumX NFDI4MobilTech,NFDI4Earth NFDI4MSE,FAIRmat NFDI4MSE,NFDI4Ing NFDI4MSE,MaRDI NFDI4MSE,NFDI4Chem NFDI4MSE,DAPHNE Text+,NFDI4Culture Text+,KonsortSWD Text+,NFDI4Ing Text+,NFDI4Earth Text+,NFDI4BioDiversity ") nfdi_nodes_2019 <- read.table( header=TRUE, sep=",", text=" name,group,funded Astro-NFDI,5,0 BERD\\@NFDI,3,0 DAPHNE,5,0 DataPLANT,2,0 FAIRmat,5,0 ForumX,3,0 GHGA,1,0 KonsortSWD,3,0 MaRDI,4,0 NFDI4Agri,2,0 NFDI4BioDiversity,2,0 NFDI4Cat,5,0 NFDI4Chem,5,0 NFDI4Crime,2,0 NFDI4Culture,3,0 NFDI4Earth,2,0 NFDI4Health,1,0 NFDI4Ing,4,0 NFDI4MSE,5,0 NFDI4Medicine,1,0 NFDI4MobilTech,4,0 PAHN-PaN,5,0 Text+,3,0 ") nfdi_edges_2020 <- read.table( header=TRUE, sep=",", text=" from,to BERD\\@NFDI,KonsortSWD BERD\\@NFDI,MaRDI BERD\\@NFDI,NFDI4Memory BERD\\@NFDI,Text+ DAPHNE4NFDI,FAIRmat DAPHNE4NFDI,NFDI-MatWerk DAPHNE4NFDI,NFDI4Cat DAPHNE4NFDI,NFDI4Chem DAPHNE4NFDI,NFDI4Health DAPHNE4NFDI,NFDI4Ing DAPHNE4NFDI,NFDI4Objects DAPHNE4NFDI,PUNCH4NFDI FAIRmat,DAPHNE4NFDI FAIRmat,DataPLANT FAIRmat,MaRDI FAIRmat,NFDI-MatWerk FAIRmat,NFDI4Cat FAIRmat,NFDI4Chem FAIRmat,NFDI4DataScience FAIRmat,NFDI4Ing FAIRmat,NFDIxCS FAIRmat,PUNCH4NFDI MaRDI,BERD\\@NFDI MaRDI,FAIRmat MaRDI,NFDI-MatWerk MaRDI,NFDI-Neuro MaRDI,NFDI4Cat MaRDI,NFDI4Chem MaRDI,NFDI4Ing MaRDI,PUNCH4NFDI NFDI-MatWerk,DAPHNE4NFDI NFDI-MatWerk,DataPLANT NFDI-MatWerk,FAIRmat NFDI-MatWerk,MaRDI NFDI-MatWerk,NFDI4Chem NFDI-MatWerk,NFDI4DataScience NFDI-MatWerk,NFDI4Ing NFDI-MatWerk,NFDIxCS NFDI-Neuro,DataPLANT NFDI-Neuro,GHGA NFDI-Neuro,NFDI4BioDiversity NFDI-Neuro,NFDI4Culture NFDI-Neuro,NFDI4Earth NFDI-Neuro,NFDI4Health NFDI-Neuro,NFDI4Ing NFDI-Neuro,NFDI4Microbiota NFDI4Agri,DataPLANT NFDI4Agri,KonsortSWD NFDI4Agri,NFDI4BioDiversity NFDI4Agri,NFDI4Earth NFDI4Agri,NFDI4Health NFDI4Agri,NFDI4Immuno NFDI4Agri,NFDI4Microbiota NFDI4DataScience,KonsortSWD NFDI4DataScience,MaRDI NFDI4DataScience,NFDI-MatWerk NFDI4DataScience,NFDI4BioDiversity NFDI4DataScience,NFDI4Cat NFDI4DataScience,NFDI4Chem NFDI4DataScience,NFDI4Culture NFDI4DataScience,NFDI4Health NFDI4DataScience,NFDI4Ing NFDI4DataScience,NFDI4Microbiota NFDI4DataScience,NFDIxCS NFDI4Earth,DataPLANT NFDI4Earth,GHGA NFDI4Earth,KonsortSWD NFDI4Earth,NFDI4Agri NFDI4Earth,NFDI4BioDiversity NFDI4Earth,NFDI4Cat NFDI4Earth,NFDI4Chem NFDI4Earth,NFDI4Culture NFDI4Earth,NFDI4Health NFDI4Earth,NFDI4Ing NFDI4Earth,NFDI4Objects NFDI4Immuno,GHGA NFDI4Immuno,NFDI4Agri NFDI4Immuno,NFDI4Health NFDI4Immuno,NFDI4Microbiota NFDI4Memory,BERD\\@NFDI NFDI4Memory,KonsortSWD NFDI4Memory,MaRDI NFDI4Memory,NFDI4Culture NFDI4Memory,NFDI4Objects NFDI4Memory,Text+ NFDI4Microbiota,DataPLANT NFDI4Microbiota,GHGA NFDI4Microbiota,NFDI4Agri NFDI4Microbiota,NFDI4BioDiversity NFDI4Microbiota,NFDI4Chem NFDI4Microbiota,NFDI4DataScience NFDI4Microbiota,NFDI4Health NFDI4Microbiota,NFDI4Immuno NFDI4Microbiota,NFDI4Ing NFDI4Objects,KonsortSWD NFDI4Objects,NFDI4Agri NFDI4Objects,NFDI4BioDiversity NFDI4Objects,NFDI4Culture NFDI4Objects,NFDI4Earth NFDI4Objects,NFDI4Memory NFDI4Objects,Text+ NFDI4SD,NFDI4Culture NFDI4SD,NFDI4DataScience NFDI4SD,NFDI4Memory NFDI4SD,NFDI4Objects NFDIxCS,FAIRmat NFDIxCS,MaRDI NFDIxCS,NFDI4Chem NFDIxCS,NFDI4DataScience NFDIxCS,NFDI4Earth NFDIxCS,NFDI4Ing PUNCH4NFDI,DAPHNE4NFDI PUNCH4NFDI,FAIRmat PUNCH4NFDI,GHGA PUNCH4NFDI,MaRDI PUNCH4NFDI,NFDI4Earth PUNCH4NFDI,NFDI4Ing PUNCH4NFDI,NFDIxCS Text+,KonsortSWD Text+,NFDI4BioDiversity Text+,NFDI4Culture Text+,NFDI4Earth Text+,NFDI4Ing Text+,NFDI4Memory Text+,NFDI4Objects ") nfdi_nodes_2020 <- read.table( header=TRUE, sep=",", text=" name,group,funded BERD\\@NFDI,3,0 DAPHNE4NFDI,5,0 DataPLANT,2,1 FAIRmat,5,0 GHGA,1,1 KonsortSWD,3,1 MaRDI,4,0 NFDI-MatWerk,4,0 NFDI-Neuro,1,0 NFDI4Agri,2,0 NFDI4BioDiversity,2,1 NFDI4Cat,5,1 NFDI4Chem,5,1 NFDI4Culture,3,1 NFDI4DataScience,4,0 NFDI4Earth,2,0 NFDI4Health,1,1 NFDI4Immuno,1,0 NFDI4Ing,4,1 NFDI4Memory,3,0 NFDI4Microbiota,2,0 NFDI4Objects,3,0 NFDI4SD,3,0 NFDIxCS,4,0 PUNCH4NFDI,5,0 Text+,3,0 ") nfdi_edges <- function(nfdi_edges_year) { df <- get(paste0("nfdi_edges_",nfdi_edges_year)) # df print(tbl_df(df), n=Inf) } # nfdi_edges(2019) # nfdi_edges(2020) nfdi_edges(2019) nfdi_edges(2020) nfdi_funded <- function(nfdi_edges_year) { df <- data.frame(get(paste0("nfdi_nodes_",nfdi_edges_year))) names(df)[1] <- "Name" rownames(df) <- 1:nrow(df) df %>% select(1,3) } # nfdi_funded(2019) # nfdi_funded(2020) nfdi_plot<- function(nfdi_edges_year) { nfdi_presettings(nfdi_edges_year,FALSE) colrs <- c("#ffcc66","#acd69a") nfdi_local_network <- function() { plot(nfdi_network_year, vertex.color = colrs[V(nfdi_network_year)$funded + 1 ], vertex.frame.color = colrs[V(nfdi_network_year)$funded + 1 ] ) } pdf(paste0("network_",nfdi_edges_year,".pdf")) nfdi_local_network() dev.off() nfdi_local_network() } nfdi_plot(2019) nfdi_plot(2020) nfdi_group <- function(nfdi_edges_year) { df <- data.frame(get(paste0("nfdi_nodes_",nfdi_edges_year))) names(df)[1] <- "Name" rownames(df) <- 1:nrow(df) df %>% select(1,2) } # nfdi_group(2019) # nfdi_group(2020) nfdi_plot_legend <- function(){ legend("bottomright", # x-position title = "NFDI-Konferenzsystematik", # title legend = c( "(1)", "(2)", "(3)", "(4)", "(5)" ), # the text of the legend col = nfdi_color_code, # colors of lines and points beside the legend text pch = 20, # the plotting symbols appearing in the legend bty = "n", # no frame, the type of box to be drawn around the legend (n=no frame) cex = .75, # character expansion factor relative to current par("cex"). pt.cex = 2, # expansion factor(s) for the points ncol = 5, ) } nfdi_plot_group <- function(nfdi_edges_year) { nfdi_presettings(nfdi_edges_year,FALSE) pdf(paste0("network_group_",nfdi_edges_year,".pdf")) plot(nfdi_network_year) nfdi_plot_legend() dev.off() plot(nfdi_network_year) nfdi_plot_legend() } # nfdi_plot_group(2019) nfdi_plot_group(2020) nfdi_list_cluster <- function(nfdi_edges_year) { nfdi_presettings(nfdi_edges_year,TRUE) liste <- list(y=c(membership(cluster_optimal(nfdi_network_year)))) df = with(data=liste, expr=data.frame(y)) df <- cbind(Name = rownames(df), df) rownames(df) <- 1:nrow(df) names(df) <- c("Name","cluster") df } # nfdi_list_cluster(2019) # nfdi_list_cluster(2020) nfdi_plot_cluster <- function(nfdi_edges_year) { nfdi_presettings(nfdi_edges_year,FALSE) nfdi_network_year_cluster <- cluster_optimal(nfdi_network_year) nfdi_local_network <- function() { plot(nfdi_network_year_cluster, nfdi_network_year, edge.color = NA, col = nfdi_color_groups, #color of nodes mark.col = "grey", # color groups mark.border = NA, # no border color ) nfdi_plot_legend() } pdf(paste0("network_cluster_",nfdi_edges_year,".pdf")) nfdi_local_network() dev.off() nfdi_local_network() } # nfdi_plot_cluster(2019) nfdi_plot_cluster(2020) nfdi_plot_cluster_trans <- function(nfdi_edges_year) { nfdi_presettings(nfdi_edges_year,FALSE) nfdi_network_year_cluster <- cluster_optimal(nfdi_network_year) nfdi_local_network <- function() { plot(nfdi_network_year_cluster, nfdi_network_year, # loading data frame col = nfdi_color_groups, #color of nodes mark.col = "grey", # color groups mark.border = NA, # no border color edge.color = c(NA, "#bf4040")[crossing(nfdi_network_year_cluster, nfdi_network_year) + 1], # color of edges ) nfdi_plot_legend() } pdf(paste0("network_cluster_trans_",nfdi_edges_year,".pdf")) nfdi_local_network() dev.off() nfdi_local_network() } # nfdi_plot_cluster_trans(2019) nfdi_plot_cluster_trans(2020) nfdi_degree_total_filtered <- function(nfdi_edges_year) { nfdi_presettings(nfdi_edges_year,TRUE) df <- data.frame(degree(nfdi_network_year, mode = "total")) names(df)[1] <- "degree.total" df <- cbind(Name = rownames(df), df) rownames(df) <- 1:nrow(df) df } #nfdi_degree_total_filtered(2019) #nfdi_degree_total_filtered(2020) nfdi_degree_in <- function(nfdi_edges_year) { nfdi_presettings(nfdi_edges_year,TRUE) df <- data.frame(degree(nfdi_network_year, mode = "in")) names(df)[1] <- "degree.in" df <- cbind(Name = rownames(df), df) rownames(df) <- 1:nrow(df) df } # nfdi_degree_in(2019) # nfdi_degree_in(2020) nfdi_degree_out <- function(nfdi_edges_year) { nfdi_presettings(nfdi_edges_year,TRUE) df <- data.frame(degree(nfdi_network_year, mode = "out")) names(df)[1] <- "degree.out" df <- cbind(Name = rownames(df), df) rownames(df) <- 1:nrow(df) df } #nfdi_degree_out(2019) #nfdi_degree_out(2020) nfdi_betweenness <- function(nfdi_edges_year) { nfdi_presettings(nfdi_edges_year,TRUE) df <- data.frame(betweenness(nfdi_network_year, v=V(nfdi_network_year))) names(df)[1] <- "betweenness" df <- cbind(Name = rownames(df), df) rownames(df) <- 1:nrow(df) df } #nfdi_betweenness(2019) #nfdi_betweenness(2020) nfdi_closeness_total <- function(nfdi_edges_year) { nfdi_presettings(nfdi_edges_year,TRUE) df <- data.frame(closeness(nfdi_network_year, mode="total")) names(df)[1] <- "closeness.total" df <- cbind(Name = rownames(df), df) rownames(df) <- 1:nrow(df) df } #nfdi_closeness_total(2019) #nfdi_closeness_total(2020) nfdi_closeness_in <- function(nfdi_edges_year) { nfdi_presettings(nfdi_edges_year,TRUE) df <- data.frame(closeness(nfdi_network_year, mode="in")) names(df)[1] <- "closeness.in" df <- cbind(Name = rownames(df), df) rownames(df) <- 1:nrow(df) df } #nfdi_closeness_in(2019) #nfdi_closeness_in(2020) nfdi_closeness_out <- function(nfdi_edges_year) { nfdi_presettings(nfdi_edges_year,TRUE) df <- data.frame(closeness(nfdi_network_year, mode="out")) names(df)[1] <- "closeness.out" df <- cbind(Name = rownames(df), df) rownames(df) <- 1:nrow(df) df } #nfdi_closeness_out(2019) #nfdi_closeness_out(2020) nfdi_data_set <- function(nfdi_edges_year) { d1 <- nfdi_funded(nfdi_edges_year) d2 <- nfdi_group(nfdi_edges_year) d3 <- nfdi_list_cluster(nfdi_edges_year) d4 <- nfdi_degree_in(nfdi_edges_year) d5 <- nfdi_degree_out(nfdi_edges_year) d6 <- nfdi_degree_total_filtered(nfdi_edges_year) d7 <- nfdi_betweenness(nfdi_edges_year) d8 <- nfdi_closeness_in(nfdi_edges_year) d9 <- nfdi_closeness_out(nfdi_edges_year) d10 <-nfdi_closeness_total(nfdi_edges_year) df <- d1 %>% inner_join(d2, by = "Name") %>% full_join(d3, by = "Name") %>% full_join(d4, by = "Name") %>% full_join(d5, by = "Name") %>% full_join(d6, by = "Name") %>% full_join(d7, by = "Name") %>% full_join(d8, by = "Name") %>% full_join(d9, by = "Name") %>% full_join(d10, by = "Name") %>% arrange(Name) %>% replace(., is.na(.), "") write.csv(df, paste0("nfdi_data_set",nfdi_edges_year,".csv")) df } nfdi_data_set(2019) nfdi_data_set(2020) nfdi_count_edges_out <- function(nfdi_edges_year) { nfdi_presettings(nfdi_edges_year,TRUE) df <- as.data.frame(table(nfdi_edges$from)) df <- as.data.frame(df) names(df)[1] <- "Name" names(df)[2] <- "count" rownames(df) <- 1:nrow(df) df } #nfdi_count_edges_out(2019) #nfdi_count_edges_out(2020) wilcox.test(nfdi_count_edges_out(2019)$count, nfdi_count_edges_out(2020)$count, alternative="two.sided", exact=F, correct=T ) nfdi_count_LoI <- function(nfdi_edges_year) { nfdi_presettings(nfdi_edges_year,TRUE) sum(table(nfdi_count_edges_out(nfdi_edges_year))) } # nfdi_count_LoI(2019) # nfdi_count_LoI(2020) print(paste0(2019,": ",nfdi_count_LoI(2019))) print(paste0(2020,": ",nfdi_count_LoI(2020))) nfdi_count_nodes <- function(nfdi_edges_year) { nfdi_presettings(nfdi_edges_year,TRUE) gorder(nfdi_network_year) } #nfdi_count_nodes(2019) #nfdi_count_nodes(2020) print(paste0(2019,": ",nfdi_count_nodes(2019))) print(paste0(2020,": ",nfdi_count_nodes(2020))) nfdi_count_edges <- function(nfdi_edges_year) { nfdi_presettings(nfdi_edges_year,TRUE) gsize(nfdi_network_year) } #nfdi_count_edges(2019) #nfdi_count_edges(2020) print(paste0(2019,": ",nfdi_count_edges(2019))) print(paste0(2020,": ",nfdi_count_edges(2020)))