美文网首页
R package:xcms(九):PCA分析

R package:xcms(九):PCA分析

作者: 佳名 | 来源:发表于2024-04-06 15:13 被阅读0次
library('SummarizedExperiment')
res <- quantify(faahko, value = "into", method = "sum")
res
rowData(res)
colData(res)
assayNames(res)
assay(res) |> head()
ssays(res)$raw_nofill <- featureValues(faahko, filled = FALSE, method = "sum")
## Extract the features and log2 transform them
ft_ints <- log2(assay(res, "raw"))

## Perform the PCA omitting all features with an NA in any of the
## samples. Also, the intensities are mean centered.
pc <- prcomp(t(na.omit(ft_ints)), center = TRUE)

## Plot the PCA
pcSummary <- summary(pc)
par(mfrow = c(1, 1),mar = c(4.5, 4.2, 1, 4))
plot(pc$x[, 1], pc$x[,2], pch = 21, main = "",
     xlab = paste0("PC1: ", format(pcSummary$importance[2, 1] * 100,
                                   digits = 3), " % variance"),
     ylab = paste0("PC2: ", format(pcSummary$importance[2, 2] * 100,
                                   digits = 3), " % variance"),
     col = "darkgrey", bg = sample_colors, cex = 2)
grid()
text(pc$x[, 1], pc$x[,2], labels = res$sample_name, col = "darkgrey",
     pos = 3, cex = 2)
PCA plot

相关文章

网友评论

      本文标题:R package:xcms(九):PCA分析

      本文链接:https://www.haomeiwen.com/subject/drgatjtx.html