Experimental set-up and sample collection in an aquaculture setting
The Atlantic salmon (Salmo salar) In vivo feed trial was performed by MOWI ASA at their research site in Averøy, Norway. Prior to commencement of the feed trial, salmon were fed on a fish meal diet (FMD) until they reached circa 750 grams in mass. Fish were separated into 5x5 meter marine pens (150 randomly distributed fish per pen) in 4x4 modular design. Four pens were randomly assigned to each of the trial diets. This study focused on eight pens housing fish fed on FMD and fish meal free diet (FMF) (Supplementary Table 1, Figure 1D). The feed trial was conducted over five months (November 2017 - March 2018). For in vivo samples recovered from actual salmon, three randomly selected fish were collected at the end of the feed trial for two different feeds (N=3 fish/feed) and sacrificed by MOWI employees. After, samples from three salmon gut compartments were collected (stomach (N=3/feed), pyloric caeca (N=3/feed) and mid gut (N=3/feed) (approximately 20 cm from the vent)), placed into 1.5 ml cryovials and kept on ice before long term storage in -80oC conditions. For in vitro initial inoculum samples (the founding community for SalmoSim runs), a further three fish fed on FMD were sacrificed and samples from three distinct gut compartments were collected (Stomach (N=3), pyloric caecum (N=3) and midgut (N=3)), transferred to 15 ml Falcon tubes containing 30% glycerol and kept on ice before long term storage in -80oC conditions. Details of samples collected from farmed Atlantic salmon have been described previously .
In vitro feed trial within SalmoSim system
Physicochemical conditions within Atlantic salmon gastrointestinal tract and microbiome sampling
Physicochemical conditions (temperature, pH, dissolved oxygen) were directly measured in adult Atlantic salmon from Mowi salmon farm in Loch Linnhe, Scotland (Supplementary Figure 1A-C). Bacterial inoculums were prepared for the in vitro trial from the different gut compartments sampled from individual fish (three biological replicates, three gut compartments per fish – stomach, pyloric caecum and midgut) collected at the start of the in vivo feed trial in Averøy, Norway. Prior to SalmoSim inoculation, inoculums that were stored in 15 ml falcon tubes containing 30% glycerol solution in -80oC freezer were dissolved in 1 ml of autoclaved 35 g/L Instant Ocean® Sea Salt solution. Distinct individual fish collected in Averøy formed the founder community for each distinct replicate of the in vitro trial (i.e., a true biological replicate (Figure 1)).
In vitro system ‘feed’ preparation
In vitro system feed media was prepared by combining the following for a total of 2 litres: 35 g/L of Instant Ocean® Sea Salt, 10 g/L of the FMD or FMF used in the MOWI feed trial (Supplementary Table 1), 1 g/L freeze-dried mucous collected from the pyloric caecum and 2 litres of deionised water. This feed was then autoclave-sterilised, followed by sieving of the bulky flocculate, and finally subjected to the second round of autoclaving.
In vitro system preparation
Three 500 ml Applikon Mini Bioreactors were filled with four 1cm3 cubes made from sterile aquarium sponge filters used as a surface for biofilm formation, assembled by attaching appropriate tubing and probes (redox, temperature, and dissolved oxygen, Figure 1A), and autoclaved. Bioreactor preparation was followed by attachment of reactor vessels to the Applikon electronic control module, connection of feed and acid and base bottles (0.01M hydrochloric acid and 0.01M sodium hydroxide solutions filtered through 0.22µm polyethersulfone membrane filter unit (Millipore, USA)). Nitrogen gas was periodically bubbled through each vessel to maintain anaerobic conditions and dissolved oxygen continually monitored. The bioreactors were then allowed to fill with 400 ml of feed media. Once the system was set up, media transfer, gas flow and acid/base addition occurred for 24 hours in sterile conditions (without microorganisms present in the system) in order to stabilise the temperature, pH, and oxygen concentration with respect to levels measured from adult salmon.
Initial pre-growth period during in vitro trial
In order to allow bacterial communities to proliferate in the in vitro environment without washing through the system, the microbial populations within the inoculum from real salmon were pre-grown inside the SalmoSim system for four days. During this phase, the system was filled with FMD media preparation and inoculum, and no media transfer occurred.
Performing feed trial within SalmoSim system
After the initial pre-growth period, each validation experiment was run for 20 days while supplying SalmoSim system with FMD. After 20 days, SalmoSim was run for 20 additional days while supplying FMF food. During the full 44-day experiment (4-day pre-growth period, 20-day system fed on FMD, and 20-day system fed on FMF) physiochemical conditions within three SalmoSim gut compartments were kept similar to the values measured in real salmon: temperature inside the reactor vessels were maintained at 12oC, dissolved oxygen contents were kept at 0% by daily flushing with N2 gas for 20 minutes, and pH was kept stable in each bioreactor by the addition of 0.01M NaOH and 0.01M HCl (stomach pH 4.0, pyloric caecum pH 7.0, and mid intestine pH 7.6). During this experiment (apart from the pre-growth period) the transfer rate of slurry between reactor vessels was 238 ml per day (5% of the total bioreactor volume - the maximum volume of sampling without disturbing microbial community structure). Finally, 1 ml of filtered salmon bile and 0.5 ml of sterile 5% mucous solution were added daily to the reactor simulating the pyloric caecum compartment. The schematic representation of SalmoSim system is visualised in Figure 1A and full feed trial within SalmoSim is visually summarised in Figure 1B and C.
Sampling was performed in several steps. First, samples from initial inoculums were collected for each gut compartment. Once SalmoSim main experiment started, the sampling from each bioreactor vessel was performed every second day throughout the 40-day run period (20 samplings in total). The SalmoSim samplings entailed collecting 30 ml of the bioreactor contents into 50 ml falcon tubes, centrifuging them for 10 minutes at 5000 rpm speed, and freezing the pellets at -20oC for storage.
Measuring nitrogen metabolism within the SalmoSim system
At each sampling point, the protein concentration in each chamber of the system was measured using Thermo Scientific™ Pierce™ BCA Protein Assay Kit (Thermo Fisher Scientific, USA) and the ammonia concentration using Sigma-Aldrich® Ammonia Assay Kit (Sigma-Aldrich, USA) to assay the bacterial community activity. Both methods were performed according to manufacturer protocol by using The Jenway 6305 UV/Visible Spectrophotometer (Jenway, USA).
Measuring Volatile Fatty Acid (VFA) production in SalmoSim
The last two time points for each diet were selected from the SalmoSim system (for all three gut compartments) for VFA analysis: 18 and 20 for FMD; and time points 38 and 40 for FMF, respectively, to ensure that the bacterial communities had enough time to adapt to SalmoSim system (for FMD time points) and the feed change (for FMF time points). During runs, 1ml of supernatant from SalmoSim bioreactors was frozen in -80°C which, was then used for VFA extraction. The protocol involved combining 1ml of supernatant with 400µl of sterile Phosphate-buffered saline (PBS) solution (Sigma Aldrich, USA) and vortexing the mixture for 1 minute. The sample was then centrifuged at 16,000 g for 30 minutes, followed by two rounds of supernatant removal, before centrifuging at 16,000 g for 30 minutes. Finally, the supernatant was then filtered through 0.2µm Costar SpinX centrifuge tube filters (Corning, USA) at 15,000 g for 2 minutes until clear. The extracted VFAs were sent for gas chromatographic analysis at MS-Omics (Denmark). In order to determine if the VFA concentrations were statistically different between SalmoSim fed on FMD and FMF diets, measured VFA values dataset were subjected to statistical analysis using linear mixed effect models (See Supplementary methods 2). Results are shown in supplementary Figure 6.
In vivo phenotypic fish performance fed on two different feeds
Phenotypic performance data (fish length, weight, gutted weight, carcass yield, gonad, and liver weights) was collected and provided at the end of the in vivo feed experiment by MOWI. The differences between each feed group (n=32 fish per feed) for each phenotype were visualised and statistical analysis was applied (independent two-sample t-test) to identify statistically significant differences between the two feed groups.
Measuring bacterial population dynamics in SalmoSim
Genomic DNA extraction
The DNA extraction protocol followed was previously described by . In short, samples were subjected to a bead-beating step for 60 seconds by combining samples with MP Biomedicals™ 1/4" CERAMIC SPHERE (Thermo Fisher Scientific, USA) and Lysing Matrix A Bulk (MP Biomedicals, USA). Later, DNA was extracted by using the QIAamp® DNA Stool kit (Qiagen, Valencia, CA, USA) according to the manufacturer’s protocol .
NGS library preparation and sequencing
In the first instance, microbial population dynamics in SalmoSim were measured in near real-time using a set of qPCR primers including published and custom sequences to enable the stability of the system to be monitored (See supplementary Methods 1 and data Supplementary Figure 3). Subsequently 16S rRNA sequencing was deployed to provide a fuller picture community dynamics. The commonly used 16S ribosomal hypervariable region 4 primers were shown to cross-amplify Salmo salar 12S ribosomal gene sequences [21,23] and hence were not used in this study. Rather, amplification of the 16s V1 hypervariable region was adopted as an alternate approach . Amplification of 16S V1 hypervariable region from diluted DNA samples was achieved using redundant tagged barcode 27F and 338R at final concentration of 1 pM of each primer. Primer sequences are summarised in Supplementary Table 3. First-round PCR was performed in triplicate on each sample and reaction conditions were 95°C for ten minutes, followed by 25 cycles at 95°C for 30 seconds, 55°C for 30 seconds and 72°C for 30 seconds, followed by a final elongation step of 72°C for 10 minutes. After the triplicate reactions were pulled together into one, their concentration was measured using a Qubit® fluorometer (Thermo Fisher Scientific, USA), and all of them were diluted to 5ng/µl using Microbial DNA-Free Water (Qiagen, Valencia, CA, USA). The second-round PCR, which enabled the addition of the external multiplex identifiers (barcodes), involved only six cycles with otherwise identical reaction conditions to the first. The detailed composition of second-round PCR primers is summarised in Supplementary Table 4. This was followed by the DNA clean-up using Agencourt AMPure XP beads (Beckman Coulter, USA) according to the manufacturers' protocol. The cleaned DNA was then gel-purified by using the QIAquick Gel Extraction Kit (Qiagen, Valencia, CA, USA) and then quantified by using Qubit® (Thermo Fisher Scientific, USA). All the PCR products were pulled together at 10nM concentration and sent for sequencing using HiSeq 2500.
Bioinformatic analysis of 16S rRNA gene amplicon sequencing data
Sequence analysis was performed with our bioinformatic pipeline as described previously with slight modifications . First, quality filtering and trimming (>Q30 quality score) was performed on all the reads of the 16s rRNA V1 hypervariable region using Sickle version V1.2 software . Second, read error correction was performed using the BayesHammer module within SPAdes V2.5.0 software to obtain high-quality assemblies . Third, paired-end reads were merged (overlap length 50bp) using PANDAseq v2.11 software with simple_bayesian read merging algorithm [27,28]. After overlapping, paired end reads merged reads were dereplicated, sorted, and filtred chimaeras using GOLD SILVA reference dataset  and singletons were removed by using VSEARCH version 2.3.4 tool . Merged pair-end filtered reads were clustered in operational taxonomic units (OTUs) using VSEARCH software at 97% identity followed by a decontamination step by mapping OTUs against the host (Salmo salar) reference genome (available on NCBI) DNA using bwa aligner implemented in DeconSeq v0.4.3 tool . Taxonomic assignment of OTUs was achieved using the Naïve Bayesian Classifier  implemented in the QIIME 2 platform using SILVA 132 database [33,34]. Phylogenetic trees of OTUs were generated using FastTree software after using MAFFT for multiple sequence alignment . The resultant OTU table was converted to a biological observation matrix (BIOM) format for the post-OTUs statistical analysis .
Post-OTUs statistical analysis: diversity metrics and community structure and composition analysis
All statistical analysis of the OTU table was performed by using R v 4.0.1 and RStudio v 1.3.959 . Alpha diversity analysis was performed using Rhea pipeline , supplemented by microbiomeSeq , and PhyloSeq  for ANOVA and visualisation steps. Two alpha diversity metrics were calculated: microbial richness (estimated number of observed OTUs) and Shannon diversity (an estimate of balance of the community using effective Shannon index [41,42]. Before calculating effective microbial richness, proportional filtering was performed at a relative abundance of 0.25% in each community to minimise the inflation in microbial richness caused by the very low abundant OTUs. Afterwards, a one-way ANOVA of diversity between groups was calculated with the p-value threshold for significance (p-value <0.05) represented using boxplots.
To investigate the effect of time on the bacterial community stability, beta diversity analysis was performed using different phylogenetical distances metrics to assay phylogenetic similarities between samples (weighted, generalised, and unweighted UniFrac). To compare communities isolated from various sources (SalmoSim, inoculum and real salmon), only samples fed on FMD were included as initial inoculum were collected from fish fed on FMD alone. Furthermore, only SalmoSim samples from the last 3 time points fed on FDM were selected as they are considered stable time points (once bacterial communities had over two weeks to adapt and grow within SalmoSim system). In short, the resulting dataset contained: real salmon samples fed on FMD, all inoculum samples and stable SalmoSim time points fed on FMD (days 16, 18, and 20). This dataset was then subdivided into several smaller datasets that included OTUs, shared by various percentage of samples (60%, 50%, 40% and 30% of samples), with the aim of minimising the impact of rare OTUs (low prevalence) on comparisons and only focusing on prevalent OTUs between samples (see details in Supplementary Table 4).
To analyse the response of microbes to the diet change (see supplementary Table 1 for feed formulation) in real salmon and SalmoSim, in addition to the full dataset (in vivo and in vitro samples); three different full dataset subsets were used to perform beta diversity analysis: samples from in vivo study, all samples from SalmoSim (all data points), and samples only from SalmoSim once it had achieved stability (the last 3 time points fed on FMD (days: 16, 18, and 20) and FMFD (days 36, 38, and 40). These datasets were used to compute ecological (Bray-Curtis and Jaccard) and phylogenetic (unweighted, weighted, and generalised UniFrac) distances with vegdist() function from the vegan v2.4-2 package and GUniFrac() function (generalised UniFrac) from the Rhea package [38,43] Both ecological and phylogenetical distances were then visualised in two dimensions by Multi-Dimensional Scaling (MDS) and non-metric MDS (NMDS) . Finally, a permutational multivariate analysis of variance (PERMANOVA) by using calculated both distances was performed to determine if the separation of selected groups is significant as a whole and in pairs .
To provide an overall visualisation of microbial composition across all samples, a principal Coordinates Analysis (PCoA) was performed using the microbiomeSeq  package based on phyloseq package  with Bray-Curtis dissimilarity measures calculated and visualised for four different subset-datasets: the full dataset (real salmon, inoculum and all SalmoSim samples), and, three different subsets each containing only one of the free biological replicate samples from SalmoSim (Fish 1, 2, or 3), along with all real salmon and inoculum samples.
Differential abundance was calculated by using microbiomeSeq based on DESeq2 package [39,45]. BIOM generated OTU table was used as an input to calculate differentially abundant OTUs between selected groups based on the Negative Binomial (Gamma-Poisson) distribution.