I'm sure its wholey on my end!
Here are my 2 usable scripts for transposing an OTU/ESV table
library(vegan)
library(tidyverse)
rm(Ftable, OtuOb, FT_colnames, Ftable2, Ftable3)
Ftable <- read_tsv('table.feature-table_biom.tsv', col_names = TRUE, skip = 1)
names(Ftable)[names(Ftable)=="#OTU ID"] <- "Feature.ID"
Ftable <- cbind(Ftable, "observation"=1:nrow(Ftable)) #adds an indexing column 'observation'
Ftable <- Ftable %>% select(observation, everything())
OtuOb <- Ftable
OtuOb <- as.tibble(OtuOb)
write_tsv(OtuOb, "OtuToObservationReference.tsv")
Ftable <- Ftable[,-2]
and another for altering how taxonomy tables are formatted (eg it separates taxonomy into its taxonomic levels making working with R much easier if you wanted to display this information)
library(tidyverse)
library(vegan)
rm(taxonomy, taxonomyInt, taxonomySep) #to delete any data with those names
taxonomy <- read_tsv("taxonomy.tsv", col_names = TRUE)
taxonomyInt <- taxonomy %>% separate(Taxon, into = c("K", "P"), extra = "drop", sep = "p_")
taxonomyInt <- taxonomyInt %>% separate(P, into = c("P", "C"), extra = "drop", sep = "c_")
taxonomyInt <- taxonomyInt %>% separate(C, into = c("C", "O"), extra = "drop", sep = "o_")
taxonomyInt <- taxonomyInt %>% separate(O, into = c("O", "F"), extra = "drop", sep = "f_")
taxonomyInt <- taxonomyInt %>% separate(F, into = c("F", "G"), extra = "drop", sep = "g_")
taxonomySep <- taxonomyInt %>% separate(G, into = c("G", "S"), extra = "drop", sep = "s_")
taxonomySep <- as.data.frame(taxonomySep)
taxonomySep <- data.frame(lapply(taxonomySep, function(taxonomySep) {gsub("k_", "", taxonomySep)}))
taxonomySep <- data.frame(lapply(taxonomySep, function(taxonomySep) {gsub("_", "Z_", taxonomySep)}))
taxonomySep <- data.frame(lapply(taxonomySep, function(taxonomySep) {gsub(";", "Z_", taxonomySep)}))
taxonomySep <- data.frame(lapply(taxonomySep, function(taxonomySep) {gsub("Z_Z_", NA, taxonomySep)}))
taxonomySep <- data.frame(lapply(taxonomySep, function(taxonomySep) {gsub("Z_", "", taxonomySep)}))
taxonomySep[taxonomySep == ""] <- NA
taxonomySep <- data.frame(lapply(taxonomySep, function(taxonomySep) {gsub("\\[", "", taxonomySep)}))
taxonomySep <- data.frame(lapply(taxonomySep, function(taxonomySep) {gsub("]", "", taxonomySep)}))
taxonomySep[taxonomySep == "Unassigned"] <- NA
taxonomySep <- data.frame(lapply(taxonomySep, function(taxonomySep) {gsub(" ", "", taxonomySep)}))
taxonomySep #To check that its removed all the crap
write_tsv(taxonomySep, "taxonomySep.tsv")
rm(taxonomy, taxonomyInt)
Like I said I am NOT a competent R user, but hopefully this will be useful to @Sirtaj-Singh, alternatively I am happy to upload it as a more tutorial based format and people wanted to add to it or improve it where they can?