# 差异分析结果
data = as.data.frame(res)
# 添加想要的信息
data$foldChange = 2 ^ data$log2FoldChange
data = dplyr::rename(data, PValue=pvalue, FDR=padj)
data$FDR[is.na(data$FDR)] <- 1
data$PAdj = p.adjust(data$PValue, method="hochberg")
data$baseMeanA = 1
data$baseMeanB = 1
# 合并差异分析结果和标准化的 counts
total <- bind_cols(data, normed) %>%
rownames_to_column("SYMBOL")
# 按照 P-value排序
total = arrange(total, FDR)
# 计算 false discovery counts
total$falsePos = 1:nrow(total) * total$FDR
# 创建各组平均值
total$baseMeanA = rowMeans(total[, col_names_A])
total$baseMeanB = rowMeans(total[, col_names_B])
total$baseMean = total$baseMeanA + total$baseMeanB
# # 将数字四舍五入,使其更美观
# total$foldChange = round(total$foldChange, 3)
# total$log2FoldChange = round(total$log2FoldChange, 1)
total$baseMean = round(total$baseMean, 1)
total$baseMeanA = round(total$baseMeanA, 1)
total$baseMeanB = round(total$baseMeanB, 1)
total$lfcSE = round(total$lfcSE, 2)
total$stat = round(total$stat, 2)
# total$FDR = round(total$FDR, 4)
total$falsePos = round(total$falsePos, 0)
total$PAdj = formatC(total$PAdj, format = "e", digits = 3)
total$PValue = formatC(total$PValue, format = "e", digits = 3)
# 重新组织列名
new_cols = c("SYMBOL",
"baseMean","baseMeanA","baseMeanB",
"foldChange", "log2FoldChange",
"lfcSE","stat","PValue","PAdj",
"FDR","falsePos", col_names_A, col_names_B)
total = total[, new_cols]