R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

Part VI. Bibliometric analysis - Conditions and Benefits

Load packages

library(statsr)
library(tidyverse)
library(readxl)
library(visNetwork)
library(igraph)
library(tidygraph)
library(ggraph)
library(formattable)

The data

# Let's load up the Authors data from excel file
benefit_list <- read_excel("Data.xlsx", sheet = "Benefits")
article_list <- read_excel("Data.xlsx", sheet = "Articles")
# Display Conditions by Article Count

benefit_list$StudyDesign <- factor(benefit_list$StudyDesign, levels = c("Randomised controlled trial" , "Non-randomised controlled trial", "Before and after study", "Descriptive cross-sectional studies", "Case series", "Case report", "Animal", "Cell", "Chemical"))

conditions_artcount <- benefit_list %>% 
  select(ArticleID, StudyDesign, Condition ) %>% distinct_all() %>%
  group_by(Condition, StudyDesign) %>% summarise(N = n()) %>% 
  mutate(n_Chemical = ifelse(as.numeric(StudyDesign) == 9, N, 0))%>%
  mutate(n_Cell = ifelse(as.numeric(StudyDesign) == 8, N, 0))%>%
  mutate(n_Animal = ifelse(as.numeric(StudyDesign) == 7, N, 0))%>%
  mutate(n_Observational = ifelse(as.numeric(StudyDesign) > 3 & as.numeric(StudyDesign) < 7, N, 0))%>%
  mutate(n_Interventional = ifelse(as.numeric(StudyDesign) <= 3, N, 0))%>%
  select(-c("StudyDesign")) %>%
  arrange(desc(N))
## `summarise()` has grouped output by 'Condition'. You can override using the
## `.groups` argument.
#conditions_artcount %>% arrange(Condition)
  
  
conditions_artcount  <-  conditions_artcount %>%
  group_by(Condition) %>% 
  summarise(Total = sum(N),Chem = sum(n_Chemical), Cell = sum(n_Cell), Animal = sum(n_Animal), H_O = sum(n_Observational), H_I = sum(n_Interventional)) %>% 
  arrange(desc(Total), desc(H_I),desc(H_O), desc(Animal), desc(Cell), desc(Chem) )
#conditions_artcount %>% arrange(Condition)
N_art = nrow(article_list)

conditions_artcount <- conditions_artcount %>% 
  mutate(Total_p = percent(Total /N_art) ) %>%
  mutate(Chem_p = percent(Chem /Total) ) %>%
  mutate(Cell_p = percent(Cell /Total) ) %>%
  mutate(Animal_p = percent(Animal /Total) ) %>%
  mutate(H_O_p = percent(H_O /Total) ) %>%
  mutate(H_I_p = percent(H_I /Total) ) %>% 
  select(c(1,2,8,3,9,4,10,5,11,6,12,7,13))
conditions_artcount
## # A tibble: 17 × 13
##    Condi…¹ Total Total_p  Chem Chem_p   Cell Cell_p Animal Anima…²   H_O H_O_p  
##    <chr>   <int> <formt> <dbl> <formt> <dbl> <form>  <dbl> <formt> <dbl> <formt>
##  1 Cancer     45 45.92%      0 0.00%       8 17.78%     12 26.67%     12 26.67% 
##  2 Health…    31 31.63%      1 3.23%      20 64.52%      7 22.58%      0 0.00%  
##  3 Hepati…     9 9.18%       0 0.00%       0 0.00%       7 77.78%      0 0.00%  
##  4 Geriat…     6 6.12%       0 0.00%       1 16.67%      1 16.67%      0 0.00%  
##  5 HIV         4 4.08%       0 0.00%       1 25.00%      0 0.00%       0 0.00%  
##  6 Allergy     4 4.08%       0 0.00%       0 0.00%       4 100.00%     0 0.00%  
##  7 Chroni…     3 3.06%       0 0.00%       0 0.00%       0 0.00%       0 0.00%  
##  8 Gastro…     3 3.06%       0 0.00%       0 0.00%       2 66.67%      0 0.00%  
##  9 Cold /…     2 2.04%       0 0.00%       0 0.00%       0 0.00%       0 0.00%  
## 10 Diabet…     2 2.04%       0 0.00%       0 0.00%       2 100.00%     0 0.00%  
## 11 Endoto…     2 2.04%       0 0.00%       0 0.00%       2 100.00%     0 0.00%  
## 12 Chemic…     1 1.02%       0 0.00%       0 0.00%       0 0.00%       0 0.00%  
## 13 Irrita…     1 1.02%       0 0.00%       0 0.00%       0 0.00%       0 0.00%  
## 14 Rheuma…     1 1.02%       0 0.00%       0 0.00%       0 0.00%       1 100.00%
## 15 Alzhei…     1 1.02%       0 0.00%       0 0.00%       1 100.00%     0 0.00%  
## 16 Bacter…     1 1.02%       0 0.00%       0 0.00%       1 100.00%     0 0.00%  
## 17 Oxidat…     1 1.02%       1 100.00%     0 0.00%       0 0.00%       0 0.00%  
## # … with 2 more variables: H_I <dbl>, H_I_p <formttbl>, and abbreviated
## #   variable names ¹​Condition, ²​Animal_p
# Condense the table
conditions_artcount <- conditions_artcount %>% mutate(precl = Chem+Cell+Animal, 
                                                      precl_p = Chem_p+Cell_p+Animal_p) %>%
  select(c(1,2,3, 14,15, 10,11,12,13))
conditions_artcount
## # A tibble: 17 × 9
##    Condition             Total Total_p precl precl_p   H_O H_O_p     H_I H_I_p  
##    <chr>                 <int> <formt> <dbl> <formt> <dbl> <formt> <dbl> <formt>
##  1 Cancer                   45 45.92%     20 44.44%     12 26.67%     13 28.89% 
##  2 Healthy / Nonspecific    31 31.63%     28 90.32%      0 0.00%       3 9.68%  
##  3 Hepatitis / Liver Di…     9 9.18%       7 77.78%      0 0.00%       2 22.22% 
##  4 Geriatric                 6 6.12%       2 33.33%      0 0.00%       4 66.67% 
##  5 HIV                       4 4.08%       1 25.00%      0 0.00%       3 75.00% 
##  6 Allergy                   4 4.08%       4 100.00%     0 0.00%       0 0.00%  
##  7 Chronic fatigue synd…     3 3.06%       0 0.00%       0 0.00%       3 100.00%
##  8 Gastroenteritis           3 3.06%       2 66.67%      0 0.00%       1 33.33% 
##  9 Cold / Flu                2 2.04%       0 0.00%       0 0.00%       2 100.00%
## 10 Diabetes mellitus         2 2.04%       2 100.00%     0 0.00%       0 0.00%  
## 11 Endotoxemia               2 2.04%       2 100.00%     0 0.00%       0 0.00%  
## 12 Chemical exposure         1 1.02%       0 0.00%       0 0.00%       1 100.00%
## 13 Irritable bowel synd…     1 1.02%       0 0.00%       0 0.00%       1 100.00%
## 14 Rheumatism                1 1.02%       0 0.00%       1 100.00%     0 0.00%  
## 15 Alzheimer's disease       1 1.02%       1 100.00%     0 0.00%       0 0.00%  
## 16 Bacterial infection       1 1.02%       1 100.00%     0 0.00%       0 0.00%  
## 17 Oxidative stress          1 1.02%       1 100.00%     0 0.00%       0 0.00%
# Display Beneficial Effects by Article Count

benefits_artcount <- benefit_list %>% 
  select(ArticleID, StudyDesign, BeneficialEffect ) %>% distinct_all() %>%
  group_by(BeneficialEffect, StudyDesign) %>% summarise(N = n()) %>% 
  mutate(n_Chemical = ifelse(as.numeric(StudyDesign) == 9, N, 0))%>%
  mutate(n_Cell = ifelse(as.numeric(StudyDesign) == 8, N, 0))%>%
  mutate(n_Animal = ifelse(as.numeric(StudyDesign) == 7, N, 0))%>%
  mutate(n_Observational = ifelse(as.numeric(StudyDesign) > 3 & as.numeric(StudyDesign) < 7, N, 0))%>%
  mutate(n_Interventional = ifelse(as.numeric(StudyDesign) <= 3, N, 0))%>%
  select(-c("StudyDesign")) %>%
  arrange(desc(N))
## `summarise()` has grouped output by 'BeneficialEffect'. You can override using
## the `.groups` argument.
benefits_artcount  <-  benefits_artcount %>%
  group_by(BeneficialEffect) %>% 
  summarise(Total = sum(N),Chem = sum(n_Chemical), Cell = sum(n_Cell), Animal = sum(n_Animal), H_O = sum(n_Observational), H_I = sum(n_Interventional)) %>% 
  arrange(desc(Total), desc(H_I),desc(H_O), desc(Animal), desc(Cell), desc(Chem) )

benefits_artcount <- benefits_artcount %>% 
  mutate(Total_p = percent(Total /N_art) ) %>%
  mutate(Chem_p = percent(Chem /Total) ) %>%
  mutate(Cell_p = percent(Cell /Total) ) %>%
  mutate(Animal_p = percent(Animal /Total) ) %>%
  mutate(H_O_p = percent(H_O /Total) ) %>%
  mutate(H_I_p = percent(H_I /Total) ) %>%
  select(c(1,2,8,3,9,4,10,5,11,6,12,7,13))
# Condense the table
benefits_artcount <- benefits_artcount %>% mutate(precl = Chem+Cell+Animal, 
                                                      precl_p = Chem_p+Cell_p+Animal_p) %>%
  select(c(1,2,3, 14,15, 10,11,12,13))
benefits_artcount %>% filter(Total>1)
## # A tibble: 16 × 9
##    BeneficialEffect       Total Total_p precl precl_p   H_O H_O_p    H_I H_I_p  
##    <chr>                  <int> <formt> <dbl> <formt> <dbl> <form> <dbl> <formt>
##  1 Immunomodulation          36 36.73%     21 58.33%      1 2.78%     14 38.89% 
##  2 Synergistic anticance…    19 19.39%      7 36.84%     10 52.63%     2 10.53% 
##  3 Hepatoprotection          13 13.27%     10 76.92%      1 7.69%      2 15.38% 
##  4 Anticancer                10 10.20%      9 90.00%      1 10.00%     0 0.00%  
##  5 Psychoneuroimmuno-mod…     8 8.16%       0 0.00%       2 25.00%     6 75.00% 
##  6 Antiinflammation           7 7.14%       6 85.71%      1 14.29%     0 0.00%  
##  7 Antioxidant                7 7.14%       7 100.00%     0 0.00%      0 0.00%  
##  8 Antiallergy                5 5.10%       5 100.00%     0 0.00%      0 0.00%  
##  9 Radioprotection            3 3.06%       2 66.67%      0 0.00%      1 33.33% 
## 10 Chemoprevention            3 3.06%       3 100.00%     0 0.00%      0 0.00%  
## 11 Antibacterial              3 3.06%       3 100.00%     0 0.00%      0 0.00%  
## 12 Antifatigue                2 2.04%       0 0.00%       0 0.00%      2 100.00%
## 13 Antiflu                    2 2.04%       0 0.00%       0 0.00%      2 100.00%
## 14 No significant effect      2 2.04%       0 0.00%       0 0.00%      2 100.00%
## 15 Gastroprotection           2 2.04%       1 50.00%      0 0.00%      1 50.00% 
## 16 Antihyperlipidemic ef…     2 2.04%       2 100.00%     0 0.00%      0 0.00%
benefits_artcount  %>% filter(Total > 1) 
## # A tibble: 16 × 9
##    BeneficialEffect       Total Total_p precl precl_p   H_O H_O_p    H_I H_I_p  
##    <chr>                  <int> <formt> <dbl> <formt> <dbl> <form> <dbl> <formt>
##  1 Immunomodulation          36 36.73%     21 58.33%      1 2.78%     14 38.89% 
##  2 Synergistic anticance…    19 19.39%      7 36.84%     10 52.63%     2 10.53% 
##  3 Hepatoprotection          13 13.27%     10 76.92%      1 7.69%      2 15.38% 
##  4 Anticancer                10 10.20%      9 90.00%      1 10.00%     0 0.00%  
##  5 Psychoneuroimmuno-mod…     8 8.16%       0 0.00%       2 25.00%     6 75.00% 
##  6 Antiinflammation           7 7.14%       6 85.71%      1 14.29%     0 0.00%  
##  7 Antioxidant                7 7.14%       7 100.00%     0 0.00%      0 0.00%  
##  8 Antiallergy                5 5.10%       5 100.00%     0 0.00%      0 0.00%  
##  9 Radioprotection            3 3.06%       2 66.67%      0 0.00%      1 33.33% 
## 10 Chemoprevention            3 3.06%       3 100.00%     0 0.00%      0 0.00%  
## 11 Antibacterial              3 3.06%       3 100.00%     0 0.00%      0 0.00%  
## 12 Antifatigue                2 2.04%       0 0.00%       0 0.00%      2 100.00%
## 13 Antiflu                    2 2.04%       0 0.00%       0 0.00%      2 100.00%
## 14 No significant effect      2 2.04%       0 0.00%       0 0.00%      2 100.00%
## 15 Gastroprotection           2 2.04%       1 50.00%      0 0.00%      1 50.00% 
## 16 Antihyperlipidemic ef…     2 2.04%       2 100.00%     0 0.00%      0 0.00%
benefits_artcount %>% filter(Total == 1) %>% select(BeneficialEffect) %>% arrange(BeneficialEffect)
## # A tibble: 13 × 1
##    BeneficialEffect        
##    <chr>                   
##  1 Antiangiogenesis        
##  2 Antiasthma              
##  3 Antihyperglycemic effect
##  4 Antimetastatic effect   
##  5 Antiretroviral          
##  6 Antirheumatic effect    
##  7 Antiviral               
##  8 Antiwasting             
##  9 Chemoprotection         
## 10 Endothelial improvement 
## 11 Memory enhancer         
## 12 Noncytotoxic            
## 13 Taste influencer
#Create network nodes from the conditions and benefits

