-
Notifications
You must be signed in to change notification settings - Fork 0
/
3000 write Table 2 subsystem.R
85 lines (61 loc) · 2.09 KB
/
3000 write Table 2 subsystem.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
rm(list = ls())
#################
# Notes #
#################
#Reading in GGMnonreg adjacency matrices.
#########################
# #
# Load packages #
# #
#########################
library(igraph)
library(ggplot2)
library(dplyr)
#########################
# #
# Load functions #
# #
#########################
#########################
# #
# Main Script #
# #
#########################
wd <- dirname(rstudioapi::getActiveDocumentContext()$path)
setwd(paste0(wd,"/Data"))
labels <- read.csv("Labelled Community strength sorted network resolution 1.csv")
names(labels)
labels$Group[labels$Group ==""] <- NA
table(labels$Group)
table(labels$community)
labels <- labels[labels$Label !="",]
labels <- dplyr::select(labels, c(community, Label,Group))
subsystems <- read.csv("linked data subsystems and 5 factors resolution 1.csv")
subsystems$community <- subsystems$Subsystem
head(labels, 16)
head(subsystems)
sort(labels$Label)
table.df <- left_join(subsystems,unique(labels) , by = "community")
dim(subsystems)
head(table.df)
dim(table.df)
table(table.df$Subsystem)
table.df$X <- NULL
table.df$Label <- gsub("Isolated component:", "", table.df$Label)
write.csv(table.df, file = "Table 3 Linked data subsystems and five factors.csv", row.names = F)
# table.df <- table.df %>%
# arrange(Group, desc(Number.of.factors))
#
# write.csv(table.df, file = "Table 2 linked data subsystems and five factors with three groups.csv", row.names = F)
df_filtered <- table.df %>%
arrange(Number.of.factors) %>%
distinct(Subsystem, .keep_all = TRUE)
table(table.df$Subsystem)
table(df_filtered$Subsystem)
df_filtered <- df_filtered[,c("Number.of.factors","Label","Group")]
df_filtered <- df_filtered %>%
arrange(Group, desc(Number.of.factors))
table(df_filtered$Label, df_filtered$Group)
df_filtered <- df_filtered[,c(2,1,3)]
names(df_filtered) <- c("Subsystem","'Number of factors'","Group")
write.csv(df_filtered, file = "Table 2 Subsystems by three groups.csv")