admin管理员组文章数量:1391947
I am trying to create a circle packing figure, and keep getting the following error message:
"Error in graph_from_data_frame(edges, vertices = vertices) :
the data frame should contain at least two columns"
I am trying to create a circles for the HPV variants that exist in HPVseq_p and then subcircles for those that exist in HPVseq_s. (ie a big circle for HPV16 that then contains the various HPV variants inside it for HPVseq_s (HPV16, HPV53)
my code is below:
library(ggraph)
library(igraph)
library(tidyverse)
library(viridis)
edges <- HPV_subtypes$HPVseq_p
vertices <- HPV_subtypes$HPVseq_s
mygraph <- graph_from_data_frame(edges, vertices=vertices)`
dput(mydata_compressed)
structure(list(Sample = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), HPVseq_p = c("HPV16",
"HPV16", "HPV16", "HPV16", "HPV16", "HPV16", "HPV16", "HPV16",
"HPV16", "HPV33"), HPVseq_s = c("HPV16", "HPV53", "HPV16", "HPV16",
"HPV16", "HPV16", "HPV16", "HPV16", "HPV16", "na"), HPVdPCR_p = c("HPV16",
"HPV16", "na", "HPV16", "HPV16", "HPV16", "HPV16", "HPV16", "HPV16",
"HPV33"), HPVdPCR_s = c("HPV16", "HPV16", "HPV16", "HPV16", "HPV16",
"HPV16", "HPV16", "na", "HPV16", "na")), row.names = c(NA, -10L
), class = c("tbl_df", "tbl", "data.frame"))
im new at this, help would be appreciated!
I am trying to create a circle packing figure, and keep getting the following error message:
"Error in graph_from_data_frame(edges, vertices = vertices) :
the data frame should contain at least two columns"
I am trying to create a circles for the HPV variants that exist in HPVseq_p and then subcircles for those that exist in HPVseq_s. (ie a big circle for HPV16 that then contains the various HPV variants inside it for HPVseq_s (HPV16, HPV53)
my code is below:
library(ggraph)
library(igraph)
library(tidyverse)
library(viridis)
edges <- HPV_subtypes$HPVseq_p
vertices <- HPV_subtypes$HPVseq_s
mygraph <- graph_from_data_frame(edges, vertices=vertices)`
dput(mydata_compressed)
structure(list(Sample = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), HPVseq_p = c("HPV16",
"HPV16", "HPV16", "HPV16", "HPV16", "HPV16", "HPV16", "HPV16",
"HPV16", "HPV33"), HPVseq_s = c("HPV16", "HPV53", "HPV16", "HPV16",
"HPV16", "HPV16", "HPV16", "HPV16", "HPV16", "na"), HPVdPCR_p = c("HPV16",
"HPV16", "na", "HPV16", "HPV16", "HPV16", "HPV16", "HPV16", "HPV16",
"HPV33"), HPVdPCR_s = c("HPV16", "HPV16", "HPV16", "HPV16", "HPV16",
"HPV16", "HPV16", "na", "HPV16", "na")), row.names = c(NA, -10L
), class = c("tbl_df", "tbl", "data.frame"))
im new at this, help would be appreciated!
Share Improve this question asked Mar 14 at 6:30 peaches523peaches523 12 bronze badges1 Answer
Reset to default 0I don´t know what is contained in your HPV_subtypes
object, but if it is the tibble that can be created from the code below, then you´re passing a vector to the d
argument in graph_from_data_frame
. Instead you need to pass a dataframe with two columns (the first two in your dataframe), usually named from and to, which specify the association between your components in the dataframe. The remaining columns are regarded as edge attributes, if the vertices
argument is NULL
, which is the default. Have a look at the example from the ?graph_from_data_frame
help page.
What do you want to achieve with this code? is it just for visualization, or do you want to use this graph for computation purposes?
本文标签:
版权声明:本文标题:Customized Circle packing with R and ggraph - error saying the data frame should contain at least two columns - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744670637a2618801.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论