-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtxi_deseq2.R
168 lines (90 loc) · 4.48 KB
/
txi_deseq2.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
library(readr)
library(tidyverse)
library(tximport)
library(stringr)
txtogenesv37 <- read_csv("C:/Users/izamamede/Desktop/Masters/R_analysis/gencode37/txtogenesv37.csv",
col_types = cols(X1 = col_skip()))
xie_kidney_index <- read_delim("xie_kidney_index.txt",
"\t", escape_double = FALSE, col_names = FALSE,
trim_ws = TRUE)
files <- file.path("C:/Users/izamamede/Desktop/Masters/Quant_files/5.Xie",
paste0(xie_kidney_index$X1,"_quant"), "quant.sf")
names(files) <- xie_kidney_index$X1
all(file.exists(files))
##############################################################################
transcript_id_togenename <- txtogenesv37 %>%
dplyr::select(2,7)
tximporteddata <- tximport(files, type="salmon", txIn = TRUE, txOut = TRUE,
countsFromAbundance = "no")
tximporteddata$abundance
x <-as.data.frame(txi_counts)
as.data.frame(txi_counts) <- tximporteddata$counts
xie_kidney_counts <- txi_counts
write.csv(xie_kidney_counts, "xie_kidney_counts.csv")
#####################################
##########################################
xie_kidney_index_mod <- xie_kidney_index %>% dplyr::select(1,3)
library("DESeq2")
ddsTxi <- DESeqDataSetFromTximport(tximporteddata,
colData = xie_kidney_index_mod,
design = ~ X3)
res()
dds$Metformin
dds <- DESeq(ddsTxi)
resultsNames(dds)
test <- results(dds)
test <- as.data.frame(test)
# or to shrink log fold changes association with condition:
#10Mm Met
res_shr <- lfcShrink(dds, coef = "X3_metformin_vs_control", type="apeglm")
#####################################################
Xie_difexpr_kidney <- as.data.frame(res_shr)
Xie_difexpr_kidney_results <- rownames_to_column(Xie_difexpr_kidney)
Xie_difexpr_kidney_results <- Xie_difexpr_kidney_results %>% filter(baseMean > 0)
Xie_difexpr_kidney_results_dic <- left_join(Xie_difexpr_kidney_results, txtogenesv37, by = c("rowname"= "transcript_id"))
Xie_difexpr_kidney_results_dic <- Xie_difexpr_kidney_results_dic %>% select(1:7, 10:13)
write.csv(Xie_difexpr_kidney_results_dic, "Xie_difexpr_kidney_results_dic.csv")
#####################
######################
#####################
#lung
##################################################################################
library(readr)
library(tidyverse)
library(tximport)
library(stringr)
txtogenesv37 <- read_csv("C:/Users/izamamede/Desktop/Masters/R_analysis/gencode37/txtogenesv37.csv",
col_types = cols(X1 = col_skip()))
xie_lung_index <- read_delim("xie_lung_index.txt",
"\t", escape_double = FALSE, col_names = FALSE,
trim_ws = TRUE)
files <- file.path("C:/Users/izamamede/Desktop/Masters/Quant_files/5.Xie",
paste0(xie_lung_index$X1,"_quant"), "quant.sf")
names(files) <- xie_lung_index$X1
all(file.exists(files))
##############################################################################
tximporteddata <- tximport(files, type="salmon", txIn = TRUE, txOut = TRUE,
countsFromAbundance = "no")
tximporteddata$abundance
txi_counts <- tximporteddata$counts
xie_lung_counts <- txi_counts
write.csv(xie_lung_counts, "xie_lung_counts.csv")
#####################################
##########################################
xie_lung_index_mod <- xie_lung_index %>% select(1,3)
library("DESeq2")
ddsTxi <- DESeqDataSetFromTximport(tximporteddata,
colData = xie_lung_index_mod,
design = ~ X3)
dds <- DESeq(ddsTxi)
resultsNames(dds)
# or to shrink log fold changes association with condition:
#Lung
res_shr <- lfcShrink(dds, coef = "X3_metformin_vs_control", type="apeglm")
#####################################################
Xie_difexpr_lung <- as.data.frame(res_shr)
Xie_difexpr_lung_results <- rownames_to_column(Xie_difexpr_lung)
Xie_difexpr_lung_results <- Xie_difexpr_lung_results %>% filter(baseMean > 0)
Xie_difexpr_lung_results_dic <- left_join(Xie_difexpr_lung_results, txtogenesv37, by = c("rowname"= "transcript_id"))
Xie_difexpr_lung_results_dic <- Xie_difexpr_lung_results_dic %>% select(1:7, 10:13)
write.csv(Xie_difexpr_lung_results_dic, "Xie_difexpr_lung_results_dic.csv")