0

我有一个用于比较控制和治疗的数据集,并将 limma 用于 pval。在我得到这样的数据之前,它适用于我的大部分数据。我可以看出控制和治疗之间存在差异。但我收到错误:“smooth.spline(lambda, pi0, df = smooth.df) 中的错误:不允许输入中的缺失或无限值”。

谁能给我一些建议如何传递错误?非常感谢!

head(df)
> Gene  ctr_1   ctr_2   tr_1    tr_2
> g1    20.50911    21.95617    25.714  25.78235
> g2    18.05096    19.96261    22.49882    23.83518
> g3    22.57205    24.65282    27.58436    29.15457
> g4    18.4146     22.08009    22.75608    25.88455
> g5    16.59619    19.06972    17.20814    22.91926
> g6    19.4405     21.65192    26.57454    27.65457
> g7    18.53613    20.8472     23.27556    24.59854
> g8    16.57177    18.38918    20.04892    21.32175
> g9    16.73278    20.81868    21.16661    24.84625
> g10   17.644      19.89144    22.3238     24.54886

Gene = df$Gene
control<- c("ctr_1","ctr_2")
treatment<- c("tr_1","tr_2")
design <- model.matrix( ~ factor(c(rep(2, 2), rep(1, 2))))
colnames(design) <- c("Intercept", "Diff")
res.eb <- eb.fit(df[, c(treatment,control)], design,Gene)

eb.fit 代码

eb.fit <- function(dat, design,Gene) {
  n <- dim(dat)[1]
  fit <- lmFit(dat, design)
  fit.eb <- eBayes(fit)
  logFC <- fit.eb$coefficients[, 2]
  df.r <- fit.eb$df.residual
  df.0 <- rep(fit.eb$df.prior, n)
  s2.0 <- rep(fit.eb$s2.prior, n)
  s2 <- (fit.eb$sigma) ^ 2
  s2.post <- fit.eb$s2.post
  t.ord <-
    fit.eb$coefficients[, 2] / fit.eb$sigma / fit.eb$stdev.unscaled[, 2]
  t.mod <- fit.eb$t[, 2]
  p.ord <- 2 * pt(-abs(t.ord), fit.eb$df.residual)
  p.mod <- fit.eb$p.value[, 2]
  q.ord <- qvalue(p.ord)$q
  q.mod <- qvalue(p.mod)$q
  p.adj <-p.adjust(p.mod,method = "BH")
  results.eb <-
    data.frame(Gene,
               logFC,
               t.ord,
               t.mod,
               p.ord,
               p.mod,
               p.adj,
               q.ord,
               q.mod,
               df.r,
               df.0,
               s2.0,
               s2,
               s2.post
               )
  return(results.eb)
}
4

0 回答 0