-
Notifications
You must be signed in to change notification settings - Fork 1
Manual: abundance table generation with R
Smutin Daniil edited this page Jun 6, 2025
·
1 revision
You can use the R package samovaR to perform data augmentation
# from .csv abundance table
data <- read_samovar("path/to/abundance_table.csv")
# from abundance table
data <- table2samovar(abundance_table)
# from phyloseq
data <- phyloseq2samovar(phyloseq_data)If you want to use your abundance file, skip this stage
data <- GMrepo_type2data(mesh_ids)
#or to use with run list:
data <- GMrepo_run2data(runs)Output - SAMOVAR object
On this stage, you can split your data into groups and filter it using metadata
data %>% samovar_preprocess()
# Similar to:
## samovar_raw %>%
## teatree_trim() %>%
## tealeaves_pack() %>%
## teabag_brew() %>%
## concotion_pour()This stage include:
- data filtration
- normalization
- database builidng
new_data <- samovar_data %>% samovar_boil(N = 100)Output - SAMOVAR object
You also can use our web application
datasets <- list()
generate_dataset <- function(meshID) {
message(meshID)
data <- meshID %>%
GMrepo_type2data(number_to_process = 1500)
build <- data %>%
samovar_preprocess(min_cluster_size = 20,
treshhold_amount = 10^(-5),
treshhold_species = 5,
treshhold_samples = 5)
datasets[[meshID]] <- build
new_data <- build %>%
samovar_boil(N = 200)
result <- rbind(
data$data %>%
rownames_to_column("sp") %>%
pivot_longer(-1, names_to = "run") %>%
mutate(type = "initial", meshID = meshID),
new_data$data %>%
rownames_to_column("sp") %>%
pivot_longer(-1, names_to = "run") %>%
mutate(type = "generated", meshID = meshID)
)
return(result)
}
meshIDs <- c(
"D006262",
"D003967",
"D000855",
"D003863",
"D015179"
)
results <- tibble()
for(meshID in meshIDs){
tmp <- generate_dataset(meshID)
results <- rbind(results, tmp)
}results_ord <- function(type) {
wide <- results %>%
subset(type == type) %>%
mutate(fn = paste(run,
#type,
meshID)) %>%
pivot_wider(id_cols = sp, values_from = value, values_fill = 0, names_from = fn) %>%
column_to_rownames("sp") %>%
subset(apply(., 1, sum) > 1)
wide_dist <- wide %>%
t %>%
subset(apply(., 1, sum) > .1) %>%
vegan::vegdist() %>%
ecodist::pco()
wide_dist$vectors %>%
as.data.frame() %>%
select(X1, X2) %>%
rownames_to_column("tp") %>%
mutate(disease = tp %>% str_remove(".* ")) %>%
ggplot() +
theme_bw() +
geom_point(aes(color = disease, X1, X2)) +
xlab("PC1") + ylab("PC2") +
scale_color_brewer("",palette = "Set2")
}