-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2d.Rmd
124 lines (96 loc) · 3.11 KB
/
2d.Rmd
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
---
title: "2D Analysis Notebook"
output:
html_document:
df_print: paged
---
```{r}
library(tidyverse)
```
```{r}
UpGene <- read.csv("~/R/Alina_RNAseq/UpGene.csv", sep = "", stringsAsFactors = FALSE )
DownGene <- read.csv("C:/Users/kesha/Desktop/2danalysis/DownGenelist_infected_infectedvscontrol.csv )
```
```{r}
library(readxl)
effector <- as.data.frame(read_excel("allStrains_PresentAbsent_effectorlist_forKeshav.xlsx",
col_types = c(
"text", "numeric", "numeric", "numeric", "numeric",
"numeric", "numeric", "numeric", "numeric", "numeric",
"numeric", "numeric", "numeric", "numeric", "numeric"
)
))
rownames(effector) <- effector[,1] # move effectors to rownames
effector <- subset(effector, select = - ...1) #remove effector symbol column
net_eff <- rowSums(effector, na.rm = TRUE, dims = 1)
effector$net_effector <- net_eff
head(effector)
```
```{r}
l2fctable_InfectedvsControl <- read.csv("~/R/Alina_RNAseq/InfectedVsControl/l2fctableSIGNIFICANT_InfectedvsControl_BL6.csv")
# filter the symbol column based on only the genes that are in UpGenes so that these are both significant and differentially regulated
# l2fctable_InfectedvsControl <- filter(l2fctable_InfectedvsControl,
# symbol %in% c(UpGene$UpGeneList, DownGene$x))
l2fctable_InfectedvsControl <- filter(l2fctable_InfectedvsControl,
symbol %in% UpGene$UpGeneList)
```
```{r}
rownames(l2fctable_InfectedvsControl) <- l2fctable_InfectedvsControl[, 2] # make the symbols as rownames
l2fctable_InfectedvsControl <- subset(l2fctable_InfectedvsControl, select = -c(X, symbol)) # remove the X and symbol columns
net_l2fc <- rowSums(l2fctable_InfectedvsControl, na.rm = TRUE, dims = 1) # sum up the values in each row for every gene to get net infected gene expression
l2fctable_InfectedvsControl$net_l2fc <- net_l2fc
```
```{r}
library(stringr)
colnames(l2fctable_InfectedvsControl) <- str_remove_all(colnames(l2fctable_InfectedvsControl),
pattern = "log2FoldChange_")
l2fctable_InfectedvsControl <- l2fctable_InfectedvsControl[order(l2fctable_InfectedvsControl$net_l2fc, decreasing = TRUE), ]
head(l2fctable_InfectedvsControl)
```
```{r}
#l2fc <- l2fctable_InfectedvsControl[ c(1:28, 227:254), ]
# l2fc <- l2fctable_InfectedvsControl[ c(1:28, 227:254), ]
```
```{r}
# l <- t(l2fctable_InfectedvsControl)
# e <- t(effector)
# data_frame_merge <- merge(l, e, by = 'row.names', all = TRUE)
```
```{r}
# cancor(l2fc$net_l2fc, effector$net_effector)
```
```{r}
# library(GGally)
# ggpairs(l2fc)
```
```{r}
# ggcorr(l2fc)
# ```
#
# ```{r}
# library(CCA)
```
```{r}
mc <- matcor(t(l2fctable_InfectedvsControl), t(effector))
```
```{r}
mc$XYcor
```
```{r}
correlate <- mc$XYcor
```
```{r}
library(corrplot)
```
```{r fig.height=15, fig.width=15}
corrplot(correlate)
```
R Canonical Correlation Analysis
```{r}
# library(corrr)
# cc1 <- cc(l2fc, effector)
```
```{r}
# compute canonical loadings
# cc2 <- comput(l2fc, effector, cc1)
```