代码拉取完成,页面将自动刷新
rm(list = ls())
setwd("D:\\the_first_paper\\ZRC_the_first_paper\\ZPP")
load("GSE30529.Rdata")
options(stringsAsFactors = F)
library(limma)
design <- model.matrix(~0 + factor(group))
colnames(design) <- levels(factor(group))
rownames <- colnames(exp_unique)
constrast.matrix <- makeContrasts(DKD-control, levels = design)
# deg
fit <- lmFit(exp_unique, design)
fit2 <- contrasts.fit(fit, constrast.matrix)
fit2 <- eBayes(fit2)
options(digits = 4)
DEG <- topTable(fit2, coef = 1, n = Inf)
DEG$group <- ifelse(DEG$P.Value > 0.05, "no_change",
ifelse(DEG$logFC > 1, "up",
ifelse(DEG$logFC < -1, "down", "no_change")))
table(DEG$group)
DEG$gene <- rownames(DEG)
save(DEG, design, fit, fit2, file = "DEG.Rdata")
# requirement
library(dplyr)
temp <- read.csv("ZPP/temp.csv")
#直接利用dplyr包里面的intersect函数对数据框取交集
temp_data_1 <- subset(DEG, group == "up")
temp_data_2 <- subset(DEG, group == "down")
result1=intersect(temp_data_1$gene, temp$Symbol)
result2=intersect(temp_data_2$gene, temp$Symbol)
#保存交集结果
write.table(file="up_mitochondria.csv",result1,quote=F,row.names = F,sep="\t")
write.table(file="down_mitochondria.csv",result2,quote=F,row.names = F,sep="\t")
# write.table(file="DEG.csv",DEG,quote=F,row.names = F)
# draw_picture
library(ggplot2)
DEG$p <- -log10(DEG$P.Value)
ggplot(data = DEG, aes(x = logFC, y = p, color = group)) + geom_point()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。