R-DESeq2-SVA
> setwd(工作目录)
> getwd()
[1] "C:/Users/OPT-3070/Desktop"
> library(DESeq2)
> count <- read.csv("counts_MSC.csv", header = T, row.names = 1)#矩阵
> View(count)
> colData <- read.csv("colData.csv", header = T, row.names = 1) #表型,分为两列:condition和indivi
> View(colData)
> dds <- DESeqDataSetFromMatrix(count, colData, design = ~indivi + condition)
> dds
> dds$condition <- relevel(dds$condition, ref = "inj_0")#定义对照
> dds <- dds[rowSums(counts(dds)) >1, ]#去低质量
> dds <- estimateSizeFactors(dds)
> dat <- counts(dds, normalized=TRUE)
> dat <- dat[rowMeans(dat) > 1,]
> head(dat)
> library(sva)
> mod <- model.matrix(~ condition, colData(dds))#构建矩阵
> View(mod)
> mod0 <- model.matrix(~ 1, colData(dds))#构建对照矩阵
> View(mod0)
> svseq <- svaseq(dat, mod, mod0, n.sv = 2)#混杂因素数目n.sv指定为2
> svseq$sv
> dds$SV1 <- svseq$sv[,1]
> dds$SV2 <- svseq$sv[,2]
> design(dds) <- as.formula(paste("~ SV1 + SV2 + ", design))#添加预测出的混杂因子到dds
> dds
> dds <- DESeq(dds)#基于预测出的混杂因素再次分析
网友评论