# #——biocstyle呼应= FALSE,结果= "飞机 "----------------------------- BiocStyle:减价 () ## ---- 消息= FALSE,警告= FALSE -------------------------------------- 库(xcms)库(RColorBrewer) (SerialParam登记 ()) ## ---- 消息= FALSE ------------------------------------------------------- ## 定义变量:set.seed(123) X <- sort(abs(rnorm(30, mean = 20, sd = 25)) ## 10 Y <- abs(rnorm(30, mean = 50, sd = 30)) ##将Y中的值放入X上定义的20个Bin中res <- binYonX(X, Y, nBins = 22) res ## ---- bininning -imputation-example, fig = TRUE, message = FALSE, fig.width = 10, fig.height = 7, fig.cap = ' bininning和缺失值imputation结果。黑点表示输入值,红色表示装箱结果,蓝色和绿色表示imputation结果(分别使用lin和linbase方法)。'---- ##绘制实际数据值。plot(X, Y, pch = 16, ylim = c(0, max(Y))) ##可视化的箱子abline(v = breaks_on_nBins(min(X), max(X), nBins = 22), col = "灰色")##定义颜色:point_colors <- paste0(brewer。pal(4, "Set1"), 80) ##绘制二进制值。points(x = res$x, y = res$y, col = point_colors[1], pch = 15) ##执行线性imputation。res_lin < - imputeLinInterpol (res $ y)点(x = res $ x, y = res_lin,坳= point_colors [2], type = " b ") # #执行线性归责”linbase res_linbase < - imputeLinInterpol (res $ y,方法=“linbase”)点(x = res $ x, y = res_linbase,坳= point_colors [3], type = " b ", lty = 2 ) ## -------------------------------------------------------------------------- ## 定义一个向量和空值。X <- 1:11 set.seed(123) Y <- sort(rnorm(11, mean = 20, sd = 10)) Y[9:11] <- NA nas <- is.na(Y) ##用profBinLin: resX <- xcms:::profBinLin(X[!nas], Y [!nas], 5, xstart = min(X), xend = max(X)) resX res <- binYonX(X, Y, nBins = 5L, shiftByHalfBinSize = TRUE) resM <- imputeLinInterpol(res$ Y, method = "lin", noInterpolAtEnds = TRUE) resM ## ----profBinLin-problems, fig = TRUE, message = FALSE, fig.align = 'center', fig.width=10, fig.height = 7, fig.cap = " profBinLin中两个bug的说明。输入值由黑点表示,灰色竖线表示箱子。使用profBinLin的宾入和插值结果显示为蓝色,使用binYonX结合imputeLinInterpol的结果显示为绿色。”——情节(x = x, y = y, pch = 16, ylim = c (0, max (y, na。rm = TRUE)), xlim = c(0, 12)) ## Plot the breaks abline(v = breaks_on_nBins(min(X), max(X), 5L, TRUE), col = "grey") ## Result from profBinLin: points(x = res$x, y = resX, col = "blue", type = "b") ## Results from imputeLinInterpol points(x = res$x, y = resM, col = "green", type = "b", pch = 4, lty = 2) ## ----eval = FALSE---------------------------------------------------------- # mzarea <- seq(which.min(abs(mzs - peakArea[i, "mzmin"])), # which.min(abs(mzs - peakArea[i, "mzmax"]))) #