-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFCConversion.R
More file actions
52 lines (44 loc) · 1.17 KB
/
FCConversion.R
File metadata and controls
52 lines (44 loc) · 1.17 KB
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
read_file_path <- "D:/Data/Program/20230107/expressionData.xlsx"
counts <- read.xlsx(read_file_path, sheetIndex = 2, header = TRUE)
database <- counts[, 2:7]
col_data <- data.frame(
row.names = colnames(database),
condition = factor(c(rep("control", 3), rep("case", 3))),
levels = c("control", "case"))
# dds is DESeqDataSet object
dds <- DESeqDataSetFromMatrix(
countData = database,
colData = col_data,
design = ~condition)
dds <- DESeq(dds)
sizeFactors(dds)
res <- results(dds)
res <- as.data.frame(res)
res <- cbind(rownames(res), res)
colnames(res) <- c(
"gengId",
"baseMean",
"log2FoldChange",
"lfcSE",
"stat",
"pvalue",
"padj")
write.table(
res,
"PvsW_gene.xlsx",
sep = "\t",
col.names = TRUE,
row.names = FALSE,
quote = FALSE,
na = "")
# abs(
res_sig <- res[which(res$pvalue < 0.05 & (res$log2FoldChange > 2)), ]
res_sig[which(res_sig$log2FoldChange > 0), "up_down"] <- "up"
res_sig[which(res_sig$log2FoldChange < 0), "up_down"] <- "down"
write.xlsx(
res_sig,
"PvsW_gene.xlsx",
sheetName = "Sheet1",
col.names = TRUE,
row.names = TRUE
)