Open AngelicaMiraples opened 4 months ago
Just realized, I would probably need to change all the other components of the ps object in addition to the otu_table, such as the tax_table, phy_tree, and refqseq. Is there perhaps an easier way to do this?
@AngelicaMiraples I think you want to use taxa_names
accessor to get/set taxa names robustly, across all the relevant components of the phyloseq object. When you modify just the otu_table, it doesn't affect the other components, and it will either break the phyloseq object, or the mismatched taxa names will be removed. This seems to work for me:
taxa_names(ps)[[X]] <- "foo"
Hi Benji, thanks for your reply! Will try this out :)
Best, Angelica
Hello!
I am working in Rstudio and have found that a small number of my ASVs are likely subtypes: They have the same taxonomic assignment and are 100% exact matches when blasted, but only vary in length by one or two nucleotides.
I would like to rename such ASVs with a "-1" ,"-2" etc or "a", "b" etc to distinguish them but I'm having a bit of trouble.
I first extract the otu table from the ps object
otu <- otu_table(ps) # taxa are rows = true
Then I check to make sure the ASV is present as a row name
otu["ASV1"]
Here is an example of what is returned for samples 10-20 out of 172
To rename ASV1 to ASV1-1 and check:
rownames(otu)[rownames(otu) == "ASV1"] = "ASV1-1"
otu["ASV1-1"]
Replacing existing otu table with new ASV1-1 containing table
otu_table(ps) <- otu
When checking if I can index ASV1-1, there is an error.
And I am left with one taxa less than when I started:
Any idea why this ASV is being removed after making this modification? Any suggestions how to fix this?
Best, Angelica