cnodes <- conditions_artcount %>% select(Condition, Total) %>% 
  rename(label = Condition, value = Total) %>% 
  mutate(group =  "Condition") 
bnodes <- benefits_artcount %>% select(BeneficialEffect, Total) %>% 
  rename(label = BeneficialEffect, value = Total) %>% 
  mutate(group =  "Effect") 
nodes <- rbind(cnodes, bnodes) %>% 
  mutate(group = factor(group, levels=c("Condition", "Effect", "Outcome"))) %>%
  mutate(level = as.numeric(group)) %>%
  rowid_to_column("id")
nodes
## # A tibble: 46 × 5
##       id label                     value group     level
##    <int> <chr>                     <int> <fct>     <dbl>
##  1     1 Cancer                       45 Condition     1
##  2     2 Healthy / Nonspecific        31 Condition     1
##  3     3 Hepatitis / Liver Disease     9 Condition     1
##  4     4 Geriatric                     6 Condition     1
##  5     5 HIV                           4 Condition     1
##  6     6 Allergy                       4 Condition     1
##  7     7 Chronic fatigue syndrome      3 Condition     1
##  8     8 Gastroenteritis               3 Condition     1
##  9     9 Cold / Flu                    2 Condition     1
## 10    10 Diabetes mellitus             2 Condition     1
## # … with 36 more rows
# Edges are defined as the condition->effect within the same article with Study Design as the category
edges <- benefit_list %>% select(Condition, BeneficialEffect, StudyDesign) %>%
  rename(fromA = Condition, toA = BeneficialEffect, category = StudyDesign) %>% 
  left_join(nodes, by = c("fromA"= "label")) %>% rename(from=id) %>% 
  left_join(nodes, by = c("toA"= "label")) %>% rename(to=id) %>%
  select(from, to, category)
edges
## # A tibble: 138 × 3
##     from    to category                   
##    <int> <int> <fct>                      
##  1     2    18 Randomised controlled trial
##  2     1    21 Animal                     
##  3     6    25 Animal                     
##  4     2    46 Cell                       
##  5     2    24 Chemical                   
##  6     1    21 Animal                     
##  7     1    27 Animal                     
##  8     1    19 Animal                     
##  9     1    27 Animal                     
## 10     1    20 Animal                     
## # … with 128 more rows
# Display the raw network diagram
visNetwork(nodes, edges) 
#collapse the edges by creating a value to each edge based on count of co-occurance
edges1 <- edges %>% filter(from != to) %>% group_by(from, to, category) %>% summarise(value = n())
## `summarise()` has grouped output by 'from', 'to'. You can override using the
## `.groups` argument.
#cat_color_list <- c("#FF4040", "#FF1493",  "#FFA07A", "#EEAD0E", "#00FF00", "#CAFF70", "#C1FFC1","#7FFFD4", "#98F5FF")
cat_color_list <- c("#FF0000", "#FF0000",  "#FF0000", "#00FF00", "#00FF00", "#00FF00", "#00EEFF","#00EEFF", "#00EEFF")
cat_color_list <- data.frame(color = cat_color_list) %>%  rowid_to_column("id")
cat_color_list
##   id   color
## 1  1 #FF0000
## 2  2 #FF0000
## 3  3 #FF0000
## 4  4 #00FF00
## 5  5 #00FF00
## 6  6 #00FF00
## 7  7 #00EEFF
## 8  8 #00EEFF
## 9  9 #00EEFF
edges1 <- edges1 %>% mutate(cat = as.numeric(category)) %>%
  left_join(cat_color_list, by = c("cat"= "id"))
edges1
## # A tibble: 75 × 6
## # Groups:   from, to [54]
##     from    to category                    value   cat color  
##    <int> <int> <fct>                       <int> <dbl> <chr>  
##  1     1    18 Randomised controlled trial     2     1 #FF0000
##  2     1    18 Before and after study          4     3 #FF0000
##  3     1    18 Case series                     1     5 #00FF00
##  4     1    18 Animal                          1     7 #00EEFF
##  5     1    19 Randomised controlled trial     2     1 #FF0000
##  6     1    19 Case series                     3     5 #00FF00
##  7     1    19 Case report                     7     6 #00FF00
##  8     1    19 Animal                          2     7 #00EEFF
##  9     1    19 Cell                            5     8 #00EEFF
## 10     1    20 Case series                     1     5 #00FF00
## # … with 65 more rows
# Define node size based on the value 
nodes <- nodes %>% mutate(font.size = 20+(value)/2)
# Plot the network 

visNetwork(nodes, edges1, width="100%", height="800") %>% 
   visNodes(scaling = list(min = 5, max = 35), borderWidth=0) %>% 
  visEdges(arrows = "to", scaling = list(min = 1, max = 10)) %>% 
  visPhysics(stabilization= FALSE, solver = "forceAtlas2Based")
#  visIgraphLayout()
visNetwork(nodes, edges1) %>%  
  visEdges(arrows = "to", smooth = TRUE, color=edges1$category) %>% 
  visHierarchicalLayout(direction = "LR")%>% 
  visNodes(scaling = list(min = 10, max = 20), borderWidth=0, shape = "dot")
# Types of cancer investigated
cancer_p <- benefit_list %>% filter(Condition == "Cancer" & !is.na(PrimarySite)) %>%
  select(PrimarySite, StudyDesign) %>% rename(site = PrimarySite)
cancer_s <- benefit_list %>% filter(Condition == "Cancer" & !is.na(SecondarySite)) %>%
  select(SecondarySite, StudyDesign) %>% rename(site = SecondarySite)
Cancer_sites <- rbind(cancer_p, cancer_s)  %>%
  group_by(site, StudyDesign) %>% summarise(N=n()) %>% arrange(desc(N))
## `summarise()` has grouped output by 'site'. You can override using the
## `.groups` argument.
Cancer_sites
## # A tibble: 31 × 3
## # Groups:   site [16]
##    site        StudyDesign                     N
##    <chr>       <fct>                       <int>
##  1 Breast      Cell                            4
##  2 Liver       Animal                          4
##  3 Various     Before and after study          4
##  4 Breast      Case series                     3
##  5 Head & Neck Randomised controlled trial     3
##  6 Liver       Case series                     3
##  7 Various     Case series                     3
##  8 Blood       Cell                            2
##  9 Lung        Case report                     2
## 10 Ovary       Case report                     2
## # … with 21 more rows
# Display Cancer Site by Article Count


cancer_p <- benefit_list %>% filter(Condition == "Cancer" & !is.na(PrimarySite)) %>%
  select(ArticleID, PrimarySite, StudyDesign) %>% rename(Site = PrimarySite)
cancer_s <- benefit_list %>% filter(Condition == "Cancer" & !is.na(SecondarySite)) %>%
  select(ArticleID, SecondarySite, StudyDesign) %>% rename(Site = SecondarySite)
Cancer_sites <- rbind(cancer_p, cancer_s) %>% distinct_all()


Cancer_sites_artcount <- Cancer_sites %>% 
  group_by(Site, StudyDesign) %>% summarise(N = n()) %>% 
  mutate(n_Chemical = ifelse(as.numeric(StudyDesign) == 9, N, 0))%>%
  mutate(n_Cell = ifelse(as.numeric(StudyDesign) == 8, N, 0))%>%
  mutate(n_Animal = ifelse(as.numeric(StudyDesign) == 7, N, 0))%>%
  mutate(n_Observational = ifelse(as.numeric(StudyDesign) > 3 & as.numeric(StudyDesign) < 7, N, 0))%>%
  mutate(n_Interventional = ifelse(as.numeric(StudyDesign) <= 3, N, 0))%>%
  select(-c("StudyDesign")) %>%
  arrange(desc(N))
## `summarise()` has grouped output by 'Site'. You can override using the
## `.groups` argument.
Cancer_sites_artcount  <-  Cancer_sites_artcount %>%
  group_by(Site) %>% 
  summarise(Total = sum(N),Chem = sum(n_Chemical), Cell = sum(n_Cell), Animal = sum(n_Animal), H_O = sum(n_Observational), H_I = sum(n_Interventional)) %>% 
  arrange(desc(Total), desc(H_I),desc(H_O), desc(Animal), desc(Cell), desc(Chem) )

cancer_art_list <- benefit_list %>% filter(Condition == "Cancer") %>% select(ArticleID) %>% distinct()
N_cancer_art = nrow(cancer_art_list)

Cancer_sites_artcount <- Cancer_sites_artcount %>% 
  mutate(Total_p = percent(Total /N_cancer_art) ) %>%
  mutate(Chem_p = percent(Chem /Total) ) %>%
  mutate(Cell_p = percent(Cell /Total) ) %>%
  mutate(Animal_p = percent(Animal /Total) ) %>%
  mutate(H_O_p = percent(H_O /Total) ) %>%
  mutate(H_I_p = percent(H_I /Total) ) %>%
  select(c(1,2,8,3,9,4,10,5,11,6,12,7,13))

Cancer_sites_artcount
## # A tibble: 16 × 13
##    Site    Total Total_p  Chem Chem_p  Cell Cell_p  Animal Anima…¹   H_O H_O_p  
##    <chr>   <int> <formt> <dbl> <form> <dbl> <formt>  <dbl> <formt> <dbl> <formt>
##  1 Various     9 20.00%      0 0.00%      0 0.00%        0 0.00%       2 22.22% 
##  2 Breast      8 17.78%      0 0.00%      4 50.00%       0 0.00%       3 37.50% 
##  3 Liver       5 11.11%      0 0.00%      0 0.00%        2 40.00%      2 40.00% 
##  4 Blood       4 8.89%       0 0.00%      2 50.00%       0 0.00%       0 0.00%  
##  5 Colore…     2 4.44%       0 0.00%      0 0.00%        0 0.00%       2 100.00%
##  6 Lung        2 4.44%       0 0.00%      0 0.00%        0 0.00%       2 100.00%
##  7 Ovary       2 4.44%       0 0.00%      0 0.00%        0 0.00%       2 100.00%
##  8 Stomach     2 4.44%       0 0.00%      0 0.00%        1 50.00%      1 50.00% 
##  9 Skin        2 4.44%       0 0.00%      1 50.00%       0 0.00%       1 50.00% 
## 10 Cervic…     1 2.22%       0 0.00%      0 0.00%        0 0.00%       0 0.00%  
## 11 Head &…     1 2.22%       0 0.00%      0 0.00%        0 0.00%       0 0.00%  
## 12 Bile d…     1 2.22%       0 0.00%      0 0.00%        0 0.00%       1 100.00%
## 13 Pancre…     1 2.22%       0 0.00%      0 0.00%        0 0.00%       1 100.00%
## 14 Umbili…     1 2.22%       0 0.00%      0 0.00%        0 0.00%       1 100.00%
## 15 Uterus      1 2.22%       0 0.00%      0 0.00%        0 0.00%       1 100.00%
## 16 Prosta…     1 2.22%       0 0.00%      1 100.00%      0 0.00%       0 0.00%  
## # … with 2 more variables: H_I <dbl>, H_I_p <formttbl>, and abbreviated
## #   variable name ¹​Animal_p
# Condense the table
Cancer_sites_artcount <- Cancer_sites_artcount %>% mutate(precl = Chem+Cell+Animal, 
                                                      precl_p = Chem_p+Cell_p+Animal_p) %>%
  select(c(1,2,3, 14,15, 10,11,12,13))
