Hello everyone,
I have a taxonomy table that I intend to merge with the OTU table using tools in the RStudio environment. However, before doing this, I would like to modify the taxonomies that contain "unclassified," "uncultured," and "NA" in columns of different ranks by adding the previous taxonomy to them. This way, the taxonomy would look like: Proteobacteria_uncultured; Bacteroidota_uncultured... To achieve this, I am trying to use some tools from the dplyr
package, but only the Species column is being modified. The columns with the other taxonomic classifications are not being changed. The code I am using is structured as follows:
# Modify "unclassified" or "uncultured" taxonomies
modified_data <- processed_data %>%
mutate(across(Kingdom:Species, ~ ifelse(. %in% c("unclassified", "uncultured", "NA"),
paste(lag(.), ., sep = "_"), .)))
What could be going wrong with the code above? Has anyone done a similar modification before and could assist me?
Thanks so much,
Jessy