用户名 Email 自动登录 找回密码 密码 立即注册

# [annotation] DESeq2包

29主题 149积分   149 发表于 2018-9-13 17:56:15 | 显示全部楼层 |阅读模式
 1）简介： DESeq2-package： for differential analysis of count data（对count data 做差异分析） 2）安装 [mw_shl_code=python,true]if("DESeq2" %in% rownames(installed.packages()) == FALSE) {source("http://bioconductor.org/biocLite.R");biocLite("DESeq2")} suppressMessages(library(DESeq2)) ls('package ESeq2')[/mw_shl_code] 3）对象的简单使用 3.1）coef（Extract a matrix of model coefﬁcients/standard errors，高级用户检验模型系数） 语法：coef(object, SE = FALSE, ...) 参数解释： object：a DESeqDataSet returned by DESeq, nbinomWaldTest, or nbinomLRT. 例子： [mw_shl_code=python,true]dds <- makeExampleDESeqDataSet(m=4) dds <- DESeq(dds) coef(dds)[1,] coef(dds, SE=TRUE)[1,][/mw_shl_code] 3.2） collapseReplicates：Collapse technical replicates in a RangedSummarizedExperiment or DESeqDataSet(用于消除技术重复) 用法：collapseReplicates(object, groupby, run, renameCols = TRUE) 参数： object：A RangedSummarizedExperiment or DESeqDataSet groupby：a grouping factor, as long as the columns of object，分组因子 run：optional, the names of each unique column in object. if provided, a new column runsCollapsed will be added to the colData which pastes together the names of run （测序run） renameCols：whether to rename the columns of the returned object using the levels of the grouping factor 例子： [mw_shl_code=python,true]dds <- makeExampleDESeqDataSet(m=12) str(dds) dds\$sample <- factor(sample(paste0("sample",rep(1:9, c(2,1,1,2,1,1,2,1,1))))) dds\$run <- paste0("run",1:12) ddsColl <- collapseReplicates(dds, dds\$sample, dds\$run) # examine the colData and column names of the collapsed data colData(ddsColl) colnames(ddsColl) # check that the sum of the counts for "sample1" is the same # as the counts in the "sample1" column in ddsColl matchFirstLevel <- dds\$sample == levels(dds\$sample) stopifnot(all(rowSums(counts(dds[,matchFirstLevel])) == counts(ddsColl[,1])))[/mw_shl_code] 3.3）counts：Accessors for the ’counts’ slot of a DESeqDataSet object 语法:counts(object, normalized = FALSE,replaced = FALSE) 参数: object:a DESeqDataSet object. normalized：logical indicating whether or not to divide the counts by the size factors or normalization factors before returning replaced：返回极端值 [mw_shl_code=python,true]dds <- makeExampleDESeqDataSet(m=4) head(counts(dds)) dds <- estimateSizeFactors(dds)   head(counts(dds, normalized=TRUE))[/mw_shl_code] 3.4）DESeq：Differential expression analysis based on the Negative Binomial 语法： DESeq(object, test = c("Wald", "LRT"), fitType = c("parametric", "local","mean"), sfType = c("ratio", "poscounts", "iterate"), betaPrior,full = design(object), reduced, quiet = FALSE,minReplicatesForReplace = 7, modelMatrixType, useT = FALSE, minmu = 0.5,parallel = FALSE, BPPARAM = bpparam()) [mw_shl_code=python,true]# count tables from RNA-Seq data cnts <- matrix(rnbinom(n=1000, mu=100, size=1/0.5), ncol=10) cond <- factor(rep(1:2, each=5)) # object construction dds <- DESeqDataSetFromMatrix(cnts, DataFrame(cond), ~ cond) # standard analysis dds <- DESeq(dds) res <- results(dds) # moderated log2 fold changes resultsNames(dds) resLFC <- lfcShrink(dds, coef=2, type="apeglm") # an alternate analysis: likelihood ratio test ddsLRT <- DESeq(dds, test="LRT", reduced= ~ 1) resLRT <- results(ddsLRT)[/mw_shl_code] 3.8）rlog Apply a ’regularized log’ transformation 用法： rlog(object, blind = TRUE, intercept, betaPriorVar, fitType = "parametric") rlogTransformation(object, blind = TRUE, intercept, betaPriorVar,fitType = "parametric") [mw_shl_code=python,true]dds <- makeExampleDESeqDataSet(m=6,betaSD=1) rld <- rlog(dds) dists <- dist(t(assay(rld))) plot(hclust(dists))[/mw_shl_code] 2 3.9）plotPCA（Sample PCA plot for transformed data） 用法：plotPCA(object, intgroup = "condition",ntop = 500, returnData = FALSE) [mw_shl_code=python,true]# using rlog transformed data: dds <- makeExampleDESeqDataSet(betaSD=1) rld <- rlog(dds) plotPCA(rld) # also possible to perform custom transformation: dds <- estimateSizeFactors(dds) # shifted log of normalized counts se <- SummarizedExperiment(log2(counts(dds, normalized=TRUE) + 1), colData=colData(dds)) # the call to DESeqTransform() is needed to # trigger our plotPCA method. plotPCA( DESeqTransform( se ) )[/mw_shl_code] 1 您需要登录后才可以回帖 登录 | 立即注册 本版积分规则 回帖后跳转到最后一页 |手机版|小黑屋|生信技能树 ( 粤ICP备15016384号 GMT+8, 2020-4-5 15:57 , Processed in 0.022756 second(s), 26 queries .