比较疾病和对照之间细菌基因的差异表达,然后计算Bray-Curtis异同性并随后绘制PCoA时,我很难使用DESeq2的结果。
我从DESeq2输出的内容已保存为数据框。它由6000行(它们是基因名称)和两列组成,一列用于p值(均<0.05),一列用于log2FOldChange>1。该数据帧称为siggenes1。在运行Bray-Curtis和PCoA之前,我需要对数据进行规范化吗?我以为这已经通过DESEq2完成,但是查看我可以提供的代码,在执行DESeq2时我没有包括normalization = T。
还是我需要在使用DESeq2之前使用扫频功能对初始数据进行归一化?
我的Bray-Curtis差异代码
vegDistOut=vegdist(t(siggenes1),"bray")
以上获得1个值为0.995的值。现在我迷失了如何设计用于绘制PCoA的代码,因为我的下一部分代码是错误的。
pcoaOut=pcoa(vegDistOut)
数组中的错误(STATS,dims [perm]):“ dims”的长度不能为0
由于上述步骤,我无法继续。
如果有人可以帮助,我将非常感激。 谢谢
答案 0 :(得分:1)
欢迎使用StackOverflow。
当试图确定两个样本的种类组成有多相似时,通常使用Bray-Curtis相似性。典型的输入将包括来自kraken,clark之类的软件的每个样本的物种计数,以获取高通量数据,或者-对于16S,Qiime2: 或dada2。
| Genus | Sample 1 | Sample 2 |
|---------------|-------------|------------|
| Pseudomonas | 200 | 100 |
| Streptococcus | 50 | 20 |
您当然可以为基因表达数据计算该指标,但这并不是通常要做的事情,我将需要有关为什么的更多信息。
据我了解,您对在PCA图中可视化样本表达之间的距离感兴趣。使用DESeq2,您可以:
library(DESeq2)
# Get a DESeqDataSet from somewhere
dds <- DESeqDataSetFrom...(...)
# You don't need to run `DESeq()` on the dds for a PCA, just transform your data
# into a homoscedastic dataset with either VST or rlog
vsd <- varianceStabilizingTransformation(dds, blind=TRUE)
rld <- rlogTransformation(dds, blind=TRUE)
# 'xxx' here takes the place of your condition of interest from your
# design data frame
plotPCA(vsd, intgroup=c('xxx'))
好吧,假设您实际上想要在PCA中拥有基因,而不是样本中。在这种情况下,您可以从VST或rlog对象获取转换后的表达式值,然后自己运行PCA代码:
library(DESeq2)
library(ggplot2)
# Get gene expression post VST
vst_expr <- assay(vsd)
# Or - if you want to select some genes
vst_expr <- assay(vsd)[c(...), ]
# Perform PCA
pca <- prcomp(vst_expr)
# Calculate explained % variation
pvar_expl <- round(((pca$sdev ^ 2) / sum(pca$sdev ^ 2)) * 100, 2)
ggplot(as.data.frame(pca$x), aes(x = PC1, y = PC2)) +
geom_point() +
xlab(paste("PC1: ", pvar_expl[1], "%")) +
ylab(paste("PC2: ", pvar_expl[2], "%"))
最后一点,通常不建议在进行探索性数据分析之前仅选择多个基因,尤其是按照您所考虑的方式。您已经测试了这些基因在DESeq2中的差异表达,因此您知道它们是不同的。最好使用PCA或热图进行盲目可视化。按照this来了解有关DESeq2的所有知识,并查看https://support.bioconductor.org/