-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_data.qmd
147 lines (123 loc) · 4.16 KB
/
load_data.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# Load data
```{r setup_load_data, include=FALSE,message=FALSE}
knitr::opts_chunk$set(echo = TRUE,
cache=TRUE,
warning = FALSE,
message = FALSE,
out.width = "100%",
lazy.cache = FALSE)
#pdf="TRUE"
library(tidyverse)
library(igraph)
library(ComplexHeatmap)
library(viridis)
library(circlize)
library(plotly)
library(randomcoloR)
library(factoextra)
library(RColorBrewer)
library(kableExtra)
library(igraph)
library(GGally)
```
```{r}
experiment=
"0a845f74-826e-3b46-aed9-e7ecf74db262/"
path_exp=paste0("data/",experiment)
knitr::kable(data.frame(
Directory_files_and_folders=dir(path_exp),
Type=c(rep("Data file",2),
rep("Directory",3),
rep("Data file",8),
"Directory")))
```
```{r}
MBB=read_csv(paste0(path_exp,"Different_MBB.csv"),
show_col_types = FALSE)
mDAG=read_csv(paste0(path_exp,"Different_mDAG.csv"),
show_col_types = FALSE)
```
## Load metadata
Organisms are sorted by Kingdom, Phylum and Class:
```{r}
path_exp
Results=read_csv(paste0(path_exp,"Results.csv"))
#rename MetaDaG variables
names(Results)[c(1,2,3,4,5)]=c("Organism","Categories","Groups","mDAG_Id","Full_Name")
taxo=Results %>% select(Organism:Full_Name)
meta_taxo=taxo %>% separate(Categories,into=c("Kingdom","Phylum","Class"))
index=which(is.na(meta_taxo$Class))
meta_taxo$Class[index]=paste(meta_taxo$Phylum[index])
rm(taxo)
aux=table(meta_taxo$Kingdom)
Freq_Kingdom=tibble(Kingdom=names(aux),Freq_Kingdom=aux)
aux=table(meta_taxo$Phylum)
Freq_Phylum=tibble(Phylum=names(aux),Freq_Phylum=aux)
aux=table(meta_taxo$Class)
Freq_Class=tibble(Class=names(aux),Freq_Class=aux)
meta_taxo = meta_taxo %>%
left_join(Freq_Kingdom) %>%
left_join(Freq_Phylum) %>%
left_join(Freq_Class)
meta_taxo = meta_taxo %>%
arrange(desc(Freq_Kingdom),
desc(Freq_Phylum),
desc(Freq_Class))
#arrange metaxto by frequencies of kingom phylum and class
knitr::kable(head(meta_taxo))
```
```{r}
table(meta_taxo$Kingdom) %>% kable %>%
kable_styling("striped", full_width = F,position="left")%>%
scroll_box(width = "400px", height = "200px")
table(meta_taxo$Phylum,meta_taxo$Kingdom) %>% kable %>%
kable_styling("striped", full_width = F,position="left")%>%
scroll_box(width = "500px", height = "500px")
```
## Table of MBBs
In this example `MBB` is a table with `r nrow(MBB)` rows and `r ncol(MBB)` columns. It displays, for every MBB, the selected groups (Kingdoms, families, etc.) to which it belongs.
```{r}
#100
knitr::kable(MBB[1:20,1:10]) %>%
scroll_box(width = "100%", height = "200px")
```
## Table of m-DAGs
In this example `mDAG` is a table with `r nrow(mDAG)` rows and `r ncol(mDAG)` columns. It displays, for every m-DAG, the selected groups (Kingdoms, families, etc.) in which it belongs.
```{r}
kable(mDAG[1:20,1:10]) %>% scroll_box(width = "100%", height = "200px")
```
```{r}
dim(mDAG)
names(mDAG)[1:6]
head(names(mDAG)[7:(dim(mDAG)[2]-1150)])
# 28 to 1213 code MBB: 1 if MBB in mDAG 0
```
## Results Table
The `Results` table contains for every organism (row) the following information: its category (taxonomy), selected group, Full name, m-DAG id and all reactions name id with their corresponding enzyme. When a reaction is present in the corresponding m-DAG, the MBB to which it belongs is displayed in this column.
```{r}
kable(Results[1:20,1:10])%>%
row_spec(0, angle = 0) %>%
scroll_box(width = "300%", height = "1000px")
```
```{r}
dim(Results)
names(Results)[1]# organisms kegg id class representant of mDAG
names(Results)[2]# taxonomy separate by |
names(Results)[3]# groups
names(Results)[4]# mDAG_Id
names(Results)[5]# Full name representant
names(Results)[6:36]# columns 6 to 3998
# reactions name id with its enzyme.
```
```{r}
reactions=names(Results)[-c(1:5)]
reverse_reactions=stringr::str_detect(reactions,"rev")
reverse_reactions=table(reverse_reactions)
dimnames(reverse_reactions)$reverse_reactions=
c("Non reverse reaction","Reverse reaction")
reverse_reactions %>% kable %>%
kable_styling("striped", full_width = F,position="left")
```
```{r pasar_load, include=FALSE}
save.image(file='metadag_work_space.RData')
```