Cancer_sites_artcount
## # A tibble: 16 × 9
##    Site        Total Total_p    precl precl_p      H_O H_O_p        H_I H_I_p   
##    <chr>       <int> <formttbl> <dbl> <formttbl> <dbl> <formttbl> <dbl> <formtt>
##  1 Various         9 20.00%         0 0.00%          2 22.22%         7 77.78%  
##  2 Breast          8 17.78%         4 50.00%         3 37.50%         1 12.50%  
##  3 Liver           5 11.11%         2 40.00%         2 40.00%         1 20.00%  
##  4 Blood           4 8.89%          2 50.00%         0 0.00%          2 50.00%  
##  5 Colorectal      2 4.44%          0 0.00%          2 100.00%        0 0.00%   
##  6 Lung            2 4.44%          0 0.00%          2 100.00%        0 0.00%   
##  7 Ovary           2 4.44%          0 0.00%          2 100.00%        0 0.00%   
##  8 Stomach         2 4.44%          1 50.00%         1 50.00%         0 0.00%   
##  9 Skin            2 4.44%          1 50.00%         1 50.00%         0 0.00%   
## 10 Cervical        1 2.22%          0 0.00%          0 0.00%          1 100.00% 
## 11 Head & Neck     1 2.22%          0 0.00%          0 0.00%          1 100.00% 
## 12 Bile duct       1 2.22%          0 0.00%          1 100.00%        0 0.00%   
## 13 Pancreatic      1 2.22%          0 0.00%          1 100.00%        0 0.00%   
## 14 Umbilical       1 2.22%          0 0.00%          1 100.00%        0 0.00%   
## 15 Uterus          1 2.22%          0 0.00%          1 100.00%        0 0.00%   
## 16 Prostate        1 2.22%          1 100.00%        0 0.00%          0 0.00%
# create a new list of nodes from the column names row 10 to 36
onodes <- benefit_list %>% colnames()
onodes <- onodes[c(10:35)] 
onodes <- data.frame(label = onodes, group="Outcome", level=3)
onodes
##                         label   group level
## 1                  Mast cells Outcome     3
## 2                 Macrophages Outcome     3
## 3                 Neutrophils Outcome     3
## 4             Dendritic Cells Outcome     3
## 5                 T & B Cells Outcome     3
## 6        Natural Killer Cells Outcome     3
## 7                 Eosinophils Outcome     3
## 8                 Lymphocytes Outcome     3
## 9                   Cytokines Outcome     3
## 10    Nitric Oxide Production Outcome     3
## 11       Cancer Proliferation Outcome     3
## 12              Tumor Markers Outcome     3
## 13                  Apoptosis Outcome     3
## 14            Gene Expression Outcome     3
## 15            Immunoglobulins Outcome     3
## 16                  Histamine Outcome     3
## 17       Inflammatory Markers Outcome     3
## 18      Hematopoietic tissues Outcome     3
## 19   Oxidative Stress Markers Outcome     3
## 20              Survival Rate Outcome     3
## 21             Incidence Rate Outcome     3
## 22         Treatment Response Outcome     3
## 23 Quality of Life Assessment Outcome     3
## 24         Chemo Side Effects Outcome     3
## 25     Liver Function Markers Outcome     3
## 26    Safety & Adverse Events Outcome     3
# Create edges as a data frame 
edges2 <- data.frame(fromA= character(0), toA= character(0), cond = character(0), art =  character(0), cat = numeric(0) )

