---
# System prepended metadata

title: Kara's code

---

# Kara's code


# Metabarcoding-of-human-guts
Fecal microbiota transplant (FMT) study. Metabarcoding of human guts.
# Name:
Kara Frasier
# Code
```
conda activate genomics

cd Metabarcoding-of-human-guts/

cp  /tmp/gen711_project_data/fastp-single.sh ~/fastq-single.sh

chmod +x ~/fastq-single.sh

./fastp-single.sh 120 /tmp/gen711_project_data/FMT_3/fmt-tutorial-demux-2 import_fastp
 
./fastp-single.sh 120 /tmp/gen711_project_data/FMT_3/fmt-tutorial-demux-1 import_fastp2
```
 
## Qiime conda and data import 
```
conda activate qiime2-2022.8

qiime tools import --type "SampleData[SequencesWithQuality]" --input-format CasavaOneEightSingleLanePerSampleDirFmt --input-path import_fastp --output-path import_qiime1

qiime tools import --type "SampleData[SequencesWithQuality]" --input-format CasavaOneEightSingleLanePerSampleDirFmt --input-path import_fastp2 --output-path import_qiime2
```
## Cutadapt
```
### import 1
qiime cutadapt trim-single \
    --i-demultiplexed-sequences import_qiime1.qza \
    --p-front TACGTATGGTGCA \
    --p-discard-untrimmed \
    --p-match-adapter-wildcards \
    --verbose \
    --o-trimmed-sequences import_cutadapt1

qiime demux summarize --i-data import_cutadapt1.qza --o-visualization import_demux1


### import 2
qiime cutadapt trim-single \
    --i-demultiplexed-sequences import_qiime2.qza \
    --p-front TACGTATGGTGCA \
    --p-discard-untrimmed \
    --p-match-adapter-wildcards \
    --verbose \
    --o-trimmed-sequences import_cutadapt2

qiime demux summarize --i-data import_cutadapt2.qza --o-visualization import_demux2
```

## Denoising
```
qiime dada2 denoise-single \
    --i-demultiplexed-seqs import_cutadapt1.qza 
    --p-trunc-len 125 \
    --p-trim-left 0 \
    --p-n-threads 4 \
    --o-denoising-stats denoising-stats1.qza \
    --o-table feature_table1.qza \
    --o-representative-sequences rep-seqs1.qza

qiime dada2 denoise-single \
    --i-demultiplexed-seqs ? \ 
    --p-trunc-len ? \
    --p-trim-left ? \
    --p-n-threads ? \
    --o-denoising-stats ? \
    --o-table ? \
    --o-representative-sequences ?

## Merge rep-seqs1/2 and feature_table1/2 

## rep-seqs
qiime feature-table merge-seqs \
    --i-data rep-seqs1.qza
   --i-data rep-seqs2.qza \
   --o-merged-data rep-seqs.qza

## For FMT, merge feature tables
qiime feature-table merge \
  --i-tables ? \
  --i-tables ? \
  --o-merged-table results/feature_table.qza
```
# Taxonomy
```
qiime feature-classifier classify-sklearn \
    --i-classifier /tmp/gen711_project_data/reference_databases/classifier.qza \
    --i-reads rep-seqs.qza \
    --o-classification FMT-taxonomy.qza
    
qiime taxa barplot \
    --i-table feature_table.qza \
    --i-taxonomy FMT-taxonomy.qza \
    --m-metadata-file sample-metadata.tsv \
    --o-visualization barplot-1.qzv

```



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

qiime diversity core-metrics-phylogenetic \
  --i-phylogeny rooted-tree.qza \
  --i-table feature_table.qza \
  --p-sampling-depth 500 \
  --m-metadata-file metadata.tsv  \
  --p-n-jobs-or-threads 4 \
  --output-dir core-metrics
  
qiime feature-table relative-frequency \
  --i-table core-metrics/rarefied_table.qza \
  --o-relative-frequency-table core-metrics/relative_rarefied_table

qiime diversity pcoa-biplot \
  --i-features core-metrics/relative_rarefied_table.qza \
  --i-pcoa core-metrics/unweighted_unifrac_pcoa_results.qza \
  --o-biplot core-metrics/unweighted_unifrac_pcoa_biplot

qiime emperor biplot \
  --i-biplot core-metrics/unweighted_unifrac_pcoa_biplot.qza \
  --m-sample-metadata-file metadata.tsv \
  --o-visualization core-metrics/unweighted_unifrac_pcoa_biplot
  
qiime diversity alpha-group-significance \
  --i-alpha-diversity core-metrics/shannon_vector.qza \
  --m-metadata-file metadata.tsv \
  --o-visualization core-metrics/alpha-group-significance

qiime diversity beta-group-significance \
  --i-distance-matrix core-metrics/unweighted_unifrac_distance_matrix.qza \
  --m-metadata-file metadata.tsv \
  --m-metadata-column <column_in_metadata_that_groups_replicates>  \
  --p-pairwise \
  --o-visualization core-metrics/unweighted_unifrac-beta-group-significance
```
  
# to download a .qzv file to visualize at qiime-view
```
(at RON): realpath file-to-download.qzv
/file/path/to/your/qzv
  
(from your computer)our computer)our computer)sftp  username@ron....
(from your computer) get /file/path/to/your/*.*qzv
