使用分类法绘制简单的树状图,而无需在R中聚类

发布于 2025-01-29 19:27:48 字数 2127 浏览 4 评论 0原文

我有一个看起来像这样的分类数据集: ”“在此处输入图像描述”

我想绘制一个简单的树状图,该模拟图仅显示分类关系,而在哪里宽度或颜色代表数据集中该属的丰度。似乎R中的许多软件包都希望您使用层次群集或基于DNA的数据来创建树状图,但是在这里我不需要这样做,也找不到可以以这种格式处理数据的软件包。有没有办法在R中进行此操作,还是我使用Photoshop卡住了?

编辑: 可再现的数据示例:

structure(list(phylum = c("Arthropoda", "Arthropoda", "Arthropoda", 
"Arthropoda", "Arthropoda", "Arthropoda", "Arthropoda", "Arthropoda", 
"Arthropoda", "Arthropoda", "Arthropoda", "Arthropoda", "Arthropoda", 
"Arthropoda", "Arthropoda", "Arthropoda", "Arthropoda", "Arthropoda", 
"Arthropoda", "Arthropoda"), class = c("Insecta", "Insecta", 
"Insecta", "Arachnida", "Insecta", "Insecta", "Insecta", "Insecta", 
"Insecta", "Insecta", "Insecta", "Insecta", "Insecta", "Insecta", 
"Insecta", "Insecta", "Insecta", "Insecta", "Arachnida", "Insecta"
), order = c("Plecoptera", "Trichoptera", "Diptera", "Sarcoptiformes", 
"Diptera", "Trichoptera", NA, "Plecoptera", "Plecoptera", "Plecoptera", 
"Plecoptera", "Plecoptera", "Megaloptera", "Plecoptera", "Diptera", 
"Plecoptera", "Plecoptera", "Plecoptera", "Trombidiformes", "Plecoptera"
), family = c("Leuctridae", "Odontoceridae", "Chironomidae", 
"Malaconothridae", NA, "Hydropsychidae", NA, "Perlidae", "Leuctridae", 
"Leuctridae", "Leuctridae", "Leuctridae", "Corydalidae", "Perlidae", 
"Limoniidae", "Perlidae", "Perlidae", "Perlidae", "Aturidae", 
"Perlidae"), tribe = c(NA_character_, NA_character_, NA_character_, 
NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, 
NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, 
NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, 
NA_character_, NA_character_), genus = c("Leuctra", "Psilotreta", 
"Tanytarsus", "Malaconothrus", "Parametriocnemus", "Cheumatopsyche", 
NA, "Paragnetina", "Leuctra", "Leuctra", "Leuctra", "Leuctra", 
"Nigronia", "Paragnetina", "Hexatoma", NA, "Paragnetina", "Paragnetina", 
"Aturus", NA)), row.names = c(NA, 20L), class = "data.frame")

I have a taxonomic dataset that looks like this: enter image description here

I would like to plot a simple dendrogram that just shows the taxonomic relationships, and where line width or color would represent the abundance of the genus in the dataset. It seems that many of the packages in R want you to use hierarchical clustering or DNA-based data to create the dendrogram, but here I do not need to do that and can't find a package that can handle the data in this format. Is there a way to do this in R, or am I stuck using photoshop?

EDIT:
Data for reproducible example:

structure(list(phylum = c("Arthropoda", "Arthropoda", "Arthropoda", 
"Arthropoda", "Arthropoda", "Arthropoda", "Arthropoda", "Arthropoda", 
"Arthropoda", "Arthropoda", "Arthropoda", "Arthropoda", "Arthropoda", 
"Arthropoda", "Arthropoda", "Arthropoda", "Arthropoda", "Arthropoda", 
"Arthropoda", "Arthropoda"), class = c("Insecta", "Insecta", 
"Insecta", "Arachnida", "Insecta", "Insecta", "Insecta", "Insecta", 
"Insecta", "Insecta", "Insecta", "Insecta", "Insecta", "Insecta", 
"Insecta", "Insecta", "Insecta", "Insecta", "Arachnida", "Insecta"
), order = c("Plecoptera", "Trichoptera", "Diptera", "Sarcoptiformes", 
"Diptera", "Trichoptera", NA, "Plecoptera", "Plecoptera", "Plecoptera", 
"Plecoptera", "Plecoptera", "Megaloptera", "Plecoptera", "Diptera", 
"Plecoptera", "Plecoptera", "Plecoptera", "Trombidiformes", "Plecoptera"
), family = c("Leuctridae", "Odontoceridae", "Chironomidae", 
"Malaconothridae", NA, "Hydropsychidae", NA, "Perlidae", "Leuctridae", 
"Leuctridae", "Leuctridae", "Leuctridae", "Corydalidae", "Perlidae", 
"Limoniidae", "Perlidae", "Perlidae", "Perlidae", "Aturidae", 
"Perlidae"), tribe = c(NA_character_, NA_character_, NA_character_, 
NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, 
NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, 
NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, 
NA_character_, NA_character_), genus = c("Leuctra", "Psilotreta", 
"Tanytarsus", "Malaconothrus", "Parametriocnemus", "Cheumatopsyche", 
NA, "Paragnetina", "Leuctra", "Leuctra", "Leuctra", "Leuctra", 
"Nigronia", "Paragnetina", "Hexatoma", NA, "Paragnetina", "Paragnetina", 
"Aturus", NA)), row.names = c(NA, 20L), class = "data.frame")

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文