# Edges are defined through iterating the co-occurrence of a beneficial effect and an outcome  
for (a in unique(benefit_list$BeneficialEffect)) {
  i_list <- benefit_list %>% filter(BeneficialEffect == a)
  len <- nrow(i_list)
  for(l in c(10:35)) {
    n <- names(benefit_list)[l]
    for (i in c(1:len)) {
      if (!is.na(i_list[i,l]) & i_list[i,l] == "Yes") {
        new <- c(a, n, i_list[i, 5], i_list[i, 1],  i_list[i, 4])
        edges2[nrow(edges2) + 1,] <- new
      }
    }
  }
}
edges2
##                             fromA                        toA
## 1                Immunomodulation                Macrophages
## 2                Immunomodulation                Macrophages
## 3                Immunomodulation                Macrophages
## 4                Immunomodulation                Macrophages
## 5                Immunomodulation                Macrophages
## 6                Immunomodulation                Macrophages
## 7                Immunomodulation                Macrophages
## 8                Immunomodulation                Macrophages
## 9                Immunomodulation                Macrophages
## 10               Immunomodulation                Macrophages
## 11               Immunomodulation                Macrophages
## 12               Immunomodulation                Macrophages
## 13               Immunomodulation                Macrophages
## 14               Immunomodulation                Neutrophils
## 15               Immunomodulation            Dendritic Cells
## 16               Immunomodulation            Dendritic Cells
## 17               Immunomodulation            Dendritic Cells
## 18               Immunomodulation            Dendritic Cells
## 19               Immunomodulation            Dendritic Cells
## 20               Immunomodulation                T & B Cells
## 21               Immunomodulation                T & B Cells
## 22               Immunomodulation                T & B Cells
## 23               Immunomodulation                T & B Cells
## 24               Immunomodulation                T & B Cells
## 25               Immunomodulation                T & B Cells
## 26               Immunomodulation                T & B Cells
## 27               Immunomodulation                T & B Cells
## 28               Immunomodulation                T & B Cells
## 29               Immunomodulation                T & B Cells
## 30               Immunomodulation       Natural Killer Cells
## 31               Immunomodulation       Natural Killer Cells
## 32               Immunomodulation       Natural Killer Cells
## 33               Immunomodulation       Natural Killer Cells
## 34               Immunomodulation       Natural Killer Cells
## 35               Immunomodulation       Natural Killer Cells
## 36               Immunomodulation       Natural Killer Cells
## 37               Immunomodulation       Natural Killer Cells
## 38               Immunomodulation       Natural Killer Cells
## 39               Immunomodulation       Natural Killer Cells
## 40               Immunomodulation       Natural Killer Cells
## 41               Immunomodulation       Natural Killer Cells
## 42               Immunomodulation       Natural Killer Cells
## 43               Immunomodulation       Natural Killer Cells
## 44               Immunomodulation       Natural Killer Cells
## 45               Immunomodulation                Lymphocytes
## 46               Immunomodulation                Lymphocytes
## 47               Immunomodulation                Lymphocytes
## 48               Immunomodulation                Lymphocytes
## 49               Immunomodulation                Lymphocytes
## 50               Immunomodulation                  Cytokines
## 51               Immunomodulation                  Cytokines
## 52               Immunomodulation                  Cytokines
## 53               Immunomodulation                  Cytokines
## 54               Immunomodulation                  Cytokines
## 55               Immunomodulation                  Cytokines
## 56               Immunomodulation                  Cytokines
## 57               Immunomodulation                  Cytokines
## 58               Immunomodulation                  Cytokines
## 59               Immunomodulation                  Cytokines
## 60               Immunomodulation                  Cytokines
## 61               Immunomodulation                  Cytokines
## 62               Immunomodulation                  Cytokines
## 63               Immunomodulation    Nitric Oxide Production
## 64               Immunomodulation    Nitric Oxide Production
## 65               Immunomodulation    Nitric Oxide Production
## 66               Immunomodulation    Nitric Oxide Production
## 67               Immunomodulation              Tumor Markers
## 68               Immunomodulation            Gene Expression
## 69               Immunomodulation            Gene Expression
## 70               Immunomodulation       Inflammatory Markers
## 71               Immunomodulation       Inflammatory Markers
## 72               Immunomodulation              Survival Rate
## 73               Immunomodulation              Survival Rate
## 74               Immunomodulation         Treatment Response
## 75               Immunomodulation Quality of Life Assessment
## 76               Immunomodulation     Liver Function Markers
## 77               Immunomodulation     Liver Function Markers
## 78               Immunomodulation     Liver Function Markers
## 79               Immunomodulation    Safety & Adverse Events
## 80               Immunomodulation    Safety & Adverse Events
## 81               Immunomodulation    Safety & Adverse Events
## 82               Immunomodulation    Safety & Adverse Events
## 83               Immunomodulation    Safety & Adverse Events
## 84               Immunomodulation    Safety & Adverse Events
## 85               Immunomodulation    Safety & Adverse Events
## 86                     Anticancer       Natural Killer Cells
## 87                     Anticancer       Natural Killer Cells
## 88                     Anticancer                  Cytokines
## 89                     Anticancer                  Cytokines
## 90                     Anticancer       Cancer Proliferation
## 91                     Anticancer       Cancer Proliferation
## 92                     Anticancer       Cancer Proliferation
## 93                     Anticancer       Cancer Proliferation
## 94                     Anticancer       Cancer Proliferation
## 95                     Anticancer       Cancer Proliferation
## 96                     Anticancer       Cancer Proliferation
## 97                     Anticancer       Cancer Proliferation
## 98                     Anticancer       Cancer Proliferation
## 99                     Anticancer                  Apoptosis
## 100                    Anticancer                  Apoptosis
## 101                    Anticancer            Gene Expression
## 102                    Anticancer            Gene Expression
## 103                    Anticancer   Oxidative Stress Markers
## 104                    Anticancer              Survival Rate
## 105                    Anticancer              Survival Rate
## 106                    Anticancer              Survival Rate
## 107                    Anticancer              Survival Rate
## 108                    Anticancer              Survival Rate
## 109                    Anticancer    Safety & Adverse Events
## 110                   Antiallergy                 Mast cells
## 111                   Antiallergy                 Mast cells
## 112                   Antiallergy                 Mast cells
## 113                   Antiallergy                 Mast cells
## 114                   Antiallergy                Eosinophils
## 115                   Antiallergy                  Cytokines
## 116                   Antiallergy                  Cytokines
## 117                   Antiallergy            Immunoglobulins
## 118                   Antiallergy            Immunoglobulins
## 119                   Antiallergy                  Histamine
## 120                   Antiallergy                  Histamine
## 121                   Antiallergy       Inflammatory Markers
## 122                   Antiallergy       Inflammatory Markers
## 123                  Noncytotoxic    Safety & Adverse Events
## 124                   Antioxidant                  Cytokines
## 125                   Antioxidant       Cancer Proliferation
## 126                   Antioxidant                  Apoptosis
## 127                   Antioxidant                  Apoptosis
## 128                   Antioxidant            Gene Expression
## 129                   Antioxidant            Gene Expression
## 130                   Antioxidant       Inflammatory Markers
## 131                   Antioxidant       Inflammatory Markers
## 132                   Antioxidant      Hematopoietic tissues
## 133                   Antioxidant   Oxidative Stress Markers
## 134                   Antioxidant   Oxidative Stress Markers
## 135                   Antioxidant   Oxidative Stress Markers
## 136                   Antioxidant   Oxidative Stress Markers
## 137                   Antioxidant   Oxidative Stress Markers
## 138                   Antioxidant   Oxidative Stress Markers
## 139                   Antioxidant     Liver Function Markers
## 140               Chemoprevention                Lymphocytes
## 141               Chemoprevention       Cancer Proliferation
## 142               Chemoprevention       Cancer Proliferation
## 143               Chemoprevention       Cancer Proliferation
## 144               Chemoprevention                  Apoptosis
## 145               Chemoprevention                  Apoptosis
## 146               Chemoprevention            Gene Expression
## 147               Chemoprevention       Inflammatory Markers
## 148               Chemoprevention       Inflammatory Markers
## 149               Chemoprevention             Incidence Rate
## 150               Chemoprevention     Liver Function Markers
## 151               Chemoprevention     Liver Function Markers
## 152 Synergistic anticancer effect       Cancer Proliferation
## 153 Synergistic anticancer effect       Cancer Proliferation
## 154 Synergistic anticancer effect       Cancer Proliferation
## 155 Synergistic anticancer effect       Cancer Proliferation
## 156 Synergistic anticancer effect       Cancer Proliferation
## 157 Synergistic anticancer effect       Cancer Proliferation
## 158 Synergistic anticancer effect       Cancer Proliferation
## 159 Synergistic anticancer effect       Cancer Proliferation
## 160 Synergistic anticancer effect       Cancer Proliferation
## 161 Synergistic anticancer effect              Tumor Markers
## 162 Synergistic anticancer effect              Tumor Markers
## 163 Synergistic anticancer effect              Tumor Markers
## 164 Synergistic anticancer effect              Tumor Markers
## 165 Synergistic anticancer effect              Tumor Markers
## 166 Synergistic anticancer effect              Tumor Markers
## 167 Synergistic anticancer effect              Tumor Markers
## 168 Synergistic anticancer effect                  Apoptosis
## 169 Synergistic anticancer effect                  Apoptosis
## 170 Synergistic anticancer effect                  Apoptosis
## 171 Synergistic anticancer effect                  Apoptosis
## 172 Synergistic anticancer effect                  Apoptosis
## 173 Synergistic anticancer effect                  Apoptosis
## 174 Synergistic anticancer effect            Gene Expression
## 175 Synergistic anticancer effect            Gene Expression
## 176 Synergistic anticancer effect            Gene Expression
## 177 Synergistic anticancer effect              Survival Rate
## 178 Synergistic anticancer effect              Survival Rate
## 179 Synergistic anticancer effect              Survival Rate
## 180 Synergistic anticancer effect              Survival Rate
## 181 Synergistic anticancer effect              Survival Rate
## 182 Synergistic anticancer effect              Survival Rate
## 183 Synergistic anticancer effect              Survival Rate
## 184 Synergistic anticancer effect              Survival Rate
## 185 Synergistic anticancer effect              Survival Rate
## 186 Synergistic anticancer effect              Survival Rate
## 187 Synergistic anticancer effect             Incidence Rate
## 188 Synergistic anticancer effect         Treatment Response
## 189 Synergistic anticancer effect         Treatment Response
## 190 Synergistic anticancer effect         Treatment Response
## 191 Synergistic anticancer effect         Treatment Response
## 192 Synergistic anticancer effect         Treatment Response
## 193 Synergistic anticancer effect         Treatment Response
## 194 Synergistic anticancer effect         Treatment Response
## 195 Synergistic anticancer effect         Treatment Response
## 196 Synergistic anticancer effect         Treatment Response
## 197 Synergistic anticancer effect Quality of Life Assessment
## 198 Synergistic anticancer effect Quality of Life Assessment
## 199 Synergistic anticancer effect Quality of Life Assessment
## 200 Synergistic anticancer effect Quality of Life Assessment
## 201 Synergistic anticancer effect Quality of Life Assessment
## 202 Synergistic anticancer effect Quality of Life Assessment
## 203 Synergistic anticancer effect     Liver Function Markers
## 204 Synergistic anticancer effect     Liver Function Markers
## 205 Synergistic anticancer effect    Safety & Adverse Events
## 206              Hepatoprotection                Lymphocytes
## 207              Hepatoprotection                  Cytokines
## 208              Hepatoprotection                  Cytokines
## 209              Hepatoprotection                  Cytokines
## 210              Hepatoprotection                  Cytokines
## 211              Hepatoprotection              Tumor Markers
## 212              Hepatoprotection                  Apoptosis
## 213              Hepatoprotection            Gene Expression
## 214              Hepatoprotection            Gene Expression
## 215              Hepatoprotection            Gene Expression
## 216              Hepatoprotection       Inflammatory Markers
## 217              Hepatoprotection       Inflammatory Markers
## 218              Hepatoprotection       Inflammatory Markers
## 219              Hepatoprotection       Inflammatory Markers
## 220              Hepatoprotection       Inflammatory Markers
## 221              Hepatoprotection   Oxidative Stress Markers
## 222              Hepatoprotection              Survival Rate
## 223              Hepatoprotection         Treatment Response
## 224              Hepatoprotection Quality of Life Assessment
## 225              Hepatoprotection Quality of Life Assessment
## 226              Hepatoprotection     Liver Function Markers
## 227              Hepatoprotection     Liver Function Markers
## 228              Hepatoprotection     Liver Function Markers
## 229              Hepatoprotection     Liver Function Markers
## 230              Hepatoprotection     Liver Function Markers
## 231              Hepatoprotection     Liver Function Markers
## 232              Hepatoprotection     Liver Function Markers
## 233              Hepatoprotection     Liver Function Markers
## 234              Hepatoprotection     Liver Function Markers
## 235              Hepatoprotection     Liver Function Markers
## 236              Hepatoprotection     Liver Function Markers
## 237              Hepatoprotection     Liver Function Markers
## 238              Hepatoprotection     Liver Function Markers
## 239              Hepatoprotection    Safety & Adverse Events
## 240              Hepatoprotection    Safety & Adverse Events
## 241         No significant effect    Safety & Adverse Events
## 242         No significant effect    Safety & Adverse Events
## 243  Psychoneuroimmuno-modulation       Natural Killer Cells
## 244  Psychoneuroimmuno-modulation                  Cytokines
## 245  Psychoneuroimmuno-modulation              Tumor Markers
## 246  Psychoneuroimmuno-modulation              Survival Rate
## 247  Psychoneuroimmuno-modulation         Treatment Response
## 248  Psychoneuroimmuno-modulation         Treatment Response
## 249  Psychoneuroimmuno-modulation Quality of Life Assessment
## 250  Psychoneuroimmuno-modulation Quality of Life Assessment
## 251  Psychoneuroimmuno-modulation Quality of Life Assessment
## 252  Psychoneuroimmuno-modulation Quality of Life Assessment
## 253  Psychoneuroimmuno-modulation Quality of Life Assessment
## 254  Psychoneuroimmuno-modulation Quality of Life Assessment
## 255  Psychoneuroimmuno-modulation Quality of Life Assessment
## 256  Psychoneuroimmuno-modulation Quality of Life Assessment
## 257  Psychoneuroimmuno-modulation         Chemo Side Effects
## 258  Psychoneuroimmuno-modulation         Chemo Side Effects
## 259  Psychoneuroimmuno-modulation    Safety & Adverse Events
## 260  Psychoneuroimmuno-modulation    Safety & Adverse Events
## 261                       Antiflu             Incidence Rate
## 262                       Antiflu             Incidence Rate
## 263                       Antiflu         Treatment Response
## 264                       Antiflu         Treatment Response
## 265                   Antiwasting         Chemo Side Effects
## 266                   Antiwasting    Safety & Adverse Events
## 267               Memory enhancer            Gene Expression
## 268               Memory enhancer       Inflammatory Markers
## 269               Memory enhancer   Oxidative Stress Markers
## 270                 Antibacterial                Neutrophils
## 271                 Antibacterial                T & B Cells
## 272                 Antibacterial                Lymphocytes
## 273                 Antibacterial                  Cytokines
## 274                 Antibacterial                  Cytokines
## 275                 Antibacterial              Survival Rate
## 276                 Antibacterial         Treatment Response
## 277                 Antibacterial     Liver Function Markers
## 278               Radioprotection                  Apoptosis
## 279               Radioprotection       Inflammatory Markers
## 280               Radioprotection      Hematopoietic tissues
## 281               Radioprotection   Oxidative Stress Markers
## 282               Radioprotection   Oxidative Stress Markers
## 283               Radioprotection         Chemo Side Effects
## 284               Radioprotection    Safety & Adverse Events
## 285              Antiinflammation                 Mast cells
## 286              Antiinflammation                Lymphocytes
## 287              Antiinflammation                  Cytokines
## 288              Antiinflammation                  Cytokines
## 289              Antiinflammation                  Cytokines
## 290              Antiinflammation                  Apoptosis
## 291              Antiinflammation            Gene Expression
## 292              Antiinflammation       Inflammatory Markers
## 293              Antiinflammation       Inflammatory Markers
## 294              Antiinflammation       Inflammatory Markers
## 295              Antiinflammation       Inflammatory Markers
## 296              Antiinflammation       Inflammatory Markers
## 297              Antiinflammation       Inflammatory Markers
## 298              Antiinflammation   Oxidative Stress Markers
## 299              Antiinflammation              Survival Rate
## 300              Antiinflammation         Treatment Response
## 301              Antiinflammation Quality of Life Assessment
## 302              Antiinflammation     Liver Function Markers
## 303              Antiinflammation     Liver Function Markers
## 304          Antirheumatic effect       Inflammatory Markers
## 305          Antirheumatic effect         Treatment Response
## 306          Antirheumatic effect Quality of Life Assessment
## 307              Gastroprotection         Chemo Side Effects
## 308              Gastroprotection         Chemo Side Effects
## 309              Gastroprotection    Safety & Adverse Events
## 310              Gastroprotection    Safety & Adverse Events
## 311               Chemoprotection              Survival Rate
## 312               Chemoprotection             Incidence Rate
## 313               Chemoprotection     Liver Function Markers
## 314                    Antiasthma                Eosinophils
## 315                    Antiasthma                  Histamine
## 316                    Antiasthma       Inflammatory Markers
## 317                   Antifatigue         Treatment Response
## 318                   Antifatigue         Treatment Response
## 319       Endothelial improvement    Nitric Oxide Production
## 320         Antimetastatic effect              Tumor Markers
## 321                     Antiviral         Treatment Response
## 322                     Antiviral Quality of Life Assessment
## 323                     Antiviral     Liver Function Markers
## 324                     Antiviral    Safety & Adverse Events
##                          cond                          art cat
## 1       Healthy / Nonspecific           Chae et al. (2004)   8
## 2       Healthy / Nonspecific    Ghoneum & Matsuura (2004)   8
## 3       Healthy / Nonspecific           Kang et al. (2022)   8
## 4       Healthy / Nonspecific      Kim D.J. et al. (2011b)   7
## 5       Healthy / Nonspecific       Kim H.Y. et al. (2005)   7
## 6       Healthy / Nonspecific       Kim H.Y. et al. (2005)   8
## 7       Healthy / Nonspecific       Kim S.P. et al. (2013)   8
## 8       Healthy / Nonspecific       Kim S.P. et al. (2014)   8
## 9       Healthy / Nonspecific       Kim S.P. et al. (2018)   8
## 10      Healthy / Nonspecific     Miura et al. (2004/2013)   8
## 11      Healthy / Nonspecific Pérez-Martínez et al. (2015)   8
## 12                     Cancer Pérez-Martínez et al. (2015)   7
## 13      Healthy / Nonspecific             Yu et al. (2004)   8
## 14                     Cancer      Golombick et al. (2016)   3
## 15      Healthy / Nonspecific      Cholujova et al. (2009)   8
## 16                     Cancer      Cholujova et al. (2013)   1
## 17      Healthy / Nonspecific     Ghoneum & Agrawal (2011)   8
## 18      Healthy / Nonspecific     Ghoneum & Agrawal (2014)   8
## 19      Healthy / Nonspecific       Kim S.P. et al. (2014)   8
## 20      Healthy / Nonspecific            Bae et al. (2004)   7
## 21      Healthy / Nonspecific           Chae et al. (2004)   8
## 22      Healthy / Nonspecific     Ghoneum & Agrawal (2011)   8
## 23      Healthy / Nonspecific     Ghoneum & Agrawal (2014)   8
## 24                     Cancer       Ghoneum & Brown (1999)   3
## 25                     Cancer               Ghoneum (1999)   3
## 26      Healthy / Nonspecific          Giese et al. (2008)   7
## 27      Healthy / Nonspecific           Kang et al. (2022)   8
## 28      Healthy / Nonspecific       Kim H.Y. et al. (2005)   8
## 29                     Cancer        Lissoni et al. (2008)   3
## 30      Healthy / Nonspecific            Ali et al. (2012)   1
## 31                     Cancer      Cholujova et al. (2013)   1
## 32                  Geriatric         Elsaid et al. (2018)   1
## 33                  Geriatric         Elsaid et al. (2021)   1
## 34                  Geriatric       Ghoneum & Abedi (2004)   7
## 35                  Geriatric       Ghoneum & Abedi (2004)   8
## 36                     Cancer       Ghoneum & Brown (1999)   3
## 37      Healthy / Nonspecific      Ghoneum & Jewett (2000)   8
## 38      Healthy / Nonspecific              Ghoneum (1998b)   3
## 39                     Cancer               Ghoneum (1999)   3
## 40          Chemical exposure               Ghoneum (1999)   3
## 41      Healthy / Nonspecific          Giese et al. (2008)   7
## 42   Irritable bowel syndrome         Kamiya et al. (2014)   1
## 43      Healthy / Nonspecific Pérez-Martínez et al. (2015)   8
## 44                     Cancer Pérez-Martínez et al. (2015)   7
## 45   Irritable bowel syndrome         Kamiya et al. (2014)   1
## 46      Healthy / Nonspecific      Kim D.J. et al. (2011b)   7
## 47      Healthy / Nonspecific       Kim H.Y. et al. (2005)   7
## 48                        HIV         Lewis et al. (2020b)   1
## 49                     Cancer        Lissoni et al. (2008)   3
## 50      Healthy / Nonspecific            Ali et al. (2012)   1
## 51      Healthy / Nonspecific           Chae et al. (2004)   8
## 52      Healthy / Nonspecific           Choi et al. (2014)   1
## 53                     Cancer      Cholujova et al. (2013)   1
## 54      Healthy / Nonspecific     Ghoneum & Agrawal (2011)   8
## 55      Healthy / Nonspecific     Ghoneum & Agrawal (2014)   8
## 56      Healthy / Nonspecific      Ghoneum & Jewett (2000)   8
## 57      Healthy / Nonspecific    Ghoneum & Matsuura (2004)   8
## 58      Healthy / Nonspecific              Ghoneum (1998b)   3
## 59      Healthy / Nonspecific          Giese et al. (2008)   7
## 60      Healthy / Nonspecific           Kang et al. (2022)   8
## 61      Healthy / Nonspecific      Kim D.J. et al. (2011b)   7
## 62      Healthy / Nonspecific       Kim S.P. et al. (2018)   8
## 63      Healthy / Nonspecific           Chae et al. (2004)   8
## 64      Healthy / Nonspecific    Ghoneum & Matsuura (2004)   8
## 65      Healthy / Nonspecific           Kang et al. (2022)   8
## 66      Healthy / Nonspecific       Kim S.P. et al. (2018)   8
## 67                     Cancer               Okamura (2004)   5
## 68                  Geriatric         Elsaid et al. (2021)   1
## 69      Healthy / Nonspecific       Kim S.P. et al. (2018)   8
## 70                     Cancer      Golombick et al. (2016)   3
## 71   Irritable bowel syndrome         Kamiya et al. (2014)   1
## 72                     Cancer       Ghoneum & Brown (1999)   3
## 73                     Cancer               Okamura (2004)   5
## 74   Irritable bowel syndrome         Kamiya et al. (2014)   1
## 75                     Cancer               Okamura (2004)   5
## 76                  Geriatric         Elsaid et al. (2018)   1
## 77                        HIV         Lewis et al. (2020b)   1
## 78                     Cancer               Okamura (2004)   5
## 79      Healthy / Nonspecific            Ali et al. (2012)   1
## 80      Healthy / Nonspecific           Choi et al. (2014)   1
## 81                  Geriatric         Elsaid et al. (2021)   1
## 82      Healthy / Nonspecific              Ghoneum (1998b)   3
## 83                     Cancer           Itoh et al. (2015)   1
## 84   Irritable bowel syndrome         Kamiya et al. (2014)   1
## 85                        HIV         Lewis et al. (2020b)   1
## 86                     Cancer    Badr El-Din et al. (2008)   7
## 87                     Cancer       Kim H.Y. et al. (2007)   7
## 88                     Cancer    Badr El-Din et al. (2008)   7
## 89                     Cancer        Ghoneum et al. (2000)   8
## 90                     Cancer                    An (2011)   7
## 91                     Cancer    Badr El-Din et al. (2008)   7
## 92                     Cancer            Bae et al. (2004)   7
## 93                     Cancer          Brush et al. (2010)   8
## 94                     Cancer        Ghoneum et al. (2000)   8
## 95                     Cancer      Kim D.J. et al. (2011a)   7
## 96                     Cancer       Kim H.Y. et al. (2007)   7
## 97                     Cancer         Markus et al. (2006)   6
## 98                     Cancer         Noaman et al. (2008)   7
## 99                     Cancer   Ghoneum & Gollapudi (2003)   8
## 100                    Cancer         Noaman et al. (2008)   7
## 101                    Cancer   Ghoneum & Gollapudi (2003)   8
## 102                    Cancer         Noaman et al. (2008)   7
## 103                    Cancer         Noaman et al. (2008)   7
## 104                    Cancer                    An (2011)   7
## 105                    Cancer            Bae et al. (2004)   7
## 106                    Cancer      Kim D.J. et al. (2011a)   7
## 107                    Cancer       Kim H.Y. et al. (2007)   7
## 108                    Cancer         Markus et al. (2006)   6
## 109                    Cancer    Badr El-Din et al. (2008)   7
## 110                   Allergy                    An (2011)   7
## 111                   Allergy            Bae et al. (2004)   7
## 112     Healthy / Nonspecific        Hoshino et al. (2010)   8
## 113     Healthy / Nonspecific      Kim D.J. et al. (2011a)   8
## 114                   Allergy     Kambayashi & Endo (2002)   7
## 115                   Allergy                    An (2011)   7
## 116     Healthy / Nonspecific        Hoshino et al. (2010)   8
## 117                   Allergy                    An (2011)   7
## 118                   Allergy            Bae et al. (2004)   7
## 119                   Allergy            Bae et al. (2004)   7
## 120                   Allergy     Kambayashi & Endo (2002)   7
## 121     Healthy / Nonspecific        Hoshino et al. (2010)   8
## 122                   Allergy     Kambayashi & Endo (2002)   7
## 123     Healthy / Nonspecific                    An (2011)   8
## 124               Endotoxemia       Kim S.P. et al. (2013)   7
## 125                    Cancer         Noaman et al. (2008)   7
## 126                    Cancer         Noaman et al. (2008)   7
## 127           Gastroenteritis           Zhao et al. (2020)   7
## 128       Alzheimer's disease    Ghoneum & El Sayed (2021)   7
## 129                    Cancer         Noaman et al. (2008)   7
## 130       Alzheimer's disease    Ghoneum & El Sayed (2021)   7
## 131           Gastroenteritis           Zhao et al. (2020)   7
## 132     Healthy / Nonspecific        Ghoneum et al. (2013)   7
## 133       Alzheimer's disease    Ghoneum & El Sayed (2021)   7
## 134     Healthy / Nonspecific        Ghoneum et al. (2013)   7
## 135               Endotoxemia       Kim S.P. et al. (2013)   7
## 136                    Cancer         Noaman et al. (2008)   7
## 137          Oxidative stress         Tazawa et al. (2000)   9
## 138           Gastroenteritis           Zhao et al. (2020)   7
## 139               Endotoxemia       Kim S.P. et al. (2013)   7
## 140                    Cancer   Badr El-Din et al. (2016a)   7
## 141                    Cancer   Badr El-Din et al. (2016a)   7
## 142                    Cancer   Badr El-Din et al. (2016c)   7
## 143                    Cancer    Badr El-Din et al. (2020)   7
## 144                    Cancer   Badr El-Din et al. (2016a)   7
## 145                    Cancer    Badr El-Din et al. (2020)   7
## 146                    Cancer    Badr El-Din et al. (2020)   7
## 147                    Cancer   Badr El-Din et al. (2016c)   7
## 148                    Cancer    Badr El-Din et al. (2020)   7
## 149                    Cancer   Badr El-Din et al. (2016a)   7
## 150                    Cancer   Badr El-Din et al. (2016c)   7
## 151                    Cancer    Badr El-Din et al. (2020)   7
## 152                    Cancer   Badr El-Din et al. (2016b)   7
## 153                    Cancer    Badr El-Din et al. (2019)   7
## 154                    Cancer        Ghoneum et al. (2014)   8
## 155                    Cancer       Hajtó  & Kirsch (2013)   5
## 156                    Cancer                 Hajtó (2017)   6
## 157                    Cancer                 Hajtó (2018)   6
## 158                    Cancer          Hajtó et al. (2015)   6
## 159                    Cancer         Hajtó et al. (2016a)   6
## 160                    Cancer              Kaketani (2004)   6
## 161                    Cancer           Bang et al. (2010)   1
## 162                    Cancer       Hajtó  & Kirsch (2013)   5
## 163                    Cancer                 Hajtó (2017)   6
## 164                    Cancer                 Hajtó (2018)   6
## 165                    Cancer            Meshitsuka (2013)   6
## 166                    Cancer               Okamura (2004)   5
## 167                    Cancer             Tsunekawa (2004)   5
## 168                    Cancer   Badr El-Din et al. (2016b)   7
## 169                    Cancer    Badr El-Din et al. (2019)   7
## 170                    Cancer  Ghoneum & Gollapudi (2005a)   8
## 171                    Cancer  Ghoneum & Gollapudi (2005b)   8
## 172                    Cancer   Ghoneum & Gollapudi (2011)   8
## 173                    Cancer        Ghoneum et al. (2014)   8
## 174                    Cancer   Badr El-Din et al. (2016b)   7
## 175                    Cancer    Badr El-Din et al. (2019)   7
## 176                    Cancer   Ghoneum & Gollapudi (2011)   8
## 177                    Cancer           Bang et al. (2010)   1
## 178                    Cancer        Ghoneum et al. (2014)   8
## 179                    Cancer   Gollapudi & Ghoneum (2008)   8
## 180                    Cancer       Hajtó  & Kirsch (2013)   5
## 181                    Cancer          Hajtó et al. (2015)   6
## 182                    Cancer         Hajtó et al. (2016a)   6
## 183                    Cancer              Kaketani (2004)   6
## 184                    Cancer                 Kawai (2004)   6
## 185                    Cancer               Okamura (2004)   5
## 186                    Cancer             Tsunekawa (2004)   5
## 187                    Cancer           Bang et al. (2010)   1
## 188                    Cancer           Bang et al. (2010)   1
## 189                    Cancer       Hajtó  & Kirsch (2013)   5
## 190                    Cancer                 Hajtó (2017)   6
## 191                    Cancer                 Hajtó (2018)   6
## 192                    Cancer          Hajtó et al. (2015)   6
## 193                    Cancer         Hajtó et al. (2016a)   6
## 194                    Cancer              Kaketani (2004)   6
## 195                    Cancer            Meshitsuka (2013)   6
## 196                    Cancer          Tan & Flores (2020)   1
## 197                    Cancer       Hajtó  & Kirsch (2013)   5
## 198                    Cancer          Hajtó et al. (2015)   6
## 199                    Cancer         Hajtó et al. (2016a)   6
## 200                    Cancer                 Kawai (2004)   6
## 201                    Cancer               Okamura (2004)   5
## 202                    Cancer             Tsunekawa (2004)   5
## 203                    Cancer       Hajtó  & Kirsch (2013)   5
## 204                    Cancer               Okamura (2004)   5
## 205                    Cancer           Bang et al. (2010)   1
## 206 Hepatitis / Liver Disease         Lewis et al. (2020c)   1
## 207 Hepatitis / Liver Disease       Egashira et al. (2013)   7
## 208 Hepatitis / Liver Disease       Kim S.P. et al. (2013)   7
## 209 Hepatitis / Liver Disease         Lewis et al. (2020c)   1
## 210 Hepatitis / Liver Disease         Zheng et al. (2012a)   7
## 211                    Cancer               Okamura (2004)   5
## 212                    Cancer    Badr El-Din et al. (2020)   7
## 213                    Cancer    Badr El-Din et al. (2020)   7
## 214 Hepatitis / Liver Disease          Chung et al. (2015)   7
## 215 Hepatitis / Liver Disease         Zheng et al. (2012b)   7
## 216                    Cancer   Badr El-Din et al. (2016c)   7
## 217                    Cancer    Badr El-Din et al. (2020)   7
## 218 Hepatitis / Liver Disease          Chung et al. (2015)   7
## 219 Hepatitis / Liver Disease       Egashira et al. (2013)   7
## 220 Hepatitis / Liver Disease         Zheng et al. (2012b)   7
## 221 Hepatitis / Liver Disease       Kim S.P. et al. (2013)   7
## 222                    Cancer               Okamura (2004)   5
## 223 Hepatitis / Liver Disease         Salama et al. (2016)   1
## 224                    Cancer               Okamura (2004)   5
## 225 Hepatitis / Liver Disease         Salama et al. (2016)   1
## 226                    Cancer   Badr El-Din et al. (2016c)   7
## 227                    Cancer    Badr El-Din et al. (2020)   7
## 228     Healthy / Nonspecific          Chung et al. (2015)   8
## 229 Hepatitis / Liver Disease          Chung et al. (2015)   7
## 230 Hepatitis / Liver Disease          Daizo et al. (2001)   7
## 231 Hepatitis / Liver Disease       Egashira et al. (2013)   7
## 232 Hepatitis / Liver Disease       Kim S.P. et al. (2013)   7
## 233 Hepatitis / Liver Disease         Lewis et al. (2020c)   1
## 234                    Cancer               Okamura (2004)   5
## 235 Hepatitis / Liver Disease         Salama et al. (2016)   1
## 236 Hepatitis / Liver Disease         Yamada et al. (2002)   7
## 237 Hepatitis / Liver Disease         Zheng et al. (2012a)   7
## 238 Hepatitis / Liver Disease         Zheng et al. (2012b)   7
## 239 Hepatitis / Liver Disease         Lewis et al. (2020c)   1
## 240 Hepatitis / Liver Disease         Salama et al. (2016)   1
## 241                       HIV         Cadden et al. (2020)   1
## 242  Chronic fatigue syndrome      McDermott et al. (2006)   1
## 243                    Cancer       Takahara & Sano (2004)   1
## 244                    Cancer        Kim J.M. et al.(2020)   2
## 245                    Cancer             Tsunekawa (2004)   5
## 246                    Cancer             Tsunekawa (2004)   5
## 247                    Cancer         Hajtó et al. (2016b)   4
## 248                    Cancer       Takahara & Sano (2004)   1
## 249                 Geriatric         Elsaid et al. (2020)   1
## 250                    Cancer         Hajtó et al. (2016b)   4
## 251                    Cancer        Kim J.M. et al.(2020)   2
## 252                    Cancer         Masood et al. (2013)   1
## 253                    Cancer      Petrovics et al. (2016)   1
## 254                    Cancer       Takahara & Sano (2004)   1
## 255                    Cancer          Tan & Flores (2020)   1
## 256                    Cancer             Tsunekawa (2004)   5
## 257                    Cancer         Hajtó et al. (2016b)   4
## 258                    Cancer         Masood et al. (2013)   1
## 259                    Cancer         Hajtó et al. (2016b)   4
## 260                    Cancer         Masood et al. (2013)   1
## 261                Cold / Flu         Elsaid et al. (2021)   1
## 262                Cold / Flu         Tazawa et al. (2003)   1
## 263                Cold / Flu         Elsaid et al. (2021)   1
## 264                Cold / Flu         Tazawa et al. (2003)   1
## 265     Healthy / Nonspecific     Endo & Kanbayashi (2003)   7
## 266     Healthy / Nonspecific     Endo & Kanbayashi (2003)   7
## 267       Alzheimer's disease    Ghoneum & El Sayed (2021)   7
## 268       Alzheimer's disease    Ghoneum & El Sayed (2021)   7
## 269       Alzheimer's disease    Ghoneum & El Sayed (2021)   7
## 270     Healthy / Nonspecific        Ghoneum et al. (2008)   8
## 271       Bacterial infection       Kim S.P. et al. (2014)   7
## 272       Bacterial infection       Kim S.P. et al. (2014)   7
## 273     Healthy / Nonspecific        Ghoneum et al. (2008)   8
## 274       Bacterial infection       Kim S.P. et al. (2014)   7
## 275       Bacterial infection       Kim S.P. et al. (2014)   7
## 276           Gastroenteritis       Kim S.P. et al. (2018)   7
## 277       Bacterial infection       Kim S.P. et al. (2014)   7
## 278           Gastroenteritis           Zhao et al. (2020)   7
## 279           Gastroenteritis           Zhao et al. (2020)   7
## 280     Healthy / Nonspecific        Ghoneum et al. (2013)   7
## 281     Healthy / Nonspecific        Ghoneum et al. (2013)   7
## 282           Gastroenteritis           Zhao et al. (2020)   7
## 283                    Cancer          Tan & Flores (2020)   1
## 284                    Cancer          Tan & Flores (2020)   1
## 285     Healthy / Nonspecific        Hoshino et al. (2010)   8
## 286                   Allergy      Kim D.J. et al. (2011a)   7
## 287     Healthy / Nonspecific        Hoshino et al. (2010)   8
## 288               Endotoxemia           Sudo et al. (2001)   7
## 289 Hepatitis / Liver Disease         Zheng et al. (2012a)   7
## 290           Gastroenteritis           Zhao et al. (2020)   7
## 291 Hepatitis / Liver Disease         Zheng et al. (2012b)   7
## 292     Healthy / Nonspecific        Hoshino et al. (2010)   8
## 293                Rheumatism             Ichihashi (2004)   5
## 294                   Allergy      Kim D.J. et al. (2011a)   7
## 295               Endotoxemia           Sudo et al. (2001)   7
## 296           Gastroenteritis           Zhao et al. (2020)   7
## 297 Hepatitis / Liver Disease         Zheng et al. (2012b)   7
## 298           Gastroenteritis           Zhao et al. (2020)   7
## 299               Endotoxemia           Sudo et al. (2001)   7
## 300                Rheumatism             Ichihashi (2004)   5
## 301                Rheumatism             Ichihashi (2004)   5
## 302 Hepatitis / Liver Disease         Zheng et al. (2012a)   7
## 303 Hepatitis / Liver Disease         Zheng et al. (2012b)   7
## 304                Rheumatism             Ichihashi (2004)   5
## 305                Rheumatism             Ichihashi (2004)   5
## 306                Rheumatism             Ichihashi (2004)   5
## 307           Gastroenteritis           Itoh et al. (2015)   1
## 308     Healthy / Nonspecific         Jacoby et al. (2001)   7
## 309           Gastroenteritis           Itoh et al. (2015)   1
## 310     Healthy / Nonspecific         Jacoby et al. (2001)   7
## 311     Healthy / Nonspecific         Jacoby et al. (2001)   7
## 312     Healthy / Nonspecific         Jacoby et al. (2001)   7
## 313     Healthy / Nonspecific         Jacoby et al. (2001)   7
## 314                   Allergy     Kambayashi & Endo (2002)   7
## 315                   Allergy     Kambayashi & Endo (2002)   7
## 316                   Allergy     Kambayashi & Endo (2002)   7
## 317  Chronic fatigue syndrome                Kenyon (2001)   3
## 318  Chronic fatigue syndrome      Petrovics et al. (2016)   1
## 319                       HIV         Lewis et al. (2020a)   1
## 320                    Cancer      Pescatore et al. (2022)   3
## 321 Hepatitis / Liver Disease         Salama et al. (2016)   1
## 322 Hepatitis / Liver Disease         Salama et al. (2016)   1
## 323 Hepatitis / Liver Disease         Salama et al. (2016)   1
## 324 Hepatitis / Liver Disease         Salama et al. (2016)   1
#calculate the value of outcome nodes using the edges
edges2_dist <- edges2 %>% select(toA, art, cat) %>% distinct_all()
lonodes <- onodes %>% left_join(edges2_dist, by = c("label" = "toA")) %>%
  group_by(label, group,  level, cat) %>% summarise(value = n()) %>% 
  arrange(desc(value))
