So this is probably just me being new at phylogenetic analyses, but I have a few, related, questions. I have a dataset and I have an overall phylogeny for the group which I am working on. I then made a phylogeny only for the species for which I have data, using the function keep.tip from the ape package. I then used the name.check, but I got all of my rows, as numbers, of my data frame return under data_not_tree, and all of my species names return under tree_not_data. I then tried again, this time importing my data as a csv rather than as an excel file, but instead found that the keep.tip function could no longer recognise the species names in the row names as what I was interested in, and it didn't return me a tree. I then thought that perhaps the issue is that I need to reorder my data, and I tried to use the ReorderData function form the evobiR package, with taxa.names = 1, as the first column of my dataset has the species names, but that only returned the following error message:

Error in `[<-`:
! Assigned data `data[which(data[, taxa.names] == tree$tip.label[i]), ]` must be
  compatible with row subscript `i`.
✖ 1 row must be assigned.
✖ Element 1 of assigned data has 2 rows.
ℹ Row updates require a list value. Do you need `list()` or `as.list()`?
Caused by error in `vectbl_recycle_rhs_rows()`:
! Can't recycle input of size 2 to size 1.
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/tibble_error_assign_incompatible_size>
Error in `[<-`:
! Assigned data `data[which(data[, taxa.names] == tree$tip.label[i]), ]` must be
  compatible with row subscript `i`.
✖ 1 row must be assigned.
✖ Element 1 of assigned data has 2 rows.
ℹ Row updates require a list value. Do you need `list()` or `as.list()`?
Caused by error in `vectbl_recycle_rhs_rows()`:
! Can't recycle input of size 2 to size 1.
---
Backtrace:
     ▆
  1. ├─evobiR::ReorderData(CDTree, ColourDiscriminationAltitude, taxa.names = 1)
  2. │ ├─base::`[<-`(`*tmp*`, i, , value = `<tibble[,3]>`)
  3. │ └─tibble:::`[<-.tbl_df`(`*tmp*`, i, , value = `<tibble[,3]>`)
  4. │   └─tibble:::tbl_subassign(x, i, j, value, i_arg, j_arg, substitute(value))
  5. │     └─tibble:::tbl_subassign_row(xo, i, value, i_arg, value_arg, call)
  6. │       ├─base::withCallingHandlers(...)
  7. │       └─tibble:::vectbl_assign(x[[j]], i, recycled_value[[j]])
  8. │         └─vctrs::vec_assign(x, i, value)
  9. ├─vctrs:::stop_recycle_incompatible_size(...)
 10. │ └─vctrs:::stop_vctrs(...)
 11. │   └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = call)
 12. │     └─rlang:::signal_abort(cnd, .file)
 13. │       └─base::signalCondition(cnd)
 14. └─tibble (local) `<fn>`(`<vctrs___>`)
 15.   └─tibble:::vectbl_recycle_rhs_rows(value, length(i), i_arg, value_arg, call)

I confess I do not really see where the error occurred, as I have checked through and all of my columns are of the same size, and none of the rows have any null values in them. But I worry that even if I were to solve this issue, name.check, and hence all of the pgls and other phylogenetic analysis I would want to do downstream, would not recognise the names in the first column of my data as the relevant species names, since it clearly seems to think that the species names are the numeric row names. So I was wondering if A) is there a way, preferably in the ape package, to make a column recognised as the the one which has the relevant species names B) is there a way to resolve the error which I get when I use the ReorderData function, or some other way to reorder the data in the data frame so it is ordered the same way as the data in the phylogeny?

I have already tried importing the data as a .csv rather than excel, but that only leads to the keep.tip function not understanding that the species I want to keep are in the row names, so I would rather if it were possible to resolve this issue without importing the data as a .csv, but if it can be done without causing problems with the keep.tip function, I am open to that too.

0

There are 0 best solutions below