У меня есть следующее дерево mytree
:
library(ape)
library(ggtree)
library(ggimage)
mytree <- structure(list(edge = structure(c(83L, 84L, 85L, 85L, 85L, 85L,
85L, 85L, 85L, 85L, 85L, 85L, 84L, 86L, 86L, 86L, 86L, 86L, 84L,
87L, 87L, 87L, 84L, 88L, 88L, 84L, 89L, 89L, 84L, 90L, 90L, 90L,
83L, 91L, 92L, 92L, 92L, 92L, 92L, 92L, 92L, 92L, 92L, 92L, 92L,
92L, 92L, 92L, 92L, 91L, 93L, 91L, 94L, 94L, 94L, 91L, 95L, 95L,
91L, 96L, 83L, 97L, 98L, 98L, 98L, 98L, 98L, 98L, 98L, 97L, 99L,
99L, 99L, 97L, 100L, 97L, 101L, 83L, 102L, 103L, 103L, 103L,
103L, 103L, 102L, 104L, 104L, 104L, 102L, 105L, 83L, 106L, 107L,
107L, 83L, 108L, 109L, 83L, 110L, 111L, 83L, 112L, 113L, 113L,
83L, 114L, 115L, 114L, 116L, 83L, 117L, 118L, 118L, 117L, 119L,
83L, 120L, 121L, 83L, 122L, 123L, 83L, 124L, 125L, 84L, 85L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 86L, 11L, 12L, 13L,
14L, 15L, 87L, 16L, 17L, 18L, 88L, 19L, 20L, 89L, 21L, 22L, 90L,
23L, 24L, 25L, 91L, 92L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
34L, 35L, 36L, 37L, 38L, 39L, 40L, 93L, 41L, 94L, 42L, 43L, 44L,
95L, 45L, 46L, 96L, 47L, 97L, 98L, 48L, 49L, 50L, 51L, 52L, 53L,
54L, 99L, 55L, 56L, 57L, 100L, 58L, 101L, 59L, 102L, 103L, 60L,
61L, 62L, 63L, 64L, 104L, 65L, 66L, 67L, 105L, 68L, 106L, 107L,
69L, 70L, 108L, 109L, 71L, 110L, 111L, 72L, 112L, 113L, 73L,
74L, 114L, 115L, 75L, 116L, 76L, 117L, 118L, 77L, 78L, 119L,
79L, 120L, 121L, 80L, 122L, 123L, 81L, 124L, 125L, 82L), .Dim = c(124L,
2L)), Nnode = 43L, tip.label = c("Mysida", "Isopoda", "Amphipoda",
"Decapoda", "Euphausiacea", "Lophogastrida", "Mysidacea", "Leptostraca",
"Cumacea", "Stomatopoda", "Calanoida", "Cyclopoida", "Mormonilloida",
"Harpacticoida", "Siphonostomatoida", "Halocyprida", "Myodocopida",
"Podocopida", "Cyclopoida", "Calanoida", "Poecilostomatoida",
"Calanoida", "Anomopoda", "Onychopoda", "Ctenopoda", "Stomiiformes",
"Myctophiformes", "Aulopiformes", "Perciformes", "Stephanoberyciformes",
"Anguilliformes", "Argentiniformes", "Clupeiformes", "Lophiiformes",
"Osmeriformes", "Syngnathiformes", "Saccopharyngiformes", "Beryciformes",
"Gadiformes", "Scorpaeniformes", "Copelata", "Salpida", "Doliolida",
"Pyrosomatida", "Stomiiformes", "Myctophiformes", "Phlebobranchia",
"Siphonophorae", "Trachymedusae", "Siphonophora", "Anthoathecata",
"Narcomedusae", "Leptothecata", "Limnomedusae", "Coronatae",
"Semaeostomeae", "Rhizostomeae", "Actiniaria", "Carybdeida",
"Oegopsida", "Teuthida", "Octopoda", "Sepiida", "Decapodiformes",
"Pteropoda", "Thecosomata", "Littorinimorpha", "Cardiida", "Phragmophora",
"Aphragmophora", "Rhabditida", "Radiolaria", "Phyllodocida",
"Spionida", "Polystilifera", "Polystilifera", "Lobata", "Cydippida",
"Beroida", "Clionaida", "", "Chroreotrichida")), class = "phylo", order = "cladewise")
Я пытаюсь построить его с помощью вставленных картинок и легенды
d <- data.frame(node = (c(84,91,97,102,106,108, 110,112, 114, 117, 120, 122,124)),
lab = c("Arthropoda", "Chordata" , "Cnidaria" , "Mollusca" , "Chaetognatha" , "Nematoda" , "Protozoa", "Annelida" , "Nemertea" , "Ctenophora" , "Porifera" , "Platyhelminthes", "Ciliophora" ),
images = c("http://phylopic.org/assets/images/submissions/99364664-e1d2-4963-942b-b9222de80867.64.png",
"http://phylopic.org/assets/images/submissions/aa9d2eb5-d86b-4fe5-adee-99056db1d8d8.64.png",
"http://phylopic.org/assets/images/submissions/eef1fc50-acc1-4c7d-ae2b-508b7a6f3944.thumb.png",
"http://phylopic.org/assets/images/submissions/555c8380-c0a0-41e3-83e0-07f6293c6e41.thumb.png",
"http://phylopic.org/assets/images/submissions/345d2e9d-c443-4579-8f5b-c9b15ab55c84.thumb.png",
"http://phylopic.org/assets/images/submissions/3c60fbfb-5722-4248-94f0-23f841030294.thumb.png",
"http://phylopic.org/assets/images/submissions/91b6a357-3c72-446b-8d4e-bab352ec8ff7.thumb.png",
"http://phylopic.org/assets/images/submissions/e7d59ad8-887c-4017-bad5-6e2b5b167dc6.thumb.png",
"http://phylopic.org/assets/images/submissions/429429ed-d07d-463f-9316-62c7adde7e71.thumb.png",
"http://phylopic.org/assets/images/submissions/27a08157-6943-4faf-9aa3-980249e5c376.thumb.png",
"http://phylopic.org/assets/images/submissions/3449d9ef-2900-4309-bf22-5262c909344b.thumb.png",
"http://phylopic.org/assets/images/submissions/b3cb2896-495b-4c5e-9ce0-5a887a6b1838.thumb.png",
"http://phylopic.org/assets/images/submissions/77801963-4647-4921-9c6a-44ab9beb3917.thumb.png"))
tr <- ggtree(mytree,layout="unrooted")+ geom_nodepoint()# + geom_text(aes(label=node))#+ xlim(-3, 3)+ ylim(-3,3)
tr %<+% d + geom_nodelab(aes(image=images , color= lab), geom="image")+ geom_tippoint()+ geom_text(aes(label=label, angle= angle), hjust=-.2, na.rm = T)+ theme(legend.position="top")+xlim(-2.5, 5)+ ylim(-4,3)
У меня проблемы с:
- угол текста: особенно справа, текст выровнен очень грязно, я не мог понять, как это изменить
- Я не уверен, почему легенда имеет категорию NA так же ясно, как мой набор данных
d
нет пропущенных значений, поэтому я не уверен, как его удалить