-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDEA_script.Rmd
134 lines (81 loc) · 2.69 KB
/
DEA_script.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
125
126
127
128
129
130
131
132
133
134
```{r}
#Library calling
library(viridis)
library(htmltools)
library(ggplot2)
library( "DESeq2" )
library(stringr)
library(janitor)
library(clusterSim)
```
Add a new chunk by clicking the *Insert Chunk* button on the toolbar or by pressing *Ctrl+Alt+I*.
```{r}
#Data_Read
Data_read_DESEQ2=read.csv(file = 'GSE157103_genes.ec.tsv', sep = '\t',row.names=1)
Data_read_DESEQ2=round(Data_read_DESEQ2)
Data_read_DESEQ2=as.matrix(Data_read_DESEQ2)
mode(Data_read_DESEQ2) <- "integer"
RRNA=read.csv(file = 'group-1379.csv')$Approved.symbol
K=0
GGenes=row.names(Data_read_DESEQ2)
inter=intersect(GGenes,RRNA)
Data_read_DESEQ2=Data_read_DESEQ2[!(row.names(Data_read_DESEQ2)%in%inter),]
```
```{r}
#MetaData matrix
#Condition
Names2=colnames(Data_read_DESEQ2)
for (i in 1:length(Names2)){
if (grepl("NC",Names2[i], fixed=TRUE)){
Names2[i]="NC"
}
else{
Names2[i]="C"
}
}
#Metadata dataframe
MetaDataAll=cbind(Names2)
```
```{r}
#DEseq2
dds1=DESeqDataSetFromMatrix(countData=Data_read_DESEQ2,colData=MetaDataAll,design = ~Names2)
dds1$Names2=relevel(dds1$Names2,"NC")
dds1 <- DESeq(dds1)
```
```{r}
#DEseq P_Val=0.05, LFC=0.5
Results_0.05P <- results(dds1,alpha = 0.05,contrast=c("Names2","C","NC"),lfcThreshold=0.5,altHypothesis="greaterAbs")
write.csv(as.data.frame(Results_0.05P),file="Total_Genes.csv")
Results_0.05P <- Results_0.05P[order(Results_0.05P$padj),]
sum(Results_0.05P$padj < 0.05, na.rm=TRUE) #number of genes
DEG_0.05P <- subset(Results_0.05P,padj<0.05)
DEG_FC2=subset(DEG_0.05P,abs(log2FoldChange)>0.5)
DEG_FC2
write.csv(as.data.frame(DEG_0.05P),file="DEGS_DESEQ2_Two_Tailed.csv")
```
```{r}
#miRNA Data Read
miRNA=read.csv("Calu3_smallRNA_miRNAcounts.txt",sep = "\t",row.names = 1)
miRNA_Names=names(miRNA)
miRNA_Names=miRNA_Names[c(11,12,15,16)]
R_miRNA=miRNA[miRNA_Names]
miRNA_Condition=c('S','S','Un','Un')
miRNA_Condition_D=as.data.frame(miRNA_Condition)
miRNA_Condition_D$miRNA_Condition=factor(miRNA_Condition_D$miRNA_Condition)
```
```{r}
#MIRNa DEseq
dds_mirna=DESeqDataSetFromMatrix(countData=R_miRNA,colData=miRNA_Condition_D,design =~miRNA_Condition)
dds_mirna$miRNA_Condition=relevel(dds_mirna$miRNA_Condition,"Un")
resultsNames(dds_mirna)
dds_mirna <- DESeq(dds_mirna)
Res_mirna <- results(dds_mirna, alpha = 0.05)
Res_mirna
write.csv(as.data.frame(Res_mirna),file="ALL_MIRNA.csv")
sum(Res_mirna$padj < 0.05, na.rm=TRUE) #number of genes
Res_mirna <- subset(Res_mirna,padj<0.05)
Res_mirna
Res_mirna <- subset(Res_mirna,abs(log2FoldChange)>.5)
NAM=rownames(Res_mirna)
write.csv(as.data.frame(Res_mirna),file="MIRNA_LFC_0.5.csv")
```