我需要帮助才能将一些列添加到 treedata 对象列表的列表中,如下所示:。(你可以在帖子末尾找到数据)
[上下文]
> The_dataframe
[[1]]
[[1]][[1]]
'treedata' S4 object'.
...@ phylo:
Phylogenetic tree with 15 tips and 19 internal nodes.
Tip labels:
Ailuropoda_melanoleuca, Agriarctos_spp, Indarctos_arctoides, Indarctos_vireti, Ursus_americanus, Ursus_thibetanus, ...
Node labels:
, , , Ursavus_brevirhinus, Ursavus_primaevus, Kretzoiarctos_beatrix, ...
Rooted; includes branch lengths.
with the following features available:
'age_0.95_HPD', 'index', 'posterior', 'sampled_ancestor'.
# The associated data tibble abstraction: 34 × 7
# The 'node', 'label' and 'isTip' are from the phylo tree.
node label isTip age_0.95_HPD index posterior sampled_ancestor
<int> <chr> <lgl> <list> <chr> <dbl> <dbl>
1 1 Ailuropoda_melanoleuca TRUE <dbl [1]> 10 NA NA
2 2 Agriarctos_spp TRUE <dbl [2]> 19 NA 0.265
3 3 Indarctos_arctoides TRUE <dbl [2]> 7 NA 0.352
4 4 Indarctos_vireti TRUE <dbl [2]> 4 NA 0.138
5 5 Ursus_americanus TRUE <dbl [1]> 15 NA NA
6 6 Ursus_thibetanus TRUE <dbl [1]> 18 NA NA
7 7 Helarctos_malayanus TRUE <dbl [1]> 13 NA NA
8 8 Ursus_arctos TRUE <dbl [1]> 16 NA NA
9 9 Ursus_maritimus TRUE <dbl [1]> 12 NA NA
10 10 Ursus_spelaeus TRUE <dbl [2]> 14 NA NA
# … with 24 more rows
如您所见,示例数据只有一张表可供访问as_tibble(The_dataframe[[1]][[1]])
# A tibble: 34 × 8
parent node branch.length label age_0.95_HPD index posterior sampled_ancestor
<int> <int> <dbl> <chr> <list> <chr> <dbl> <dbl>
1 24 1 7.80 Ailuropoda_melanoleuca <dbl [1]> 10 NA NA
2 23 2 2.56 Agriarctos_spp <dbl [2]> 19 NA 0.265
3 26 3 1.88 Indarctos_arctoides <dbl [2]> 7 NA 0.352
4 25 4 1.61 Indarctos_vireti <dbl [2]> 4 NA 0.138
5 31 5 2.83 Ursus_americanus <dbl [1]> 15 NA NA
6 31 6 2.83 Ursus_thibetanus <dbl [1]> 18 NA NA
7 30 7 3.57 Helarctos_malayanus <dbl [1]> 13 NA NA
8 33 8 1.50 Ursus_arctos <dbl [1]> 16 NA NA
9 33 9 1.50 Ursus_maritimus <dbl [1]> 12 NA NA
10 32 10 2.97 Ursus_spelaeus <dbl [2]> 14 NA NA
# … with 24 more rows
[问题]:
- 是否有人有代码的想法,以便添加一个新列,例如 Newcol 填充 30,但当然要保留 treedata 类的列表?到目前为止我试过
as_tibble(The_dataframe[[1]][[1]])$"new_col"<-30
但我收到错误消息:
Error in as_tibble(The_dataframe[[1]][[1]])$Newcol <- 30 :
unable to find the "as_tibble<-" function
[预期行为]:
通过点击The_dataframe我应该得到以下输出:
> The_dataframe
[[1]]
[[1]][[1]]
'treedata' S4 object'.
...@ phylo:
Phylogenetic tree with 15 tips and 19 internal nodes.
Tip labels:
Ailuropoda_melanoleuca, Agriarctos_spp, Indarctos_arctoides, Indarctos_vireti, Ursus_americanus, Ursus_thibetanus, ...
Node labels:
, , , Ursavus_brevirhinus, Ursavus_primaevus, Kretzoiarctos_beatrix, ...
Rooted; includes branch lengths.
with the following features available:
'age_0.95_HPD', 'index', 'posterior', 'sampled_ancestor'.
# The associated data tibble abstraction: 34 × 7
# The 'node', 'label' and 'isTip' are from the phylo tree.
node label isTip age_0.95_HPD index posterior sampled_ancestor Newcol
<int> <chr> <lgl> <list> <chr> <dbl> <dbl> <dbl>
1 1 Ailuropoda_melanoleuca TRUE <dbl [1]> 10 NA NA 30
2 2 Agriarctos_spp TRUE <dbl [2]> 19 NA 0.265 30
3 3 Indarctos_arctoides TRUE <dbl [2]> 7 NA 0.352 30
4 4 Indarctos_vireti TRUE <dbl [2]> 4 NA 0.138 30
5 5 Ursus_americanus TRUE <dbl [1]> 15 NA NA 30
6 6 Ursus_thibetanus TRUE <dbl [1]> 18 NA NA 30
7 7 Helarctos_malayanus TRUE <dbl [1]> 13 NA NA 30
8 8 Ursus_arctos TRUE <dbl [1]> 16 NA NA 30
9 9 Ursus_maritimus TRUE <dbl [1]> 12 NA NA 30
10 10 Ursus_spelaeus TRUE <dbl [2]> 14 NA NA 30
# … with 24 more rows
[输出数据]
The_dataframe <- list(list(new("treedata", file = "", treetext = "(((((((((Ailuropoda_melanoleuca[&index=10]:7.801817)Ailurarctos_lufengensis[&index=21,posterior=0.256991,age_95%_HPD={6.64001,8.1982},sampled_ancestor=0.467377]:1.366333,Agriarctos_spp[&index=19,sampled_ancestor=0.264980,age_95%_HPD={5.13563,7.7489}]:2.559428)[&index=22,posterior=0.328895,age_95%_HPD={7.75754,10.9303}]:1.473766,((Indarctos_arctoides[&index=7,sampled_ancestor=0.351531,age_95%_HPD={5.0131,9.69924}]:1.875503)Indarctos_punjabiensis[&index=23,posterior=0.154461,age_95%_HPD={7.28854,9.69991},sampled_ancestor=0.528628]:0.808470,Indarctos_vireti[&index=4,sampled_ancestor=0.138482,age_95%_HPD={7.85346,8.69269}]:1.606633)[&index=24,posterior=0.312916,age_95%_HPD={8.72817,10.9523}]:0.717725)[&index=25,posterior=0.591212,age_95%_HPD={9.44492,11.7607}]:1.038375)Kretzoiarctos_beatrix[&index=26,posterior=0.535286,age_95%_HPD={11.3942,11.7999},sampled_ancestor=0.909454]:4.177918)Ursavus_primaevus[&index=27,posterior=0.420772,age_95%_HPD={15.5618,15.97},sampled_ancestor=0.569907]:0.883936)Ursavus_brevirhinus[&index=28,posterior=0.354194,age_95%_HPD={16.2798,16.8996},sampled_ancestor=0.842876]:3.765166,(((((Ursus_americanus[&index=15]:2.829507,Ursus_thibetanus[&index=18]:2.829507)[&index=29,posterior=0.758988,age_95%_HPD={1.22039,4.36821}]:0.737650,Helarctos_malayanus[&index=13]:3.567157)[&index=30,posterior=0.993342,age_95%_HPD={1.85239,5.83876}]:0.941132,((Ursus_arctos[&index=16]:1.503686,Ursus_maritimus[&index=12]:1.503686)[&index=31,posterior=1.000000,age_95%_HPD={0.513308,2.69051}]:1.642701,Ursus_spelaeus[&index=14,age_95%_HPD={0.06962,0.245158}]:2.972521)[&index=32,posterior=0.986684,age_95%_HPD={1.22187,5.83336}]:1.361901)[&index=33,posterior=0.965379,age_95%_HPD={2.39173,7.55755}]:2.506113,Melursus_ursinus[&index=17]:7.014401)[&index=34,posterior=1.000000,age_95%_HPD={4.41289,11.1142}]:4.086867,(Arctodus_simus[&index=6,sampled_ancestor=0.003995,age_95%_HPD={0.670375,2.58573}]:3.401332,Tremarctos_ornatus[&index=9]:5.247488)[&index=35,posterior=0.994674,age_95%_HPD={1.73983,9.46342}]:5.853780)[&index=36,posterior=1.000000,age_95%_HPD={5.75446,17.6826}]:9.406043)[&index=37,posterior=0.399467,age_95%_HPD={16.7729,27.5404}]:5.439961,Ballusia_elmensis[&index=11,sampled_ancestor=0.487350,age_95%_HPD={14.4635,22.7975}]:6.045218)[&index=38,posterior=0.403462,age_95%_HPD={19.7677,34.694}]:6.089001,Zaragocyon_daamsi[&index=2,sampled_ancestor=0.017310,age_95%_HPD={20.2921,22.7797}]:10.366901)[&index=39,posterior=0.997337,age_95%_HPD={24.7003,41.1459}]:0.000000;",
phylo = structure(list(edge = structure(c(16L, 17L, 18L,
19L, 20L, 21L, 22L, 23L, 24L, 23L, 22L, 25L, 26L, 25L, 18L,
27L, 28L, 29L, 30L, 31L, 31L, 30L, 29L, 32L, 33L, 33L, 32L,
28L, 27L, 34L, 34L, 17L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
23L, 24L, 1L, 2L, 25L, 26L, 3L, 4L, 27L, 28L, 29L, 30L, 31L,
5L, 6L, 7L, 32L, 33L, 8L, 9L, 10L, 11L, 34L, 12L, 13L, 14L,
15L), .Dim = c(33L, 2L)), edge.length = c(6.089001, 5.439961,
3.765166, 0.883936, 4.177918, 1.038375, 1.473766, 1.366333,
7.801817, 2.559428, 0.717725, 0.80847, 1.875503, 1.606633,
9.406043, 4.086867, 2.506113, 0.941132, 0.73765, 2.829507,
2.829507, 3.567157, 1.361901, 1.642701, 1.503686, 1.503686,
2.972521, 7.014401, 5.85378, 3.401332, 5.247488, 6.045218,
10.366901), Nnode = 19L, node.label = c("", "", "", "Ursavus_brevirhinus",
"Ursavus_primaevus", "Kretzoiarctos_beatrix", "", "", "Ailurarctos_lufengensis",
"", "Indarctos_punjabiensis", "", "", "", "", "", "", "",
""), tip.label = c("Ailuropoda_melanoleuca", "Agriarctos_spp",
"Indarctos_arctoides", "Indarctos_vireti", "Ursus_americanus",
"Ursus_thibetanus", "Helarctos_malayanus", "Ursus_arctos",
"Ursus_maritimus", "Ursus_spelaeus", "Melursus_ursinus",
"Arctodus_simus", "Tremarctos_ornatus", "Ballusia_elmensis",
"Zaragocyon_daamsi"), root.edge = 0), class = "phylo", order = "cladewise"),
data = structure(list(age_0.95_HPD = list(NA_real_, c(6.64001,
8.1982), c(5.13563, 7.7489), c(7.75754, 10.9303), c(5.0131,
9.69924), c(7.28854, 9.69991), c(7.85346, 8.69269), c(8.72817,
10.9523), c(9.44492, 11.7607), c(11.3942, 11.7999), c(15.5618,
15.97), c(16.2798, 16.8996), NA_real_, NA_real_, c(1.22039,
4.36821), NA_real_, c(1.85239, 5.83876), NA_real_, NA_real_,
c(0.513308, 2.69051), c(0.06962, 0.245158), c(1.22187,
5.83336), c(2.39173, 7.55755), NA_real_, c(4.41289, 11.1142
), c(0.670375, 2.58573), NA_real_, c(1.73983, 9.46342
), c(5.75446, 17.6826), c(16.7729, 27.5404), c(14.4635,
22.7975), c(19.7677, 34.694), c(20.2921, 22.7797), c(24.7003,
41.1459)), index = c("10", "21", "19", "22", "7", "23",
"4", "24", "25", "26", "27", "28", "15", "18", "29", "13",
"30", "16", "12", "31", "14", "32", "33", "17", "34", "6",
"9", "35", "36", "37", "11", "38", "2", "39"), posterior = c(posterior1 = NA,
posterior2 = 0.256991, posterior3 = NA, posterior4 = 0.328895,
posterior5 = NA, posterior6 = 0.154461, posterior7 = NA,
posterior8 = 0.312916, posterior9 = 0.591212, posterior10 = 0.535286,
posterior11 = 0.420772, posterior12 = 0.354194, posterior13 = NA,
posterior14 = NA, posterior15 = 0.758988, posterior16 = NA,
posterior17 = 0.993342, posterior18 = NA, posterior19 = NA,
posterior20 = 1, posterior21 = NA, posterior22 = 0.986684,
posterior23 = 0.965379, posterior24 = NA, posterior25 = 1,
posterior26 = NA, posterior27 = NA, posterior28 = 0.994674,
posterior29 = 1, posterior30 = 0.399467, posterior31 = NA,
posterior32 = 0.403462, posterior33 = NA, posterior34 = 0.997337
), sampled_ancestor = c(sampled_ancestor1 = NA, sampled_ancestor2 = 0.467377,
sampled_ancestor3 = 0.26498, sampled_ancestor4 = NA, sampled_ancestor5 = 0.351531,
sampled_ancestor6 = 0.528628, sampled_ancestor7 = 0.138482,
sampled_ancestor8 = NA, sampled_ancestor9 = NA, sampled_ancestor10 = 0.909454,
sampled_ancestor11 = 0.569907, sampled_ancestor12 = 0.842876,
sampled_ancestor13 = NA, sampled_ancestor14 = NA, sampled_ancestor15 = NA,
sampled_ancestor16 = NA, sampled_ancestor17 = NA, sampled_ancestor18 = NA,
sampled_ancestor19 = NA, sampled_ancestor20 = NA, sampled_ancestor21 = NA,
sampled_ancestor22 = NA, sampled_ancestor23 = NA, sampled_ancestor24 = NA,
sampled_ancestor25 = NA, sampled_ancestor26 = 0.003995, sampled_ancestor27 = NA,
sampled_ancestor28 = NA, sampled_ancestor29 = NA, sampled_ancestor30 = NA,
sampled_ancestor31 = 0.48735, sampled_ancestor32 = NA, sampled_ancestor33 = 0.01731,
sampled_ancestor34 = NA), node = c("1", "24", "2", "23",
"3", "26", "4", "25", "22", "21", "20", "19", "5", "6", "31",
"7", "30", "8", "9", "33", "10", "32", "29", "11", "28",
"12", "13", "34", "27", "18", "14", "17", "15", "16")), row.names = c(NA,
-34L), class = c("tbl_df", "tbl", "data.frame")), extraInfo = structure(list(), class = c("tbl_df",
"tbl", "data.frame"), row.names = integer(0), .Names = character(0)),
tip_seq = NULL, anc_seq = NULL, seq_type = character(0),
tipseq_file = character(0), ancseq_file = character(0), info = list())))