## `summarise()` has grouped output by 'label', 'group', 'level'. You can override
## using the `.groups` argument.
lonodes
## # A tibble: 80 × 5
## # Groups:   label, group, level [26]
##    label                   group   level   cat value
##    <chr>                   <chr>   <dbl> <dbl> <int>
##  1 Safety & Adverse Events Outcome     3     1    13
##  2 Cancer Proliferation    Outcome     3     7    11
##  3 Liver Function Markers  Outcome     3     7    11
##  4 Cytokines               Outcome     3     8    10
##  5 Inflammatory Markers    Outcome     3     7    10
##  6 Macrophages             Outcome     3     8    10
##  7 Cytokines               Outcome     3     7     9
##  8 Treatment Response      Outcome     3     1     8
##  9 Gene Expression         Outcome     3     7     7
## 10 Survival Rate           Outcome     3     7     7
## # … with 70 more rows
outcome_list_artcount <- lonodes %>% select(label, N=value, cat) %>% 
  mutate(n_Chemical = ifelse(cat == 9, N, 0))%>%
  mutate(n_Cell = ifelse(cat == 8, N, 0))%>%
  mutate(n_Animal = ifelse(cat == 7, N, 0))%>%
  mutate(n_Observational = ifelse(cat > 3 & cat < 7, N, 0))%>%
  mutate(n_Interventional = ifelse(cat <= 3, N, 0))%>%
  select(-c("cat")) %>%
  arrange(desc(N))
