更新 RNA-arry.R

This commit is contained in:
生信分析 2024-12-11 02:49:27 +08:00
parent c7b7f636a9
commit d8fdaa0208

View File

@ -38,28 +38,28 @@ exp <- exp[, -1]
#将样本按pData$title分为normal组和cancer组并转换为factor
grp <- grp[colnames(exp),]
grp <- ifelse(str_detect(grp$title,"Normal"),"normal","cancer") %>%
  factor(c("normal","cancer"))
factor(c("normal","cancer"))
############################样本质量控制与标准化################################
pca_plot1 <- as.data.frame(prcomp(t(exp))$x) %>%
  ggplot(aes(x = PC1, y = PC2, colour = grp)) +
  geom_point() +
  stat_ellipse(level = 0.95, show.legend = F) +
  theme_bw() +
  theme(panel.grid.major=element_blank(), panel.grid.minor=element_blank()) +
  ggtitle("Before Normalize")
ggplot(aes(x = PC1, y = PC2, colour = grp)) +
geom_point() +
stat_ellipse(level = 0.95, show.legend = F) +
theme_bw() +
theme(panel.grid.major=element_blank(), panel.grid.minor=element_blank()) +
ggtitle("Before Normalize")
exp <- normalizeBetweenArrays(exp, method="quantile")
if(max(exp)>50) exp <- log2(exp + 1)
pca_plot2 <- as.data.frame(prcomp(t(exp))$x) %>%
  ggplot(aes(x = PC1, y = PC2, colour = grp)) +
  geom_point() +
  stat_ellipse(level = 0.95, show.legend = F) +
  theme_bw() +
  theme(panel.grid.major=element_blank(), panel.grid.minor=element_blank()) +
  ggtitle("After Normalize")
ggplot(aes(x = PC1, y = PC2, colour = grp)) +
geom_point() +
stat_ellipse(level = 0.95, show.legend = F) +
theme_bw() +
theme(panel.grid.major=element_blank(), panel.grid.minor=element_blank()) +
ggtitle("After Normalize")
pca_plot1 + theme(legend.position = "none") + pca_plot2