Downloading ASV table for microbial community network analysis

Dear @Ranjith_Kumar,
a phyloseq object is just a R object that combines OTU, Taxonomy and Metadata tables (tree and sequences optionally as well). Since you always need those datasets for ASV/OTU analysis and it’s difficult to work with them individually.
At the end of the tutorial, the step: Create phyloseq object from dada2 creates a phyloseq object. This phyloseq object can be used in the shiny-phyloseq tool that I wrapped. But this is just a simple app that provides some phyloseq functions, but cannot do fancy operations ! But you can also download the phyloseq object and import it to R and use the phyloseq package to do customized operations. You can also load it into the interactive tool: jupyter notebook.

Install phyloseq: mamba create --name myenvname bioconductor-phyloseq and other packages you might need.

A simple example code to create a co-occurrence network would be:

# Load necessary libraries
library(phyloseq)
library(igraph)
library(vegan)
library(ggplot2)

# Load your phyloseq object (replace with your actual data)
# Example: ps <- readRDS("your_phyloseq_object.rds")

# Extract the OTU table from the phyloseq object
otu_table <- otu_table(ps)

# Convert the OTU table to a data frame for easier manipulation
otu_df <- as.data.frame(otu_table)
otu_df[otu_df > 0] <- 1  # Convert presence/absence data (1 if present, 0 if absent)

# Calculate the co-occurrence matrix (using a simple correlation metric, like Jaccard)
co_occurrence <- vegdist(t(otu_df), method = "jaccard")
co_occurrence_matrix <- as.matrix(co_occurrence)

# Convert the co-occurrence matrix into a correlation matrix
# Apply a threshold for the correlation, e.g., only keep values above a threshold like 0.5
threshold <- 0.5
co_occurrence_matrix[co_occurrence_matrix < threshold] <- 0

# Create an igraph object from the matrix
network_graph <- graph_from_adjacency_matrix(co_occurrence_matrix, mode = "undirected", diag = FALSE)

# Visualize the network using ggplot2 (you can customize this part)
plot(network_graph, vertex.size=5, vertex.label.cex=0.5, edge.width=0.5, main="Co-occurrence Network")

You can further adapt this to your needs.
If I find the time, I can also work on a Galaxy tool for this. But usually directly writing R code is simpler since many customizations might be needed.
Best, Paul