## Adding missing grouping variables: `group`, `level`
outcome_list_artcount  <-  outcome_list_artcount %>%
  group_by(label) %>% 
  summarise(Total = sum(N),Chem = sum(n_Chemical), Cell = sum(n_Cell), Animal = sum(n_Animal), H_O = sum(n_Observational), H_I = sum(n_Interventional)) %>% 
  arrange(desc(Total), desc(H_I),desc(H_O), desc(Animal), desc(Cell), desc(Chem) )



outcome_list_artcount <- outcome_list_artcount %>% 
  mutate(Total_p = percent(Total /N_art) ) %>%
  mutate(Chem_p = percent(Chem /Total) ) %>%
  mutate(Cell_p = percent(Cell /Total) ) %>%
  mutate(Animal_p = percent(Animal /Total) ) %>%
  mutate(H_O_p = percent(H_O /Total) ) %>%
  mutate(H_I_p = percent(H_I /Total) ) %>%
  select(c(1,2,8,3,9,4,10,5,11,6,12,7,13))
outcome_list_artcount
## # A tibble: 26 × 13
##    label     Total Total_p  Chem Chem_p  Cell Cell_p Animal Anima…¹   H_O H_O_p 
##    <chr>     <int> <formt> <dbl> <form> <dbl> <form>  <dbl> <formt> <dbl> <form>
##  1 Cytokines    25 25.51%      0 0.00%     10 40.00%      9 36.00%      0 0.00% 
##  2 Cancer P…    21 21.43%      0 0.00%      3 14.29%     11 52.38%      7 33.33%
##  3 Safety &…    19 19.39%      0 0.00%      1 5.26%       3 15.79%      1 5.26% 
##  4 Treatmen…    19 19.39%      0 0.00%      0 0.00%       1 5.26%       9 47.37%
##  5 Survival…    19 19.39%      0 0.00%      2 10.53%      7 36.84%      8 42.11%
##  6 Liver Fu…    18 18.37%      0 0.00%      1 5.56%      11 61.11%      2 11.11%
##  7 Natural …    17 17.35%      0 0.00%      3 17.65%      5 29.41%      0 0.00% 
##  8 Quality …    15 15.31%      0 0.00%      0 0.00%       0 0.00%       8 53.33%
##  9 Inflamma…    14 14.29%      0 0.00%      1 7.14%      10 71.43%      1 7.14% 
## 10 Macropha…    13 13.27%      0 0.00%     10 76.92%      3 23.08%      0 0.00% 
## # … with 16 more rows, 2 more variables: H_I <dbl>, H_I_p <formttbl>, and
## #   abbreviated variable name ¹​Animal_p
# Condense the table
outcome_list_artcount <- outcome_list_artcount %>% mutate(precl = Chem+Cell+Animal, 
                                                      precl_p = Chem_p+Cell_p+Animal_p) %>%
  select(c(1,2,3, 14,15, 10,11,12,13))
outcome_list_artcount
## # A tibble: 26 × 9
##    label                   Total Total_p precl precl_p   H_O H_O_p    H_I H_I_p 
##    <chr>                   <int> <formt> <dbl> <formt> <dbl> <form> <dbl> <form>
##  1 Cytokines                  25 25.51%     19 76.00%      0 0.00%      6 24.00%
##  2 Cancer Proliferation       21 21.43%     14 66.67%      7 33.33%     0 0.00% 
##  3 Safety & Adverse Events    19 19.39%      4 21.05%      1 5.26%     14 73.68%
##  4 Treatment Response         19 19.39%      1 5.26%       9 47.37%     9 47.37%
##  5 Survival Rate              19 19.39%      9 47.37%      8 42.11%     2 10.53%
##  6 Liver Function Markers     18 18.37%     12 66.67%      2 11.11%     4 22.22%
##  7 Natural Killer Cells       17 17.35%      8 47.06%      0 0.00%      9 52.94%
##  8 Quality of Life Assess…    15 15.31%      0 0.00%       8 53.33%     7 46.67%
##  9 Inflammatory Markers       14 14.29%     11 78.57%      1 7.14%      2 14.29%
## 10 Macrophages                13 13.27%     13 100.00%     0 0.00%      0 0.00% 
## # … with 16 more rows
# Combined Beneficial effects and Positive outcomes

lonodes <- lonodes %>% group_by(label, group) %>% summarise(value = sum(value)) %>% arrange(desc(value)) %>% 
  mutate(group = factor(group, levels=c("Condition", "Effect", "Outcome"))) %>%
  mutate(level = as.numeric(group)) %>%  
  rowid_to_column("id") %>% 
  mutate(id = id + nrow(nodes)) %>% 
  mutate(font.size = 20+(value)/2)
## `summarise()` has grouped output by 'label'. You can override using the
## `.groups` argument.
lonodes
## # A tibble: 26 × 6
## # Groups:   label [26]
##       id label                      group   value level font.size
##    <int> <chr>                      <fct>   <int> <dbl>     <dbl>
##  1    47 Cytokines                  Outcome    25     3      32.5
##  2    48 Cancer Proliferation       Outcome    21     3      30.5
##  3    49 Safety & Adverse Events    Outcome    19     3      29.5
##  4    50 Survival Rate              Outcome    19     3      29.5
##  5    51 Treatment Response         Outcome    19     3      29.5
##  6    52 Liver Function Markers     Outcome    18     3      29  
##  7    53 Natural Killer Cells       Outcome    17     3      28.5
##  8    54 Quality of Life Assessment Outcome    15     3      27.5
##  9    55 Inflammatory Markers       Outcome    14     3      27  
## 10    56 Macrophages                Outcome    13     3      26.5
## # … with 16 more rows
all_nodes <- rbind(nodes, lonodes)
all_nodes
## # A tibble: 72 × 6
##       id label                     value group     level font.size
##    <int> <chr>                     <int> <fct>     <dbl>     <dbl>
##  1     1 Cancer                       45 Condition     1      42.5
##  2     2 Healthy / Nonspecific        31 Condition     1      35.5
##  3     3 Hepatitis / Liver Disease     9 Condition     1      24.5
##  4     4 Geriatric                     6 Condition     1      23  
##  5     5 HIV                           4 Condition     1      22  
##  6     6 Allergy                       4 Condition     1      22  
##  7     7 Chronic fatigue syndrome      3 Condition     1      21.5
##  8     8 Gastroenteritis               3 Condition     1      21.5
##  9     9 Cold / Flu                    2 Condition     1      21  
## 10    10 Diabetes mellitus             2 Condition     1      21  
## # … with 62 more rows
# Edges are defined as the effect->outcome within the same article with Study Design as the category


