专栏名称: 生信菜鸟团
生信菜鸟团荣誉归来,让所有想分析生物信息学数据的小伙伴找到归属,你值得拥有!
目录
相关文章推荐
生物学霸  ·  手把手教学:用好 Word ... ·  昨天  
生物学霸  ·  Cell 子刊:上海交通大学王戈林团队揭示 ... ·  2 天前  
华大集团BGI  ·  2025自然指数发布!华大集团跻身全球前四, ... ·  2 天前  
51好读  ›  专栏  ›  生信菜鸟团

R tips:解决monocle的plot_genes_branched_heatmap函数报错

生信菜鸟团  · 公众号  · 生物  · 2025-04-12 12:00

主要观点总结

在使用monocle包进行基因表达分析时遇到报错,通过查看和修改源代码解决了问题。

关键观点总结

关键观点1:


关键观点2:


关键观点3:




正文

请到「今天看啥」查看全文


fit_model_helper ( x , modelFormulaStr = trend_formula ,
  • expressionFamily = expressionFamily , relative_expr = relative_expr ,
  • disp_func = cds@dispFitInfo [[ "blind" ]] $disp_func )
  • if ( is . null ( model_fits ))
  • expression_curve as . data . frame ( matrix ( rep ( NA , nrow ( new_data )),
  • nrow = 1 ))
  • else expression_curve as . data . frame ( responseMatrix ( list ( model_fits ),
  • new_data , response_type = response_type ))
  • colnames ( expression_curve ) row . names ( new_data )
  • expression_curve
  • }, convert_to_dense = TRUE , trend_formula = trend_formula , expressionFamily = expressionFamily ,
  • relative_expr = relative_expr , new_data = new_data )
  • 3 : genSmoothCurves ( new_cds [, ], cores = cores , trend_formula = trend_formula ,
  • relative_expr = T , new_data = rbind ( newdataA , newdataB ))
  • 2 : plot_genes_branched_heatmap (., branch_point = 1 , num_clusters = 4 ,
  • show_rownames = F , return_heatmap = T )
  • 1 : cds [ BEAM_genes , ] %>% plot_genes_branched_heatmap ( branch_point = 1 ,
  • num_clusters = 4 , show_rownames = F , return_heatmap = T )
  • 梳理调用栈,并结合各节点的函数源码可以发现报错传递是:

    1. plot_genes_branched_heatmap -> genSmoothCurves -> responseMatrix

    先看一下responseMatrix的源码,如下所示,可以发现报错点的if语句那里是有问题的。因为结合最开始的报错提示表明x@family@vfamily的长度可能不为1。

    1. monocle:::responseMatrix
    2. function (models, newdata = NULL, response_type = "response", 
    3.     cores = 1) 
    4. {
    5.     res_list  mclapply(models, function(x) {
    6.         if (is.null(x)) {
    7.             NA
    8.         }
    9.         else {
    10.             ### 报错点 ###
    11.             if (x@family@vfamily %in% c("negbinomial", "negbinomial.size")) {
    12.                 predict(x, newdata = newdata, type = response_type)
    13.             }
    14.             else if (x@family@vfamily %in% c("uninormal")) {
    15.                 predict(x, newdata = newdata, type = response_type)
    16.             }
    17.             else {
    18.                 10^predict(x, newdata = newdata, type = response_type)
    19.             }
    20.         






    请到「今天看啥」查看全文