我使用R包ape
绘制系统发育树。显示的一些标签对我来说不是直接感兴趣的(例如,“CAN”,见下图),并且它们中的一些重叠(例如,“B10”,“D1”或“D3”)。我们的想法是:(1)找到一种方法来阻止某些标签的显示,或(2)减少字体大小以使标签更具可读性。
以下是我用来绘制树的代码:
library(ape)
arbol <- nj(as.dist(Matrix_Distance))
plot.phylo(arbol, type = "unrooted", edge.width = 1, font = 1,lab4ut = "axial", show.tip.label = TRUE, cex = 0.5)
以下是dput()
矩阵的Matrix_Distance
:
Matrix_Distance <- structure(c(0, 0.326511506251481, 0.336006086921219, 0.0444988056126707,
0.0480867845389803, 0.0503019236019748, 0.0374190142347097, 0.044474378005598,
0.0495784849816714, 0.0376867344270165, 0.0379398897604375, 0.199202292123909,
0.200410050450334, 0.330229533194149, 0.336736047551321, 0.192383188880773,
0.0963655296763318, 0.0452457156018548, 0.0459338875869661, 0.0520404126026609,
0.326511506251481, 0, 0.277738407973838, 0.326027271922371, 0.329568087515665,
0.328551854053512, 0.328442686320933, 0.325848806029151, 0.325351105074129,
0.333090129724386, 0.33062905751089, 0.351548041828749, 0.35298522688544,
0.278038721695356, 0.280444201259627, 0.347785267127948, 0.317880376701051,
0.331310062984989, 0.334259421551803, 0.33321321720163, 0.336006086921219,
0.277738407973838, 0, 0.335219063735799, 0.335375425728176, 0.332607795984944,
0.333624302483247, 0.334027396919537, 0.334805995833275, 0.335455392618241,
0.336176687192981, 0.356303015361001, 0.35991484492754, 0.0140578030166058,
0.0144763669722533, 0.361289001237283, 0.322368619083354, 0.339550052850274,
0.334620165238968, 0.334520636092453, 0.0444988056126707, 0.326027271922371,
0.335219063735799, 0, 0.0400897398776824, 0.0402562647662547,
0.0414107144955124, 0.00533124050947717, 0.0391928609558206,
0.0427009237803975, 0.0435719247828981, 0.191082014943474, 0.197090480513609,
0.330060002985445, 0.331576321436942, 0.194190923742177, 0.0987412452322503,
0.0426289828094761, 0.0411839645860355, 0.0493718669337317, 0.0480867845389803,
0.329568087515665, 0.335375425728176, 0.0400897398776824, 0,
0.00454773013981058, 0.0400728473448956, 0.0407189164844416,
0.00482284749281307, 0.045823214324788, 0.0445233775660656, 0.195961845095479,
0.195672881728697, 0.333832538512492, 0.334608164905294, 0.195649893475027,
0.0968066707407677, 0.0430605330700204, 0.0434531283254102, 0.0539686262771277,
0.0503019236019748, 0.328551854053512, 0.332607795984944, 0.0402562647662547,
0.00454773013981058, 0, 0.0390674431248307, 0.0406523361332636,
0.00268044509675024, 0.0462499761541193, 0.0450677605762003,
0.194849231667258, 0.195399409244883, 0.333084236549372, 0.337895157995945,
0.195224367762397, 0.0968295660915616, 0.0434429045722447, 0.044646027345151,
0.0527555979590115, 0.0374190142347097, 0.328442686320933, 0.333624302483247,
0.0414107144955124, 0.0400728473448956, 0.0390674431248307, 0,
0.00503397088784229, 0.0423027945795776, 0.00186442780875119,
0.00530974368995733, 0.199302539132322, 0.199995474885383, 0.333474261863549,
0.335187241997379, 0.199733796648274, 0.103691542371057, 0.0470613290896341,
0.0471122945287453, 0.0530235459194857, 0.044474378005598, 0.325848806029151,
0.334027396919537, 0.00533124050947717, 0.0407189164844416, 0.0406523361332636,
0.00503397088784229, 0, 0.00681699975100358, 0.0441748944665067,
0.003522575395536, 0.199770392807277, 0.197741744940629, 0.333853257134419,
0.33582505480648, 0.198483330686744, 0.103148545689295, 0.0477440505751682,
0.0445732489871238, 0.055186206944818, 0.0495784849816714, 0.325351105074129,
0.334805995833275, 0.0391928609558206, 0.00482284749281307, 0.00268044509675024,
0.0423027945795776, 0.00681699975100358, 0, 0.039420637717289,
0.0422282283194595, 0.194256396504509, 0.195856326510698, 0.330068213529374,
0.335903033931699, 0.194416823513667, 0.0961000771643727, 0.0433900961812807,
0.0427593691418318, 0.0519440981058184, 0.0376867344270165, 0.333090129724386,
0.335455392618241, 0.0427009237803975, 0.045823214324788, 0.0462499761541193,
0.00186442780875119, 0.0441748944665067, 0.039420637717289, 0,
0.0390702469624961, 0.197659208886204, 0.198154699676583, 0.327367819084691,
0.332485733577357, 0.19488214965918, 0.100586838253038, 0.0450055381921049,
0.0415899238627063, 0.0519147495479087, 0.0379398897604375, 0.33062905751089,
0.336176687192981, 0.0435719247828981, 0.0445233775660656, 0.0450677605762003,
0.00530974368995733, 0.003522575395536, 0.0422282283194595, 0.0390702469624961,
0, 0.193243216543313, 0.192716414780958, 0.331500798269211, 0.332278217436312,
0.192354218097537, 0.0986226942472296, 0.0426762753334572, 0.0427290342074088,
0.0485044666051026, 0.199202292123909, 0.351548041828749, 0.356303015361001,
0.191082014943474, 0.195961845095479, 0.194849231667258, 0.199302539132322,
0.199770392807277, 0.194256396504509, 0.197659208886204, 0.193243216543313,
0, 0.188327278515924, 0.319803751206133, 0.320450936911227, 0.184680747074505,
0.0016830999405719, 0.102543989109571, 0.102929829171427, 0.0985319020732606,
0.200410050450334, 0.35298522688544, 0.35991484492754, 0.197090480513609,
0.195672881728697, 0.195399409244883, 0.199995474885383, 0.197741744940629,
0.195856326510698, 0.198154699676583, 0.192716414780958, 0.188327278515924,
0, 0.00996509651300943, 0.361098737043685, 0.360763784891108,
0.00925831234565036, 0.200678422180443, 0.197633497229289, 0.197602528974878,
0.330229533194149, 0.278038721695356, 0.0140578030166058, 0.330060002985445,
0.333832538512492, 0.333084236549372, 0.333474261863549, 0.333853257134419,
0.330068213529374, 0.327367819084691, 0.331500798269211, 0.319803751206133,
0.00996509651300943, 0, 0.360702907713455, 0.363054305844546,
0.00879489890519423, 0.197861665955482, 0.200169731748693, 0.195047488054228,
0.336736047551321, 0.280444201259627, 0.0144763669722533, 0.331576321436942,
0.334608164905294, 0.337895157995945, 0.335187241997379, 0.33582505480648,
0.335903033931699, 0.332485733577357, 0.332278217436312, 0.320450936911227,
0.361098737043685, 0.360702907713455, 0, 0.0135127552832453,
0.361907005213846, 0.336605263172587, 0.33593078154814, 0.331371565318138,
0.192383188880773, 0.347785267127948, 0.361289001237283, 0.194190923742177,
0.195649893475027, 0.195224367762397, 0.199733796648274, 0.198483330686744,
0.194416823513667, 0.19488214965918, 0.192354218097537, 0.184680747074505,
0.360763784891108, 0.363054305844546, 0.0135127552832453, 0,
0.359861893571362, 0.336656360746836, 0.334253860842037, 0.333018174065755,
0.0963655296763318, 0.317880376701051, 0.322368619083354, 0.0987412452322503,
0.0968066707407677, 0.0968295660915616, 0.103691542371057, 0.103148545689295,
0.0961000771643727, 0.100586838253038, 0.0986226942472296, 0.0016830999405719,
0.00925831234565036, 0.00879489890519423, 0.361907005213846,
0.359861893571362, 0, 0.199382445122727, 0.197320501995477, 0.191867695619231,
0.0452457156018548, 0.331310062984989, 0.339550052850274, 0.0426289828094761,
0.0430605330700204, 0.0434429045722447, 0.0470613290896341, 0.0477440505751682,
0.0433900961812807, 0.0450055381921049, 0.0426762753334572, 0.102543989109571,
0.200678422180443, 0.197861665955482, 0.336605263172587, 0.336656360746836,
0.199382445122727, 0, 0.00322819864061239, 0.0541256629080693,
0.0459338875869661, 0.334259421551803, 0.334620165238968, 0.0411839645860355,
0.0434531283254102, 0.044646027345151, 0.0471122945287453, 0.0445732489871238,
0.0427593691418318, 0.0415899238627063, 0.0427290342074088, 0.102929829171427,
0.197633497229289, 0.200169731748693, 0.33593078154814, 0.334253860842037,
0.197320501995477, 0.00322819864061239, 0, 0.0531978315034261,
0.0520404126026609, 0.33321321720163, 0.334520636092453, 0.0493718669337317,
0.0539686262771277, 0.0527555979590115, 0.0530235459194857, 0.055186206944818,
0.0519440981058184, 0.0519147495479087, 0.0485044666051026, 0.0985319020732606,
0.197602528974878, 0.195047488054228, 0.331371565318138, 0.333018174065755,
0.191867695619231, 0.0541256629080693, 0.0531978315034261, 0), .Dim = c(20L,
20L), .Dimnames = list(c("A1", "A2", "A4", "A5", "B1", "B2",
"B3", "B4", "B10", "B12", "B15", "CAN", "C1", "C2", "C3", "C4",
"C5", "D1", "D3", "D4"), c("A1", "A2", "A4", "A5", "B1", "B2",
"B3", "B4", "B10", "B12", "B15", "CAN", "C1", "C2", "C3", "C4",
"C5", "D1", "D3", "D4")))
答案 0 :(得分:1)
根据documentation(第195页),您可以通过调整参数cex
来调整树上显示的字体大小(这是一个缩放因子,默认值取决于当前值图形参数可能因用户而异):
一个数值,给出了tip和节点标签的因子缩放(Character EXpansion)。默认设置是从图形参数中获取当前值
要删除某些标签,最简单的方法是在绘图之前删除(或隐藏)您不想显示的样本的相应列/行。根据文档,事实上,show.tip.label
是一个布尔值:
指示是否在系统发育上显示提示标签的逻辑(默认为TRUE,即显示标签)。
答案 1 :(得分:1)
尝试分两步完成。首先是没有提示的树
plot.phylo(arbol, type = "unrooted", edge.width = 1, font = 1,lab4ut = "axial", show.tip.label = FALSE)
然后是树上的提示
## Creating the vector of labels
my_labels <- tree$tip.label
## "Removing" the unwanted labels (e.g. label 1, 2 and 7)
my_labels[c(1,2,5)] <- ""
## Adding the labels
tiplabels(my_labels, cex = 0.5)