microsud / microbiomeutilities

The is mostly a wrapper tool using phyloseq and microbiome R packages.
https://microsud.github.io/microbiomeutilities/
Other
33 stars 7 forks source link

format_to_besthit edit #180

Closed sjhardisty closed 2 years ago

sjhardisty commented 2 years ago

Hello! Thank you for this package it has been really helpful.

I was trying to use the format_to_besthit to add arrows to my ordination plot. My tax table includes the string of bases instead of a name, so that complicates seeing the actual bacteria genus on the graph. I tried exporting the mds an deleting the string, re uploading and putting it into the phyloseq object/ordination with errors.
Thanks!

Code with ps2f taxtable and orddi edits

ps1 <- ps_shrimp ps2 <- tax_glom(ps1, "Genus") ps2f <- format_to_besthit(ps2, prefix="OTU-") orddi <- ordinate(ps2f, method = "NMDS", distance = "bray")

alltaxa <- ps2f@tax_table alltaxa <- as.list.data.frame(alltaxa) rownamesalltaxa <- rownames(alltaxa) write.csv(alltaxa,"Miseq2/alltaxa.csv", row.names = FALSE)

=TRIM(RIGHT(G2, LEN(G2) - SEARCH(":", G2))) alltaxa <- as.matrix(alltaxa)

write.csv(rownamesalltaxa,"Miseq2/rownamesalltaxa.csv", row.names = FALSE) rownamesalltaxa <- as.data.frame(rownamesalltaxa)

change names in excel using =TRIM(RIGHT(A2, LEN(A2) - SEARCH(":", A2))) and re upload rownames(alltaxa) <- rownamesalltaxa$X1 *rename alltaxa rows with the edited cut off alltaxa <- tax_table(alltaxa)

species <- orddi$species species_genus <- rownames(species) write.csv(species,"Miseq2/species_genus.csv", row.names = FALSE)

change names in excel using =TRIM(RIGHT(A2, LEN(A2) - SEARCH(":", A2))) and re upload

ps2f@tax_table <- alltaxa rownames(species) <- species_genus$X1 orddi$species <- species

p <- plot_ordination_utils(ps2f, orddi, color = "Neotrypaea", plot.arrow = TRUE, scale.arrow = 1.3, top.taxa = 10 )

}

p

Error if I try to create a tax table with edited rownames:

rownames(alltaxa) <- rownamesalltaxa$x #rename alltaxa rows with the edited cut off Warning: Setting row names on a tibble is deprecated. Warning: non-unique values when setting 'row.names': ‘endosymbionts’, ‘Incertae Sedis’ Error in .rowNamesDF<-(x, value = value) : duplicate 'row.names' are not allowed

Error if I edit best_hit in the tax table + species in orddi:

p <- plot_ordination_utils(ps2f, orddi, color = "Neotrypaea", plot.arrow = TRUE, scale.arrow = 1.3, top.taxa = 10 ) Species coordinates not found directly in ordination object. Attempting weighted average (vegan::wascores)

Main Issue: Labels!

image

microsud commented 2 years ago

Hi! This function is not supported anymore. I would suggest to check the microViz package for high level functionality for ordination plots. https://david-barnett.github.io/microViz/articles/web-only/ordination.html

Best wishes, Sudarshan