首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >circos.heatmap():rowMeans(m)中出错:'x‘必须是至少二维的数组

circos.heatmap():rowMeans(m)中出错:'x‘必须是至少二维的数组
EN

Stack Overflow用户
提问于 2021-07-28 09:29:02
回答 1查看 31关注 0票数 1

我正在按照教程来制作circular plots in R。假设我有这样的数据集:

代码语言:javascript
复制
set.seed(123)
    mat1 = rbind(cbind(matrix(rnorm(50*5, mean = 1), nr = 50), 
                   matrix(rnorm(50*5, mean = -1), nr = 50)),
                cbind(matrix(rnorm(50*5, mean = -1), nr = 50), 
                   matrix(rnorm(50*5, mean = 1), nr = 50))
                )
    rownames(mat1) = paste0("R", 1:100)
    colnames(mat1) = paste0("C", 1:10)
    mat1 = mat1[sample(100, 100), ] # randomly permute rows
    split = sample(letters[1:5], 100, replace = TRUE)
    split = factor(split, levels = letters[1:5])

我尝试使用Heatmap,它会相应地返回。

代码语言:javascript
复制
library(ComplexHeatmap)
Heatmap(mat1, row_split = split)

enter image description here

但是,当我尝试使用circos.heatmap()时,它返回错误:

代码语言:javascript
复制
library(circlize)
col_fun1 = colorRamp2(c(-2, 0, 2), c("blue", "white", "red"))
circos.heatmap(mat = mat1, split = split, col = col_fun1)
circos.heatmap(mat = mat1, col = col_fun1)
> Error in rowMeans(m) : 'x' must be an array of at least two dimensions

矩阵本身的维度是100x10。我有没有遗漏什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-07-28 11:11:10

CRAN版本上也有同样的问题,但是在安装了开发版本之后,这个问题被修正了

代码语言:javascript
复制
devtools::install_github("jokergoo/circlize")

-testing

代码语言:javascript
复制
> library(circlize)
========================================
circlize version 0.4.13
CRAN page: https://cran.r-project.org/package=circlize
Github page: https://github.com/jokergoo/circlize
Documentation: https://jokergoo.github.io/circlize_book/book/

If you use it in published research, please cite:
Gu, Z. circlize implements and enhances circular visualization
  in R. Bioinformatics 2014.

This message can be suppressed by:
  suppressPackageStartupMessages(library(circlize))
========================================

> col_fun1 = colorRamp2(c(-2, 0, 2), c("blue", "white", "red"))
> ?circos.heatmap
starting httpd help server ... done
> 
> set.seed(123)
> mat1 = rbind(cbind(matrix(rnorm(50*5, mean = 1), nr = 50), 
+                    matrix(rnorm(50*5, mean = -1), nr = 50)),
+              cbind(matrix(rnorm(50*5, mean = -1), nr = 50), 
+                    matrix(rnorm(50*5, mean = 1), nr = 50))
+             )
> rownames(mat1) = paste0("R", 1:100)
> colnames(mat1) = paste0("C", 1:10)
> mat1 = mat1[sample(100, 100), ] # randomly permute rows
> split = sample(letters[1:5], 100, replace = TRUE)
> spilt = factor(split, levels = letters[1:5])
> col_fun1 = colorRamp2(c(-2, 0, 2), c("blue", "white", "red"))
> circos.heatmap(mat1, split = split, col = col_fun1)
> circos.clear()

-output

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68553336

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档