edges2 <- edges2 %>% left_join(all_nodes, by = c("fromA"= "label")) %>% rename(from=id)
edges2 <- edges2 %>% left_join(all_nodes, by = c("toA"= "label")) %>% rename(to=id)
edges2 <- edges2 %>% select(from, to, cat, cond)
edges2
##     from to cat                      cond
## 1     18 56   8     Healthy / Nonspecific
## 2     18 56   8     Healthy / Nonspecific
## 3     18 56   8     Healthy / Nonspecific
## 4     18 56   7     Healthy / Nonspecific
## 5     18 56   7     Healthy / Nonspecific
## 6     18 56   8     Healthy / Nonspecific
## 7     18 56   8     Healthy / Nonspecific
## 8     18 56   8     Healthy / Nonspecific
## 9     18 56   8     Healthy / Nonspecific
## 10    18 56   8     Healthy / Nonspecific
## 11    18 56   8     Healthy / Nonspecific
## 12    18 56   7                    Cancer
## 13    18 56   8     Healthy / Nonspecific
## 14    18 70   3                    Cancer
## 15    18 64   8     Healthy / Nonspecific
## 16    18 64   1                    Cancer
## 17    18 64   8     Healthy / Nonspecific
## 18    18 64   8     Healthy / Nonspecific
## 19    18 64   8     Healthy / Nonspecific
## 20    18 59   7     Healthy / Nonspecific
## 21    18 59   8     Healthy / Nonspecific
## 22    18 59   8     Healthy / Nonspecific
## 23    18 59   8     Healthy / Nonspecific
## 24    18 59   3                    Cancer
## 25    18 59   3                    Cancer
## 26    18 59   7     Healthy / Nonspecific
## 27    18 59   8     Healthy / Nonspecific
## 28    18 59   8     Healthy / Nonspecific
## 29    18 59   3                    Cancer
## 30    18 53   1     Healthy / Nonspecific
## 31    18 53   1                    Cancer
## 32    18 53   1                 Geriatric
## 33    18 53   1                 Geriatric
## 34    18 53   7                 Geriatric
## 35    18 53   8                 Geriatric
## 36    18 53   3                    Cancer
## 37    18 53   8     Healthy / Nonspecific
## 38    18 53   3     Healthy / Nonspecific
## 39    18 53   3                    Cancer
## 40    18 53   3         Chemical exposure
## 41    18 53   7     Healthy / Nonspecific
## 42    18 53   1  Irritable bowel syndrome
## 43    18 53   8     Healthy / Nonspecific
## 44    18 53   7                    Cancer
## 45    18 60   1  Irritable bowel syndrome
## 46    18 60   7     Healthy / Nonspecific
## 47    18 60   7     Healthy / Nonspecific
## 48    18 60   1                       HIV
## 49    18 60   3                    Cancer
## 50    18 47   1     Healthy / Nonspecific
## 51    18 47   8     Healthy / Nonspecific
## 52    18 47   1     Healthy / Nonspecific
## 53    18 47   1                    Cancer
## 54    18 47   8     Healthy / Nonspecific
## 55    18 47   8     Healthy / Nonspecific
## 56    18 47   8     Healthy / Nonspecific
## 57    18 47   8     Healthy / Nonspecific
## 58    18 47   3     Healthy / Nonspecific
## 59    18 47   7     Healthy / Nonspecific
## 60    18 47   8     Healthy / Nonspecific
## 61    18 47   7     Healthy / Nonspecific
## 62    18 47   8     Healthy / Nonspecific
## 63    18 66   8     Healthy / Nonspecific
## 64    18 66   8     Healthy / Nonspecific
## 65    18 66   8     Healthy / Nonspecific
## 66    18 66   8     Healthy / Nonspecific
## 67    18 61   5                    Cancer
## 68    18 58   1                 Geriatric
## 69    18 58   8     Healthy / Nonspecific
## 70    18 55   3                    Cancer
## 71    18 55   1  Irritable bowel syndrome
## 72    18 50   3                    Cancer
## 73    18 50   5                    Cancer
## 74    18 51   1  Irritable bowel syndrome
## 75    18 54   5                    Cancer
## 76    18 52   1                 Geriatric
## 77    18 52   1                       HIV
## 78    18 52   5                    Cancer
## 79    18 49   1     Healthy / Nonspecific
## 80    18 49   1     Healthy / Nonspecific
## 81    18 49   1                 Geriatric
## 82    18 49   3     Healthy / Nonspecific
## 83    18 49   1                    Cancer
## 84    18 49   1  Irritable bowel syndrome
## 85    18 49   1                       HIV
## 86    21 53   7                    Cancer
## 87    21 53   7                    Cancer
## 88    21 47   7                    Cancer
## 89    21 47   8                    Cancer
## 90    21 48   7                    Cancer
## 91    21 48   7                    Cancer
## 92    21 48   7                    Cancer
## 93    21 48   8                    Cancer
## 94    21 48   8                    Cancer
## 95    21 48   7                    Cancer
## 96    21 48   7                    Cancer
## 97    21 48   6                    Cancer
## 98    21 48   7                    Cancer
## 99    21 57   8                    Cancer
## 100   21 57   7                    Cancer
## 101   21 58   8                    Cancer
## 102   21 58   7                    Cancer
## 103   21 63   7                    Cancer
## 104   21 50   7                    Cancer
## 105   21 50   7                    Cancer
## 106   21 50   7                    Cancer
## 107   21 50   7                    Cancer
## 108   21 50   6                    Cancer
## 109   21 49   7                    Cancer
## 110   25 67   7                   Allergy
## 111   25 67   7                   Allergy
## 112   25 67   8     Healthy / Nonspecific
## 113   25 67   8     Healthy / Nonspecific
## 114   25 71   7                   Allergy
## 115   25 47   7                   Allergy
## 116   25 47   8     Healthy / Nonspecific
## 117   25 69   7                   Allergy
## 118   25 69   7                   Allergy
## 119   25 68   7                   Allergy
## 120   25 68   7                   Allergy
## 121   25 55   8     Healthy / Nonspecific
## 122   25 55   7                   Allergy
## 123   46 49   8     Healthy / Nonspecific
## 124   24 47   7               Endotoxemia
## 125   24 48   7                    Cancer
## 126   24 57   7                    Cancer
## 127   24 57   7           Gastroenteritis
## 128   24 58   7       Alzheimer's disease
## 129   24 58   7                    Cancer
## 130   24 55   7       Alzheimer's disease
## 131   24 55   7           Gastroenteritis
## 132   24 72   7     Healthy / Nonspecific
## 133   24 63   7       Alzheimer's disease
## 134   24 63   7     Healthy / Nonspecific
## 135   24 63   7               Endotoxemia
## 136   24 63   7                    Cancer
## 137   24 63   9          Oxidative stress
## 138   24 63   7           Gastroenteritis
## 139   24 52   7               Endotoxemia
## 140   27 60   7                    Cancer
## 141   27 48   7                    Cancer
## 142   27 48   7                    Cancer
## 143   27 48   7                    Cancer
## 144   27 57   7                    Cancer
## 145   27 57   7                    Cancer
## 146   27 58   7                    Cancer
## 147   27 55   7                    Cancer
## 148   27 55   7                    Cancer
## 149   27 65   7                    Cancer
## 150   27 52   7                    Cancer
## 151   27 52   7                    Cancer
## 152   19 48   7                    Cancer
## 153   19 48   7                    Cancer
## 154   19 48   8                    Cancer
## 155   19 48   5                    Cancer
## 156   19 48   6                    Cancer
## 157   19 48   6                    Cancer
## 158   19 48   6                    Cancer
## 159   19 48   6                    Cancer
## 160   19 48   6                    Cancer
## 161   19 61   1                    Cancer
## 162   19 61   5                    Cancer
## 163   19 61   6                    Cancer
## 164   19 61   6                    Cancer
## 165   19 61   6                    Cancer
## 166   19 61   5                    Cancer
## 167   19 61   5                    Cancer
## 168   19 57   7                    Cancer
## 169   19 57   7                    Cancer
## 170   19 57   8                    Cancer
## 171   19 57   8                    Cancer
## 172   19 57   8                    Cancer
## 173   19 57   8                    Cancer
## 174   19 58   7                    Cancer
## 175   19 58   7                    Cancer
## 176   19 58   8                    Cancer
## 177   19 50   1                    Cancer
## 178   19 50   8                    Cancer
## 179   19 50   8                    Cancer
## 180   19 50   5                    Cancer
## 181   19 50   6                    Cancer
## 182   19 50   6                    Cancer
## 183   19 50   6                    Cancer
## 184   19 50   6                    Cancer
## 185   19 50   5                    Cancer
## 186   19 50   5                    Cancer
## 187   19 65   1                    Cancer
## 188   19 51   1                    Cancer
## 189   19 51   5                    Cancer
## 190   19 51   6                    Cancer
## 191   19 51   6                    Cancer
## 192   19 51   6                    Cancer
## 193   19 51   6                    Cancer
## 194   19 51   6                    Cancer
## 195   19 51   6                    Cancer
## 196   19 51   1                    Cancer
## 197   19 54   5                    Cancer
## 198   19 54   6                    Cancer
## 199   19 54   6                    Cancer
## 200   19 54   6                    Cancer
## 201   19 54   5                    Cancer
## 202   19 54   5                    Cancer
## 203   19 52   5                    Cancer
## 204   19 52   5                    Cancer
## 205   19 49   1                    Cancer
## 206   20 60   1 Hepatitis / Liver Disease
## 207   20 47   7 Hepatitis / Liver Disease
## 208   20 47   7 Hepatitis / Liver Disease
## 209   20 47   1 Hepatitis / Liver Disease
## 210   20 47   7 Hepatitis / Liver Disease
## 211   20 61   5                    Cancer
## 212   20 57   7                    Cancer
## 213   20 58   7                    Cancer
## 214   20 58   7 Hepatitis / Liver Disease
## 215   20 58   7 Hepatitis / Liver Disease
## 216   20 55   7                    Cancer
## 217   20 55   7                    Cancer
## 218   20 55   7 Hepatitis / Liver Disease
## 219   20 55   7 Hepatitis / Liver Disease
## 220   20 55   7 Hepatitis / Liver Disease
## 221   20 63   7 Hepatitis / Liver Disease
## 222   20 50   5                    Cancer
## 223   20 51   1 Hepatitis / Liver Disease
## 224   20 54   5                    Cancer
## 225   20 54   1 Hepatitis / Liver Disease
## 226   20 52   7                    Cancer
## 227   20 52   7                    Cancer
## 228   20 52   8     Healthy / Nonspecific
## 229   20 52   7 Hepatitis / Liver Disease
## 230   20 52   7 Hepatitis / Liver Disease
## 231   20 52   7 Hepatitis / Liver Disease
## 232   20 52   7 Hepatitis / Liver Disease
## 233   20 52   1 Hepatitis / Liver Disease
## 234   20 52   5                    Cancer
## 235   20 52   1 Hepatitis / Liver Disease
## 236   20 52   7 Hepatitis / Liver Disease
## 237   20 52   7 Hepatitis / Liver Disease
## 238   20 52   7 Hepatitis / Liver Disease
## 239   20 49   1 Hepatitis / Liver Disease
## 240   20 49   1 Hepatitis / Liver Disease
## 241   31 49   1                       HIV
## 242   31 49   1  Chronic fatigue syndrome
## 243   22 53   1                    Cancer
## 244   22 47   2                    Cancer
## 245   22 61   5                    Cancer
## 246   22 50   5                    Cancer
## 247   22 51   4                    Cancer
## 248   22 51   1                    Cancer
## 249   22 54   1                 Geriatric
## 250   22 54   4                    Cancer
## 251   22 54   2                    Cancer
## 252   22 54   1                    Cancer
## 253   22 54   1                    Cancer
## 254   22 54   1                    Cancer
## 255   22 54   1                    Cancer
## 256   22 54   5                    Cancer
## 257   22 62   4                    Cancer
## 258   22 62   1                    Cancer
## 259   22 49   4                    Cancer
## 260   22 49   1                    Cancer
## 261   30 65   1                Cold / Flu
## 262   30 65   1                Cold / Flu
## 263   30 51   1                Cold / Flu
## 264   30 51   1                Cold / Flu
## 265   40 62   7     Healthy / Nonspecific
## 266   40 49   7     Healthy / Nonspecific
## 267   42 58   7       Alzheimer's disease
## 268   42 55   7       Alzheimer's disease
## 269   42 63   7       Alzheimer's disease
## 270   28 70   8     Healthy / Nonspecific
## 271   28 59   7       Bacterial infection
## 272   28 60   7       Bacterial infection
## 273   28 47   8     Healthy / Nonspecific
## 274   28 47   7       Bacterial infection
## 275   28 50   7       Bacterial infection
## 276   28 51   7           Gastroenteritis
## 277   28 52   7       Bacterial infection
## 278   26 57   7           Gastroenteritis
## 279   26 55   7           Gastroenteritis
## 280   26 72   7     Healthy / Nonspecific
## 281   26 63   7     Healthy / Nonspecific
## 282   26 63   7           Gastroenteritis
## 283   26 62   1                    Cancer
## 284   26 49   1                    Cancer
## 285   23 67   8     Healthy / Nonspecific
## 286   23 60   7                   Allergy
## 287   23 47   8     Healthy / Nonspecific
## 288   23 47   7               Endotoxemia
## 289   23 47   7 Hepatitis / Liver Disease
## 290   23 57   7           Gastroenteritis
## 291   23 58   7 Hepatitis / Liver Disease
## 292   23 55   8     Healthy / Nonspecific
## 293   23 55   5                Rheumatism
## 294   23 55   7                   Allergy
## 295   23 55   7               Endotoxemia
## 296   23 55   7           Gastroenteritis
## 297   23 55   7 Hepatitis / Liver Disease
## 298   23 63   7           Gastroenteritis
## 299   23 50   7               Endotoxemia
## 300   23 51   5                Rheumatism
## 301   23 54   5                Rheumatism
## 302   23 52   7 Hepatitis / Liver Disease
## 303   23 52   7 Hepatitis / Liver Disease
## 304   37 55   5                Rheumatism
## 305   37 51   5                Rheumatism
## 306   37 54   5                Rheumatism
## 307   32 62   1           Gastroenteritis
## 308   32 62   7     Healthy / Nonspecific
## 309   32 49   1           Gastroenteritis
## 310   32 49   7     Healthy / Nonspecific
## 311   41 50   7     Healthy / Nonspecific
## 312   41 65   7     Healthy / Nonspecific
## 313   41 52   7     Healthy / Nonspecific
## 314   38 71   7                   Allergy
## 315   38 68   7                   Allergy
## 316   38 55   7                   Allergy
## 317   29 51   3  Chronic fatigue syndrome
## 318   29 51   1  Chronic fatigue syndrome
## 319   36 66   1                       HIV
## 320   34 61   3                    Cancer
## 321   35 51   1 Hepatitis / Liver Disease
## 322   35 54   1 Hepatitis / Liver Disease
## 323   35 52   1 Hepatitis / Liver Disease
## 324   35 49   1 Hepatitis / Liver Disease
nodes2 <- all_nodes %>% filter(group != "Condition")
nodes2
## # A tibble: 55 × 6
##       id label                         value group  level font.size
##    <int> <chr>                         <int> <fct>  <dbl>     <dbl>
##  1    18 Immunomodulation                 36 Effect     2      38  
##  2    19 Synergistic anticancer effect    19 Effect     2      29.5
##  3    20 Hepatoprotection                 13 Effect     2      26.5
##  4    21 Anticancer                       10 Effect     2      25  
##  5    22 Psychoneuroimmuno-modulation      8 Effect     2      24  
##  6    23 Antiinflammation                  7 Effect     2      23.5
##  7    24 Antioxidant                       7 Effect     2      23.5
##  8    25 Antiallergy                       5 Effect     2      22.5
##  9    26 Radioprotection                   3 Effect     2      21.5
## 10    27 Chemoprevention                   3 Effect     2      21.5
## # … with 45 more rows
# Display the raw network diagram
visNetwork(nodes2, edges2) 
#collapse the edges by creating a value to each edge based on count of co-occurance
edges3 <- edges2 %>% filter(from != to) %>% group_by(from, to, cat) %>% summarise(value = n())
## `summarise()` has grouped output by 'from', 'to'. You can override using the
## `.groups` argument.
edges3 <- edges3%>%
  left_join(cat_color_list, by = c("cat"= "id"))
