---
# System prepended metadata

title: Shark Project Code

---

# Shark Project Code
-- Antrita Manduva 


*9/26/22* 

The first step was to run quality checks on my data, which was done following this tutorial (https://hackmd.io/@elperedoStudents/SkrHIBzSw).

I adhered to this tutorial (https://hackmd.io/@MAE-MBL/HylpoaOF5#Visualizing-your-results) for the most part in qiime2 analysis. My teammate Liuhao filtered and clustered the data, and I picked up from the taxonomic classication step. 

As my project is occupied with looking at the skin microbiome vs the environmental surface micorbiome, I filtered for these variables on the metadata file. The columns of interest are Species and Region. I created a new column called "keep1" to filter based on the metadata.

I also filtered out the eukaryotic DNA by removing the mitochondrial and chloroplast DNA from the sample. 

The first step is to run/start qiime!

/

**Metadata Filtering**

```
qiime taxa filter-table --i-table table.qza  --i-taxonomy taxonomy.qza --p-exclude mitochondria,chloroplast  --o-filtered-table table-no-mitochondria-no-chloroplast.qza

qqiime feature-table summarize  --i-table table-no-mitochondria-no-chloroplast.qza  --o-visualization table-no-mitochondria-no-chloroplast.qzv  --m-sample-metadata-file metadata.tsv
  
qiime feature-table summarize  --i-table table-no-mitochondria-no-chloroplast.qza  --o-visualization table-no-mitochondria-no-chloroplast.qzv   --m-sample-metadata-file metadata.tsv

qiime feature-table filter-samples  --i-table table-no-mitochondria-no-chloroplast.qza  --m-metadata-file metadata.tsv   --p-where "[keep1]='yes'"  --o-filtered-table table-filtered-no-mitochondria-no-chloroplast.qza

qiime feature-table summarize  --i-table table-filtered-no-mitochondria-no-chloroplast.qza  --o-visualization table-filtered-no-mitochondria-no-chloroplast.qzv   --m-sample-metadata-file metadata.tsv

```

/

**Rarefaction Curves**

```
qiime diversity alpha-rarefaction   --i-table table-no-mitochondria-no-chloroplast.qza --p-max-depth 65000  --m-metadata-file metadata.tsv  --o-visualization alpha-rarefaction.qzv

qiime diversity alpha-rarefaction   --i-table table-no-mitochondria-no-chloroplast.qza --p-max-depth 8000  --m-metadata-file metadata.tsv  --o-visualization alpha-rarefaction2.qzv

qiime diversity alpha-rarefaction   --i-table table-no-mitochondria-no-chloroplast.qza --p-max-depth 10000  --m-metadata-file metadata.tsv  --o-visualization alpha-rarefaction2.qzv

```

/

**Alpha Diversity**

Below is the code for the plots for the Chao1 metric and Simpson's evenness index.

```
qiime diversity alpha --i-table  table-filtered-no-mitochondria-no-chloroplast.qza --p-metric chao1 --o-alpha-diversity ALPHA-chao1-vector.qza

qiime diversity alpha-group-significance --i-alpha-diversity ALPHA-chao1-vector.qza --m-metadata-file metadata.tsv --o-visualization ALPHA-chao1-group-significance.qzv

qiime diversity alpha --i-table  table-filtered-no-mitochondria-no-chloroplast.qza --p-metric simpson_e --o-alpha-diversity ALPHA-simpson_e-vector.qza

qiime diversity alpha-group-significance --i-alpha-diversity ALPHA-simpson_e-vector.qza --m-metadata-file metadata.tsv --o-visualization ALPHA-simpson_e-group-significance.qzv 

```

/

**Beta Diversity**

Normalizing by rarefaction:

```
qiime feature-table rarefy  --i-table table-filtered-no-mitochondria-no-chloroplast.qza --p-sampling-depth 8000 --p-with-replacement --o-rarefied-table table-filtered-no-mitochondria-no-chloroplast-rarefied.qza

qiime feature-table summarize  --i-table table-filtered-no-mitochondria-no-chloroplast-rarefied.qza  --o-visualization table-filtered-no-mitochondria-no-chloroplast-rarefied.qzv --m-sample-metadata-file metadata.tsv

```

Normalizing by relative frequency: 

```
qiime feature-table relative-frequency --i-table table-filtered-no-mitochondria-no-chloroplast.qza --o-relative-frequency-table table-filtered-no-mitochondria-no-chloroplast-frequency.qza

qiime feature-table summarize  --i-table table-filtered-no-mitochondria-no-chloroplast-frequency.qza  --o-visualization table-filtered-no-mitochondria-no-chloroplast-frequency.qzv --m-sample-metadata-file metadata.tsv

qiime tools export   --input-path table-filtered-no-mitochondria-no-chloroplast-frequency.qza  --output-path ASV-table-filtered-no-mitochondria-no-chloroplast-frequency

biom convert -i ASV-table-filtered-no-mitochondria-no-chloroplast-frequency/feature-table.biom -o ASV-table-filtered-no-mitochondria-no-chloroplast-frequency/feature-table.tsv --to-tsv

```

Phylogenetic Tree:

```
qiime phylogeny align-to-tree-mafft-fasttree --i-sequences rep-seqs.qza --o-alignment aligned-rep-seqs.qza --o-masked-alignment masked-aligned-rep-seqs.qza --o-tree unrooted-tree.qza  --o-rooted-tree rooted-tree.qza --p-n-threads 4

```

Core Metrics: 

```
qiime diversity core-metrics-phylogenetic --i-phylogeny rooted-tree.qza   --i-table table-filtered-no-mitochondria-no-chloroplast-rarefied.qza --p-sampling-depth 8000   --m-metadata-file metadata.tsv --output-dir core-metrics-results

qiime diversity beta-group-significance  --i-distance-matrix core-metrics-results/unweighted_unifrac_distance_matrix.qza  --m-metadata-file metadata.tsv  --m-metadata-column Species_Region  --o-visualization core-metrics-results/unweighted-unifrac-Species_Region-significance.qzv  --p-pairwise

qiime diversity beta-group-significance  --i-distance-matrix core-metrics-results/weighted_unifrac_distance_matrix.qza  --m-metadata-file metadata.tsv  --m-metadata-column Species_Region  --o-visualization core-metrics-results/weighted-unifrac-Species_Region-significance.qzv  --p-pairwise

qiime diversity beta-group-significance  --i-distance-matrix core-metrics-results/bray_curtis_distance_matrix.qza  --m-metadata-file metadata.tsv  --m-metadata-column Species_Region  --o-visualization core-metrics-results/bray_curtis-Species_Region-significance.qzv  --p-pairwise

qiime diversity beta-group-significance  --i-distance-matrix core-metrics-results/jaccard_distance_matrix.qza  --m-metadata-file metadata.tsv  --m-metadata-column Species_Region  --o-visualization core-metrics-results/jaccard-Species_Region-significance.qzv  --p-pairwise

```
/

Taxonomic Analyses:

```
qiime taxa barplot   --i-table table-filtered-no-mitochondria-no-chloroplast.qza   --i-taxonomy taxonomy.qza   --m-metadata-file metadata.tsv   --o-visualization taxa-bar-plots-filtered-no-mitochondria-no-chloroplast.qzv

qiime tools export   --input-path table-filtered-no-mitochondria-no-chloroplast.qza  --output-path ASV-table-filtered-no-mitochondria-no-chloroplast

biom convert -i ASV-table-filtered-no-mitochondria-no-chloroplast/feature-table.biom -o ASV-table-filtered-no-mitochondria-no-chloroplast/feature-table.tsv --to-tsv

qiime taxa collapse  --i-table table-filtered-no-mitochondria-no-chloroplast.qza --i-taxonomy taxonomy.qza   --o-collapsed-table table-collapsed-filtered-no-mitochondria-no-chloroplast-level6.qza --p-level 6

qiime tools export   --input-path table-collapsed-filtered-no-mitochondria-no-chloroplast-level6.qza  --output-path table-collapsed-filtered-no-mitochondria-no-chloroplast-level6

biom convert -i table-collapsed-filtered-no-mitochondria-no-chloroplast-level6/feature-table.biom -o table-collapsed-filtered-no-mitochondria-no-chloroplast-level6/feature-table.tsv --to-tsv
```

/ 

R program: 

```
merged.data <- merge (taxonomy, dog_skin, by="featured-ID")
write.csv(merged.data, file= " ", )
```

