## Overview

Running MIDAS can be conceptually broken down in three steps:  
1) run MIDAS per sample: `run_midas.py [species, genes, snps]`  
 -run_midas.py species should be run prior to genes or snps
 -run_midas.py genes and snps are independent of eachother and do not need to both be run  

2) merge results across samples: `merge_midas.py [species, genes, snps]`  
 -creates output files that can facilitate comparative analysis across samples and species/genes/snps  

3) analyze results: `gene_diversity.py, snp_sharing.py, etc.`  
 -these are the scripts currently in `/path/to/MIDAS/scripts/analysis`
 -at the moment they experimental but will be available directly on `/path/to/MIDAS/scripts` in the next update

First, move to the example directory and create a new directory to store per-sample outputs:  
`cd MIDAS/example`  
`mkdir samples`  

## Run MIDAS per-sample

For options, examples, and more info, use the `-h` flag:  
`run_midas.py -h`  
`run_midas.py species -h`  
`run_midas.py genes -h`  
`run_midas.py snps -h`   

Basic command usage (see below for details):  
 `run_midas.py {species, genes, snps} outdir [options]`
 
1) Profile species abundances**  
`run_midas.py species samples/sample_1 -1 sample_1.fq.gz`  
`run_midas.py species samples/sample_2 -1 sample_2.fq.gz`

2) Profile strain-level gene content of abundant species
`run_midas.py genes samples/sample_1 -1 sample_1.fq.gz`  
`run_midas.py genes samples/sample_2 -1 sample_2.fq.gz` 

3) Profile strain-level nucleotide variants of abundant species  
`run_midas.py snps samples/sample_1 -1 sample_1.fq.gz`  
`run_midas.py snps samples/sample_2 -1 sample_2.fq.gz` 

## Merge MIDAS results across samples

For options, examples, and more info, use the `-h` flag:  
`merge_midas.py -h`  
`merge_midas.py species -h`  
`merge_midas.py genes -h`  
`merge_midas.py snps -h`   

Basic command usage (see below for details):  
 `merge_midas.py {species, genes, snps} outdir -i input -t intype [options]`
 `-i` indicates the sample directories output by run_midas.py  
 `-t` indicates the input type

1) Merge species abundance across samples
`merge_midas.py species ./merged_species -i samples/sample_1,samples/sample_2 -t list`   
The results will be in the folder named `./merged_species`, and it will contain four files:
count_reads.txt
coverage.txt
relative_abundance.txt
species_prevalence.txt

2) Merge strain-level pan-genome results across samples
`merge_midas.py genes ./merged_genes -i samples/sample_1,samples/sample_2 -t list`  
The results will be in a folder named `./merged_genes`, which will contain a sub-folder for each species that satisfies the coverage criterion for inclusion.

3) Merge strain-level nucleotide variant results across samples
`merge_midas.py snps ./merged_snps -i samples/sample_1,samples/sample_2 -t list`  
The results will be in a folder named `./merged_snps`, which will contain a sub-folder for each species that satisfies the coverage criterion for inclusion.