edges3
## # A tibble: 184 × 5
## # Groups:   from, to [126]
##     from    to   cat value color  
##    <int> <int> <dbl> <int> <chr>  
##  1    18    47     1     3 #FF0000
##  2    18    47     3     1 #FF0000
##  3    18    47     7     2 #00EEFF
##  4    18    47     8     7 #00EEFF
##  5    18    49     1     6 #FF0000
##  6    18    49     3     1 #FF0000
##  7    18    50     3     1 #FF0000
##  8    18    50     5     1 #00FF00
##  9    18    51     1     1 #FF0000
## 10    18    52     1     2 #FF0000
## # … with 174 more rows
# Plot the network 

visNetwork(nodes2, edges3) %>% 
   visNodes(scaling = list(min = 5, max = 35), borderWidth=0) %>% 
  visEdges(arrows = "to", scaling = list(min = 1, max = 10)) %>% 
  visPhysics(stabilization= FALSE,  solver = "forceAtlas2Based")
#  visIgraphLayout()
all_edges <- rbind(edges1, edges3)

visNetwork(all_nodes, all_edges) %>% 
   visNodes(scaling = list(min = 5, max = 35), borderWidth=0) %>% 
  visEdges(arrows = "to", scaling = list(min = 1, max = 10)) %>% 
  visPhysics(stabilization= FALSE,  solver = "forceAtlas2Based")
visNetwork(all_nodes, all_edges) %>%  
  visEdges(arrows = "to", smooth = TRUE, color=all_edges$category) %>% 
  visHierarchicalLayout(direction = "LR", levelSeparation = 500, nodeSpacing = 500)%>% 
  visNodes(scaling = list(min = 10, max = 20), borderWidth=0, shape = "dot")
# Filter all benefits that link to cancer 
cancer_node <- all_nodes %>% filter(label == "Cancer")
cancer_benefit_edges <- all_edges %>% filter(from == cancer_node$id )
cancer_benefit_nodes <- all_nodes %>% filter(id %in% cancer_benefit_edges$to) %>% rbind(cancer_node)

# Filter all outcomes that link to benefits cancer 
cancer_outcome_edges <- edges2 %>% filter(cond == "Cancer") %>% filter(from != to) %>% group_by(from, to, cat) %>% 
  summarise(value = n()) %>% 
  left_join(cat_color_list, by = c("cat"= "id"))
## `summarise()` has grouped output by 'from', 'to'. You can override using the
## `.groups` argument.
cancer_outcome_nodes <- all_nodes %>% filter(id %in% cancer_outcome_edges$to) %>% rbind(cancer_benefit_nodes) %>% distinct_all()

cancer_benefit_edges <- cancer_benefit_edges %>% mutate(to1=from, from1=to) %>% mutate(to=to1, from = from1) %>% select(-c(to1, from1))
cancer_outcome_edges <- cancer_outcome_edges %>% mutate(to1=from, from1=to) %>% mutate(to=to1, from = from1) %>% select(-c(to1, from1))

benefits_outcomes_edges <- rbind(cancer_benefit_edges, cancer_outcome_edges) # %>% select(-c(category))
cancer_outcome_nodes
## # A tibble: 30 × 6
##       id label                      value group   level font.size
##    <int> <chr>                      <int> <fct>   <dbl>     <dbl>
##  1    47 Cytokines                     25 Outcome     3      32.5
##  2    48 Cancer Proliferation          21 Outcome     3      30.5
##  3    49 Safety & Adverse Events       19 Outcome     3      29.5
##  4    50 Survival Rate                 19 Outcome     3      29.5
##  5    51 Treatment Response            19 Outcome     3      29.5
##  6    52 Liver Function Markers        18 Outcome     3      29  
##  7    53 Natural Killer Cells          17 Outcome     3      28.5
##  8    54 Quality of Life Assessment    15 Outcome     3      27.5
##  9    55 Inflammatory Markers          14 Outcome     3      27  
## 10    56 Macrophages                   13 Outcome     3      26.5
## # … with 20 more rows
benefits_outcomes_edges
## # A tibble: 111 × 6
## # Groups:   from, to [69]
##     from    to category                    value   cat color  
##    <int> <int> <fct>                       <int> <dbl> <chr>  
##  1    18     1 Randomised controlled trial     2     1 #FF0000
##  2    18     1 Before and after study          4     3 #FF0000
##  3    18     1 Case series                     1     5 #00FF00
##  4    18     1 Animal                          1     7 #00EEFF
##  5    19     1 Randomised controlled trial     2     1 #FF0000
##  6    19     1 Case series                     3     5 #00FF00
##  7    19     1 Case report                     7     6 #00FF00
##  8    19     1 Animal                          2     7 #00EEFF
##  9    19     1 Cell                            5     8 #00EEFF
## 10    20     1 Case series                     1     5 #00FF00
## # … with 101 more rows
visNetwork(cancer_outcome_nodes, benefits_outcomes_edges, main="Beneficial actions of RBAC against cancer and its positive outcomes", height=800, width="100%") %>%  
  visEdges(arrows = "to", smooth = TRUE, color=benefits_outcomes_edges$category, dashes = TRUE) %>% 
  visHierarchicalLayout(direction = "LR", levelSeparation = 500, nodeSpacing = 1500)%>% 
  visNodes(scaling = list(min = 10, max = 100), borderWidth=1, shape = "box")
# Filter all benefits that link to healthy or Geriatric 
healthy_node <- all_nodes %>% filter(label %in% c("Healthy / Nonspecific" , "Geriatric") )
healthy_benefit_edges <- all_edges %>% filter(from %in% healthy_node$id )
healthy_benefit_nodes <- all_nodes %>% filter(id %in% healthy_benefit_edges$to) %>% rbind(healthy_node)

# Filter all outcomes that link to benefits cancer 
healthy_outcome_edges <- edges2 %>% filter(cond %in% c("Healthy / Nonspecific" , "Geriatric")) %>% filter(from != to) %>% group_by(from, to, cat) %>% summarise(value = n()) %>%
  left_join(cat_color_list, by = c("cat"= "id"))
## `summarise()` has grouped output by 'from', 'to'. You can override using the
## `.groups` argument.
healthy_outcome_nodes <- all_nodes %>% filter(id %in% healthy_outcome_edges$to) %>% rbind(healthy_benefit_nodes) %>% distinct_all()


healthy_benefit_edges <- healthy_benefit_edges %>% mutate(to1=from, from1=to) %>% mutate(to=to1, from = from1) %>% select(-c(to1, from1))
healthy_outcome_edges <- healthy_outcome_edges %>% mutate(to1=from, from1=to) %>% mutate(to=to1, from = from1) %>% select(-c(to1, from1))



healthy_benefits_outcomes_edges <- rbind(healthy_benefit_edges, healthy_outcome_edges) %>% select(-c(category))
healthy_outcome_nodes
## # A tibble: 34 × 6
##       id label                      value group   level font.size
##    <int> <chr>                      <int> <fct>   <dbl>     <dbl>
##  1    47 Cytokines                     25 Outcome     3      32.5
##  2    49 Safety & Adverse Events       19 Outcome     3      29.5
##  3    50 Survival Rate                 19 Outcome     3      29.5
##  4    52 Liver Function Markers        18 Outcome     3      29  
##  5    53 Natural Killer Cells          17 Outcome     3      28.5
##  6    54 Quality of Life Assessment    15 Outcome     3      27.5
##  7    55 Inflammatory Markers          14 Outcome     3      27  
##  8    56 Macrophages                   13 Outcome     3      26.5
##  9    58 Gene Expression               11 Outcome     3      25.5
## 10    59 T & B Cells                   11 Outcome     3      25.5
## # … with 24 more rows
healthy_benefits_outcomes_edges
## # A tibble: 62 × 5
## # Groups:   from, to [46]
##     from    to value   cat color  
##    <int> <int> <int> <dbl> <chr>  
##  1    18     2     2     1 #FF0000
##  2    18     2     1     3 #FF0000
##  3    18     2     4     7 #00EEFF
##  4    18     2    14     8 #00EEFF
##  5    20     2     1     8 #00EEFF
##  6    23     2     1     8 #00EEFF
##  7    24     2     1     7 #00EEFF
##  8    24     2     1     9 #00EEFF
##  9    25     2     2     8 #00EEFF
## 10    26     2     1     7 #00EEFF
## # … with 52 more rows
visNetwork(healthy_outcome_nodes, healthy_benefits_outcomes_edges, main="Beneficial actions of RBAC in healthy or aged adults and its positive outcomes", height=800, width="100%") %>%  
  visEdges(arrows = "to", smooth = TRUE, color=benefits_outcomes_edges$category, dashes = TRUE) %>% 
  visHierarchicalLayout(direction = "LR", levelSeparation = 500, nodeSpacing = 1500)%>% 
  visNodes(scaling = list(min = 10, max = 100), borderWidth=1, shape = "box")
# Filter all benefits that link to Hepatitis / Liver Disease
liver_node <- all_nodes %>% filter(label %in% c("Hepatitis / Liver Disease") )
liver_benefit_edges <- all_edges %>% filter(from %in% liver_node$id )
liver_benefit_nodes <- all_nodes %>% filter(id %in% liver_benefit_edges$to) %>% rbind(liver_node)

# Filter all outcomes that link to benefits cancer 
liver_outcome_edges <- edges2 %>% filter(cond %in% c("Hepatitis / Liver Disease")) %>% filter(from != to) %>% group_by(from, to, cat) %>% summarise(value = n()) %>%
  left_join(cat_color_list, by = c("cat"= "id"))
## `summarise()` has grouped output by 'from', 'to'. You can override using the
## `.groups` argument.
liver_outcome_nodes <- all_nodes %>% filter(id %in% liver_outcome_edges$to) %>% rbind(liver_benefit_nodes) %>% distinct_all()


liver_benefit_edges <- liver_benefit_edges %>% mutate(to1=from, from1=to) %>% mutate(to=to1, from = from1) %>% select(-c(to1, from1))
liver_outcome_edges <- liver_outcome_edges %>% mutate(to1=from, from1=to) %>% mutate(to=to1, from = from1) %>% select(-c(to1, from1))


liver_benefits_outcomes_edges <- rbind(liver_benefit_edges, liver_outcome_edges) %>% select(-c(category))
liver_outcome_nodes
## # A tibble: 13 × 6
##       id label                      value group     level font.size
##    <int> <chr>                      <int> <fct>     <dbl>     <dbl>
##  1    47 Cytokines                     25 Outcome       3      32.5
##  2    49 Safety & Adverse Events       19 Outcome       3      29.5
##  3    51 Treatment Response            19 Outcome       3      29.5
##  4    52 Liver Function Markers        18 Outcome       3      29  
##  5    54 Quality of Life Assessment    15 Outcome       3      27.5
##  6    55 Inflammatory Markers          14 Outcome       3      27  
##  7    58 Gene Expression               11 Outcome       3      25.5
##  8    60 Lymphocytes                    9 Outcome       3      24.5
##  9    63 Oxidative Stress Markers       6 Outcome       3      23  
## 10    20 Hepatoprotection              13 Effect        2      26.5
## 11    23 Antiinflammation               7 Effect        2      23.5
## 12    35 Antiviral                      1 Effect        2      20.5
## 13     3 Hepatitis / Liver Disease      9 Condition     1      24.5
liver_benefits_outcomes_edges
## # A tibble: 23 × 5
## # Groups:   from, to [20]
##     from    to value   cat color  
##    <int> <int> <int> <dbl> <chr>  
##  1    20     3     2     1 #FF0000
##  2    20     3     7     7 #00EEFF
##  3    23     3     2     7 #00EEFF
##  4    35     3     1     1 #FF0000
##  5    47    20     1     1 #FF0000
##  6    47    20     3     7 #00EEFF
##  7    49    20     2     1 #FF0000
##  8    51    20     1     1 #FF0000
##  9    52    20     2     1 #FF0000
## 10    52    20     7     7 #00EEFF
## # … with 13 more rows
visNetwork(liver_outcome_nodes, liver_benefits_outcomes_edges, main="Beneficial actions of RBAC in liver diseases and its positive outcomes", height=800, width="100%") %>%  
  visEdges(arrows = "to", smooth = TRUE, color=benefits_outcomes_edges$category, dashes = TRUE) %>% 
  visHierarchicalLayout(direction = "LR", levelSeparation = 500, nodeSpacing = 1500)%>% 
  visNodes(scaling = list(min = 10, max = 100), borderWidth=1, shape = "box")