# diversity analysis 

**URL:** https://forum.qiime2.org/t/diversity-analysis/4973
**Category:** User Support
**Tags:** import
**Created:** [July 10, 2018, 4:39pm UTC](https://forum.qiime2.org/t/diversity-analysis/4973 "2018-07-10T16:39:41Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![kia2094](https://forum.qiime2.org/user_avatar/forum.qiime2.org/kia2094/32/2140_2.png) [@kia2094](https://forum.qiime2.org/u/kia2094)
#### Post date: [July 10, 2018, 4:39pm UTC](https://forum.qiime2.org/t/diversity-analysis/4973/1 "2018-07-10T16:39:41Z")

</div>

Hope everyone is well. I have a problem understanding the metadata.tsv file.

I am at the diversity analysis step. I created the metadata.tsv base on examples, and entered the following code to perform diversity analysis:

qiime diversity core-metrics-phylogenetic  
--i-phylogeny rooted\_tree.qza  
--i-table table-dada2.qza  
--p-sampling-depth 500  
--m-metadata-file metadata.tsv  
--output-dir core\_metrics\_results\_folderF

The metadata.tsv is:

| #SampleID | BarcodeSequence | LinkerPrimerSequence | BodySite | Year | Month | Day | Subject | ReportedAntibioticUsage | DaysSinceExperimentStart | Description |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| #q2:types | categorical | categorical | categorical | numeric | numeric | numeric | categorical | categorical | numeric | categorical |
| C10 | CCATCTCATCCCTGCGTGTCTCCGACTCAGTTCGTGATTCGAT | CYIACTGCTGCCTCCCGTAG | saliva | 2018 | 10 | 28 | subject-1 | Yes | 0 | subject-1.saliva.2008-10-28 |
| L1S57 | CCTCTCTATGGGCAGTCGGTGAT | AGAGTTTGATCMTGGCTCAG | saliva | 2018 | 1 | 20 | subject-1 | No | 84 | subject-1.saliva.2009-1-20 |

the barcode sequences in the metadata are the in torrent multiplexing barcodes, already removed by in torrent server.

I had around 1000 V1 forward primer removed at the trim stage and around 810,000 V2 reverse primers.

Regards  
Kinaoosh

Please find bellow complete summary of all the codes I used until now:

Manifest.csv:

sample-id,absolute-filepath,direction  
sample-16s,/home/qiime2/16s.fastq,forward

qiime tools import   
--type 'SampleData[SequencesWithQuality]'   
--input-path Manifest.csv   
--output-path demux.qza   
--source-format SingleEndFastqManifestPhred33

qiime demux summarize  
--i-data demux.qza   
--o-visualization demux.qzv

qiime tools view demux.qzv

Results:

 ![image](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/6/67dbd3e329a79a51f6697e80644c020bca3e4d3b.png)

 ![image](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/b/bb90692e6a10ab9f298811f5ecede65657226860.jpg)

qiime cutadapt trim-single   
--i-demultiplexed-sequences demux.qza   
--p-front-f AGAGTTTGATCMTGGCTCAG   
--p-front-r CYNACTGCTGCCTCCCGTAG   
--p-error-rate 0   
--o-trimmed-sequences trimmed-seqs.qza   
--verbose

qiime demux summarize   
--i-data trimmed-seqs.qza   
--o-visualization trimmed-seqs.qzv

qiime demux summarize --i-data trimmed-seqs.qza --o-visualization trimmed-seqs.qzv

qiime tools view trimmed-seqs.qzv

=== Summary ===

Total reads processed: 1,072,981  
Reads with adapters: 831,332 (77.5%)  
Reads written (passing filters): 1,072,981 (100.0%)

Total basepairs processed: 341,396,059 bp  
Total written (filtered): 324,768,863 bp (95.1%)

=== Adapter 1 ===

Sequence: AGAGTTTGATCMTGGCTCAG; Type: regular 5'; Length: 20; Trimmed: 1515 times.

No. of allowed errors:  
0-20 bp: 0

Overview of removed sequences  
length count expect max.err error counts  
3 1027 16765.3 0 1027  
4 110 4191.3 0 110  
5 260 1047.8 0 260  
6 75 262.0 0 75  
7 10 65.5 0 10  
8 1 16.4 0 1  
9 5 4.1 0 5  
10 1 1.0 0 1  
42 1 0.0 0 1  
75 1 0.0 0 1  
95 1 0.0 0 1  
98 1 0.0 0 1  
101 1 0.0 0 1  
105 2 0.0 0 2  
107 1 0.0 0 1  
109 1 0.0 0 1  
123 1 0.0 0 1  
124 1 0.0 0 1  
126 1 0.0 0 1  
127 1 0.0 0 1  
130 1 0.0 0 1  
131 1 0.0 0 1  
145 1 0.0 0 1  
155 1 0.0 0 1  
174 2 0.0 0 2  
200 1 0.0 0 1  
211 1 0.0 0 1  
213 1 0.0 0 1  
294 1 0.0 0 1  
298 1 0.0 0 1  
321 1 0.0 0 1  
377 1 0.0 0 1

=== Adapter 2 ===

Sequence: CYNACTGCTGCCTCCCGTAG; Type: regular 5'; Length: 20; Trimmed: 829817 times.

No. of allowed errors:  
0-20 bp: 0

Overview of removed sequences  
length count expect max.err error counts  
3 145 16765.3 0 145  
4 753 4191.3 0 753  
5 70 1047.8 0 70  
6 64 262.0 0 64  
7 6 65.5 0 6  
11 1 0.3 0 1  
13 2 0.0 0 2  
14 3 0.0 0 3  
16 33 0.0 0 33  
17 8 0.0 0 8  
18 49 0.0 0 49  
19 1226 0.0 0 1226  
20 816799 0.0 0 816799  
21 3648 0.0 0 3648  
22 2010 0.0 0 2010  
23 1616 0.0 0 1616  
24 1241 0.0 0 1241  
25 664 0.0 0 664  
26 405 0.0 0 405  
27 240 0.0 0 240  
28 144 0.0 0 144  
29 121 0.0 0 121  
30 74 0.0 0 74  
31 48 0.0 0 48  
32 45 0.0 0 45  
33 29 0.0 0 29  
34 22 0.0 0 22  
35 23 0.0 0 23  
36 37 0.0 0 37  
37 35 0.0 0 35  
38 35 0.0 0 35  
39 49 0.0 0 49  
40 39 0.0 0 39  
41 28 0.0 0 28  
42 27 0.0 0 27  
43 24 0.0 0 24  
44 15 0.0 0 15  
45 7 0.0 0 7  
46 5 0.0 0 5  
47 4 0.0 0 4  
48 1 0.0 0 1  
49 1 0.0 0 1  
50 2 0.0 0 2  
74 1 0.0 0 1  
106 1 0.0 0 1  
116 1 0.0 0 1  
125 1 0.0 0 1  
127 1 0.0 0 1  
128 1 0.0 0 1  
138 2 0.0 0 2  
146 1 0.0 0 1  
155 1 0.0 0 1  
200 1 0.0 0 1  
204 1 0.0 0 1  
223 1 0.0 0 1  
250 1 0.0 0 1  
262 2 0.0 0 2  
284 1 0.0 0 1  
295 1 0.0 0 1  
356 1 0.0 0 1

qiime dada2 denoise-single  
--i-demultiplexed-seqs trimmed-seqs.qza  
--p-trim-left 0  
--p-trunc-len 360  
--o-representative-sequences rep-seqs-dada2.qza  
--o-table table-dada2.qza  
--o-denoising-stats stats-dada2.qza

qiime metadata tabulate  
--m-input-file stats-dada2.qza  
--o-visualization denoising\_stats

qiime metadata tabulate --m-input-file stats-dada2.qza --o-visualization denoising\_stats

qiime tools view denoising\_stats.qzv

 ![image](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/f/fbe57abaa524625ff8233ac4e598662cd52b4035.jpg)

Step 4: Build a phylogenetic tree: 4 steps

Mafft: do multiple sequence alignment.

qiime alignment mafft  
--i-sequences rep-seqs-dada2.qza  
--o-alignment aligned\_rep\_seqs.qza

Mask: to filler the alognment

qiime alignment mask  
--i-alignment aligned\_rep\_seqs.qza  
--o-masked-alignment masked\_aligned\_rep\_seqs.qza

Unroot tree (fast tree)

Qiime phylogeny fasttree  
--i-alignment masked\_aligned\_rep\_seqs.qza  
--o-tree unroot\_tree

Root the tree

Qiime phylogeny midpoint-root  
--i-tree unroot\_tree.qza  
--o-rooted-tree rooted\_tree

Step 5: diversity analysis

qiime diversity core-metrics-phylogenetic  
--i-phylogeny rooted\_tree.qza  
--i-table table-dada2.qza  
--p-sampling-depth 500  
--m-metadata-file metadata.tsv  
--output-dir core\_metrics\_results\_folder

---

<div class="post-metadata">

### Author: ![thermokarst](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@thermokarst](https://forum.qiime2.org/u/thermokarst)
#### Post date: [July 11, 2018, 5:50pm UTC](https://forum.qiime2.org/t/diversity-analysis/4973/5 "2018-07-11T17:50:24Z")

</div>

Hey there @kia2094!

> [@kia2094](#):
>
> sample-id,absolute-filepath,direction  
> sample-16s,/home/qiime2/16s.fastq,forward

This manifest indicates you have one sample (with id `sample-16s`), while your sample metadata indicates you have two samples (with ids `C10` & `L1S57`). How many samples _should_ be present in this analysis?

> [@kia2094](#):
>
> the barcode sequences in the metadata are the in torrent multiplexing barcodes, already removed by in torrent server.

These data appear to be multiplexed still --- you will not be able to demultiplex without the barcodes present.

Can you please provide some more detail about how these sequences were processed at your sequencing facility? Thanks! 🦖 :qiime2:

---

<div class="post-metadata">

### Author: ![kia2094](https://forum.qiime2.org/user_avatar/forum.qiime2.org/kia2094/32/2140_2.png) [@kia2094](https://forum.qiime2.org/u/kia2094)
#### Post date: [July 12, 2018, 12:03pm UTC](https://forum.qiime2.org/t/diversity-analysis/4973/6 "2018-07-12T12:03:45Z")

</div>

Thank you for the reply. I have one sample (16s.fastq) which contain two primers. The ion torrent 16s.fastq has only a forward read, unlike Illumina that has forward and reverse reads.

In the same 16s.fastq file, there are two primers. C10 is the reverse V2 primer and L1S57 is the forward primer.

The ion torrent automatically removes the library barcodes so I should be only left with sequences attached to primers in the 16s.fastq file.

I was confused by the qiime process steps. I imported the file, removed the primers and then I reached the diversity step. It is asking for metadata, barcode and primers. There are no barcodes since ion torrent removed them and there is no primer since I removed it by qiime cutadapt trim-single.

I'm confused on what I should put in the metadata now.

Regards

---

<div class="post-metadata">

### Author: ![thermokarst](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@thermokarst](https://forum.qiime2.org/u/thermokarst)
#### Post date: [July 12, 2018, 4:10pm UTC](https://forum.qiime2.org/t/diversity-analysis/4973/7 "2018-07-12T16:10:31Z")

</div>

> [@kia2094](#):
>
> I have one sample (16s.fastq) which contain two primers. The ion torrent 16s.fastq has only a forward read, unlike Illumina that has forward and reverse reads.

Okay! Just to make sure you are aware - samples and read directions are not the same thing.

> [@kia2094](#):
>
> It is asking for metadata, barcode and primers

Hmm --- there are no prompts for barcodes or primers at the diversity step - perhaps you are thinking about demultiplexing? Primers aren't used anywhere in the analysis, virtually every workflow recommends trimming any primers before analyzing.

> [@kia2094](#):
>
> I’m confused on what I should put in the metadata now.

Have you read the [metadata tutorial](https://docs.qiime2.org/2018.6/tutorials/metadata/)? Better yet, have you read the [Overview tutorial?](https://docs.qiime2.org/2018.6/tutorials/overview/)

As a general note - there aren't many things you can do with a dataset that only contains one sample --- diversity analysis doesn't make much sense since there is no other samples to compare with! The only thing that seems of immediate value to me is taxonomic classification (and composition barplots), but other than that, your options will be limited (not just in QIIME 2, but in general).

---

<div class="post-metadata">

### Author: ![kia2094](https://forum.qiime2.org/user_avatar/forum.qiime2.org/kia2094/32/2140_2.png) [@kia2094](https://forum.qiime2.org/u/kia2094)
#### Post date: [July 12, 2018, 6:16pm UTC](https://forum.qiime2.org/t/diversity-analysis/4973/8 "2018-07-12T18:16:22Z")

</div>

Thank you for the reply again. The a diverity can be helpful in single sample to specify the number of genera found. The metadata clearly asks for the barcodes and primers, Or did I understand it wrong? This is my metadata:

| #SampleID | BarcodeSequence | LinkerPrimerSequence | BodySite | Year | Month | Day | Subject | ReportedAntibioticUsage | DaysSinceExperimentStart | Description |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| #q2:types | categorical | categorical | categorical | numeric | numeric | numeric | categorical | categorical | numeric | categorical |
| C10 | CCATCTCATCCCTGCGTGTCTCCGACTCAGTTCGTGATTCGAT | CYIACTGCTGCCTCCCGTAG | saliva | 2018 | 10 | 28 | subject-1 | Yes | 0 | subject-1.saliva.2008-10-28 |
| L1S57 | CCTCTCTATGGGCAGTCGGTGAT | AGAGTTTGATCMTGGCTCAG | saliva | 2018 | 1 | 20 | subject-1 | No | 84 | subject-1.saliva.2009-1-20 |

My main confusion is if the metadata is asking for barcodes and primers, how dooes that relate to my fastq file. the two primers have different barcode+primer, but are in a single fast q file. If I name both above C10 and L1S57 as 16s.fastq, it says both cant have a same name.

Besides my fastq has no barcode, those were removed by the ion torrent server.The primer were removed as well by cutadapt.

Honestly, I only need the taxa, I'm not even sure why I'm involved in these, If I dont need metadata for the taxa classification I think I will move on.

Regards  
Kinaoosh

---

<div class="post-metadata">

### Author: ![Nicholas\_Bokulich](https://forum.qiime2.org/user_avatar/forum.qiime2.org/nicholas_bokulich/32/19937_2.png) [@Nicholas\_Bokulich](https://forum.qiime2.org/u/Nicholas_Bokulich)
#### Post date: [July 12, 2018, 7:20pm UTC](https://forum.qiime2.org/t/diversity-analysis/4973/9 "2018-07-12T19:20:51Z")

</div>

> [@kia2094](#):
>
> The a diverity can be helpful in single sample to specify the number of genera found

so run `qiime diversity alpha`. `core-metrics-phylogenetic` runs `alpha`, but it also does lots of other stuff that requires metadata because it is comparing groups of samples (e.g., for beta diversity and alpha diversity comparisons between groups). For more detail, do as @thermokarst suggested:

> [@thermokarst](#):
>
> read the [Overview tutorial](https://docs.qiime2.org/2018.6/tutorials/overview/)

> [@kia2094](#):
>
> Honestly, I only need the taxa, I’m not even sure why I’m involved in these, If I dont need metadata for the taxa classification I think I will move on.

You don't need metadata to perform taxonomy classification. Check out the overview tutorial and that should clarify your workflow.

---

<div class="post-metadata">

### Author: ![system](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/3X/2/1/21af5fe23cb6f4579467c66a9ed94e55274ca7bd.svg) [@system](https://forum.qiime2.org/u/system)
#### Post date: [August 13, 2018, 1:20am UTC](https://forum.qiime2.org/t/diversity-analysis/4973/10 "2018-08-13T01:20:54Z")

</div>

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
