bulk RNA-seq,R语言画3DPCA代码
时间: 2023-07-10 12:30:04 浏览: 164
bulk.seq代码
好的,以下是使用R语言画bulk RNA-seq数据的3DPCA代码:
首先,加载所需的库:
```R
library(DESeq2)
library(ggplot2)
library(plotly)
```
接下来,读入bulk RNA-seq数据,进行基于DESeq2的数据标准化和差异表达分析:
```R
countdata <- read.table("bulk_RNAseq_countdata.txt", header = T, row.names = 1)
coldata <- read.table("bulk_RNAseq_coldata.txt", header = T, row.names = 1)
dds <- DESeqDataSetFromMatrix(countData = countdata, colData = coldata, design = ~condition)
dds <- DESeq(dds)
res <- results(dds, contrast = c("condition", "sample1", "sample2"))
```
然后,将差异表达基因的表达矩阵进行PCA分析:
```R
pcaData <- plotPCA(assay(rld[res$padj < 0.05, ]), intgroup = "condition", returnData = TRUE)
```
最后,使用plotly包进行3DPCA绘图:
```R
pca3D <- plot_ly(pcaData, x = ~PC1, y = ~PC2, z = ~PC3, color = ~condition, colors = c("red", "blue")) %>%
add_markers() %>%
layout(scene = list(xaxis = list(title = "PC1"), yaxis = list(title = "PC2"), zaxis = list(title = "PC3")))
```
这样就可以得到bulk RNA-seq数据的3DPCA图了。
阅读全文