使用分类法绘制简单的树状图,而无需在R中聚类
我想绘制一个简单的树状图,该模拟图仅显示分类关系,而在哪里宽度或颜色代表数据集中该属的丰度。似乎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:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论