# #设置,包括= FALSE --------------------------------------------------- knitr: opts_chunk美元集(崩溃= TRUE,发表评论 = "#>" ) ## ---- 呼应= TRUE,消息= FALSE,警告= FALSE, eval = FALSE ---------------------- # install.packages(“gridExtra”)# # (!requireNamespace("BiocManager", quiet = TRUE)) # install.packages("BiocManager") # BiocManager::install("pmp") ## ---- message=FALSE,警告= FALSE -------------------------------------------- 库(S4Vectors)库(SummarizedExperiment)图书馆(pmp)图书馆(ggplot2)图书馆(reshape2)图书馆(gridExtra ) ## ---- eval = FALSE -------------------------------------------------------------- # 帮助(“MTBLS79 ") ## ----------------------------------------------------------------------------- 数据(“MTBLS79”)类< - MTBLS79类批< - MTBLS79批美元sample_order < - c (1: ncol (MTBLS79)) #输入数据结构MTBLS79类[1:10]批[1:10]sample_order [1:10 ] ## ----------------------------------------------------------------------------- 数据< - filter_peaks_by_fraction (df = MTBLS79类=类、方法=“质量控制”,qc_label =“质量控制”,min_frac = 0.8 ) ## ----------------------------------------------------------------------------- corrected_data < - QCRSC (df =数据、订单= sample_order批=批类=类,晶石= 0,minQC = 4) # # = FALSE,消息,警告= FALSE, fig.height = 5,fig.width = 5 ------------------ 情节< sbc_plot (df = MTBLS79 corrected_df = corrected_data类=类,批=批处理,输出= NULL,指数= c(1、5、30))情节# #——fig.width = 6, fig.height = 8 ----------------------------------------------- manual_color = c(“# 386 cb0”、“# ef3b2c”、“# 7 fc97f”、“# fdb462”、“# 984 ea3”、“# a6cee3”,“778899号”,“# fb9a99”、“# ffff33”)pca_data < - pqn_normalisation (MTBLS79类=类,qc_label =“质量控制”)pca_data < mv_imputation (pca_data方法=“资讯”,k = 5, rowmax = 0.5,colmax=0.5, maxp=NULL, check_df=FALSE) pca_data <- glog_transformation(pca_data, classes=class, qc_label="QC") pca_corrected_data <- pmp::pqn_normalisation(corrected_data, classes=class, qc_label="QC") pca_corrected_data <- pmp::mv_imputation(pca_corrected_data, method="KNN", k=5, rowmax=0.5, colmax=0.5, maxp=NULL, check_df=FALSE) pca_corrected_data <- pmp::glog_transformation(pca_corrected_data, classes=class, qc_label="QC") pca_data <- prcomp(t(assay(pca_data)), center=TRUE,规模= FALSE) pca_corrected_data < - prcomp (t(化验(pca_corrected_data)),中心= TRUE,规模= FALSE) #计算比例的方差解释前两个电脑exp_var_pca < -轮(((pca_data标准偏差美元^ 2)/笔(pca_data标准偏差美元^ 2)* 100)[1:2],2)exp_var_pca_corrected < -轮(((pca_corrected_data标准偏差美元^ 2)/笔(pca_corrected_data标准偏差美元^ 2)* 100)[1:2],2)情节< -列表()plotdata < - data.frame (PC1 = pca_data $ x [1], PC2 = pca_data $ x[2],批= as.factor(批),类=类)情节[[1]]< - ggplot (data = plotdata,aes(x=PC1, y=PC2, col=batch)) + geom_point(size=2) + theme(panel.background=element_blank()) + scale_color_manual(values=manual_color) + ggtitle("PCA scores, before correction") + xlab(paste0("PC1 (", exp_var_pca[1]," %)")) + ylab(paste0("PC2 (", exp_var_pca[2],"%)")) plot [[2]] <- ggplot(data=plotdata, aes(x=PC1, y=PC2, col=class)) + geom_point(size=2) + theme(panel.background=element_blank()) + scale_color_manual(values=manual_color) + ggtitle("PCA scores, before correction") + xlab(paste0("PC1 (", exp_var_pca[1]," %)")) + ylab(paste0("PC2 (", exp_var_pca[2],"%)")) plotdata_corr <- data.frame(PC1=pca_corrected_data$x[, 1], PC2=pca_corrected_data$x[, 2], batch=as.factor(batch), class=class) plots[[3]] <- ggplot(data=plotdata_corr, aes(x=PC1, y=PC2, col=batch)) + geom_point(size=2) + theme(panel.background=element_blank()) + scale_color_manual(values=manual_color) + ggtitle("PCA scores, after correction") + xlab(paste0("PC1 (", exp_var_pca_corrected[2]," %)") + ylab(paste0("PC2 (", exp_var_pca_corrected[2],")%)")) plot [[4]] <- ggplot(data=plotdata_corr, aes(x=PC1, y=PC2, col=class)) + geom_point(size=2) + theme(panel.background=element_blank()) + scale_color_manual(values=manual_color) + ggtitle("PCA scores, after correction") + xlab(paste0("PC1 (", exp_var_pca_corrected[1]," % ")) + ylab(paste0("PC2 (", exp_var_pca_corrected[2]," % ")))) grid。安排(ncol = 2,情节[[1]],[[2]],[[3]],[[4 ]]) ## ----------------------------------------------------------------------------- sessionInfo ()