mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
20 lines
27 KiB
JSON
20 lines
27 KiB
JSON
{
|
||
"hash": "86547a9298483fb00c80e5530b9c8997",
|
||
"result": {
|
||
"markdown": "# OBITools V4 Tutorial\n\nHere is a short tutorial on how to analyze DNA metabarcoding data produced on Illumina sequencers using:\n\n- the OBITools\n- some basic Unix commands\n\n## Wolves’ diet based on DNA metabarcoding\n\nThe data used in this tutorial correspond to the analysis of four wolf scats, using the protocol published in @Shehzad2012-pn for assessing carnivore diet. After extracting DNA from the faeces, the DNA amplifications were carried out using the primers `TTAGATACCCCACTATGC` and `TAGAACAGGCTCCTCTAG` amplifiying the *12S-V5* region [@Riaz2011-gn], together with a wolf blocking oligonucleotide.\n\nThe complete data set can be downloaded here: [the tutorial dataset](wolf_diet.tgz) \n\nOnce the data file is downloaded, using a UNIX terminal unarchive the data from the `tgz` file.\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\ntar zxvf wolf_diet.tgz\n```\n:::\n\n\n\nThat command create a new directory named `wolf_data` containing every required data files:\n\n- `fastq <fastq>` files resulting of aGA IIx (Illumina) paired-end (2 x 108 bp) \n sequencing assay of DNA extracted and amplified from four wolf faeces:\n\n - `wolf_F.fastq`\n - `wolf_R.fastq`\n\n- the file describing the primers and tags used for all samples\n sequenced:\n\n - `wolf_diet_ngsfilter.txt` The tags correspond to short and\n specific sequences added on the 5\\' end of each primer to\n distinguish the different samples\n\n- the file containing the reference database in a fasta format:\n\n - `db_v05_r117.fasta` This reference database has been extracted\n from the release 117 of EMBL using `obipcr`\n\n\n\n::: {.cell}\n\n:::\n\n\n\nTo not mix raw data and processed data a new directory called `results` is created.\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nmkdir results\n```\n:::\n\n\n \n## Step by step analysis\n\n### Recover full sequence reads from forward and reverse partial reads\n\nWhen using the result of a paired-end sequencing assay with supposedly\noverlapping forward and reverse reads, the first step is to recover the\nassembled sequence.\n\nThe forward and reverse reads of the same fragment are *at the same line\nposition* in the two fastq files obtained after sequencing. Based on\nthese two files, the assembly of the forward and reverse reads is done\nwith the `obipairing` utility that aligns the two reads and returns the\nreconstructed sequence.\n\nIn our case, the command is:\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nobipairing --min-identity=0.8 \\\n --min-overlap=10 \\\n -F wolf_data/wolf_F.fastq \\\n -R wolf_data/wolf_R.fastq \\\n > results/wolf.fastq \n```\n:::\n\n\n\nThe `--min-identity` and `--min-overlap` options allow\ndiscarding sequences with low alignment quality. If after the aligment,\nthe overlaping parts of the reads is shorter than 10 base pairs or the \nsimilarity over this aligned region is below 80% of identity, in the output file,\nthe forward and reverse reads are not aligned but concatenated, and the value of \nthe `mode` attribute in the sequence header is set to `joined` instead of `alignment`.\n\n### Remove unaligned sequence records\n\nUnaligned sequences (:py`mode=joined`{.interpreted-text role=\"mod\"})\ncannot be used. The following command allows removing them from the\ndataset:\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nobigrep -p 'annotations.mode != \"join\"' \\\n results/wolf.fastq > results/wolf.ali.fastq\n```\n:::\n\n\n\nThe `-p` requires a go like expression. `annotations.mode != \"join\"` means that\nif the value of the `mode` annotation of a sequence is\ndifferent from `join`, the corresponding sequence record will be kept.\n\nThe first sequence record of `wolf.ali.fastq` can be obtained using the\nfollowing command line:\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nhead -n 4 results/wolf.ali.fastq\n```\n:::\n\n\n\nThe folling piece of code appears on thew window of tour terminal.\n\n```\n@HELIUM_000100422_612GNAAXX:7:108:5640:3823#0/1 {\"ali_dir\":\"left\",\"ali_length\":62,\"mode\":\"alignment\",\"pairing_mismatches\":{\"(T:26)->(G:13)\":62,\"(T:34)->(G:18)\":48},\"score\":484,\"score_norm\":0.968,\"seq_a_single\":46,\"seq_ab_match\":60,\"seq_b_single\":46}\nccgcctcctttagataccccactatgcttagccctaaacacaagtaattaatataacaaaattgttcgccagagtactaccggcaatagcttaaaactcaaaggacttggcggtgctttatacccttctagaggagcctgttctaaggaggcgg\n+\nCCCCCCCBCCCCCCCCCCCCCCCCCCCCCCBCCCCCBCCCCCCC<CcCccbe[`F`accXV<TA\\RYU\\\\ee_e[XZ[XEEEEEEEEEE?EEEEEEEEEEDEEEEEEECCCCCCCCCCCCCCCCCCCCCCCACCCCCACCCCCCCCCCCCCCCC\n```\n\n### Assign each sequence record to the corresponding sample/marker combination\n\nEach sequence record is assigned to its corresponding sample and marker\nusing the data provided in a text file (here `wolf_diet_ngsfilter.txt`).\nThis text file contains one line per sample, with the name of the\nexperiment (several experiments can be included in the same file), the\nname of the tags (for example: `aattaac` if the same tag has been used\non each extremity of the PCR products, or `aattaac:gaagtag` if the tags\nwere different), the sequence of the forward primer, the sequence of the\nreverse primer, the letter `T` or `F` for sample identification using\nthe forward primer and tag only or using both primers and both tags,\nrespectively (see `obimultiplex` for details).\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nobimultiplex -t wolf_data/wolf_diet_ngsfilter.txt \\\n -u results/unidentified.fastq \\\n results/wolf.ali.fastq \\\n > results/wolf.ali.assigned.fastq\n```\n:::\n\n\n\nThis command creates two files:\n\n- `unidentified.fastq` containing all the sequence records that were\n not assigned to a sample/marker combination\n- `wolf.ali.assigned.fastq` containing all the sequence records that\n were properly assigned to a sample/marker combination\n\nNote that each sequence record of the `wolf.ali.assigned.fastq` file\ncontains only the barcode sequence as the sequences of primers and tags\nare removed by the `obimultiplex ` program. Information concerning the \nexperiment, sample, primers and tags is added as attributes in the \nsequence header.\n\nFor instance, the first sequence record of `wolf.ali.assigned.fastq` is:\n\n```\n@HELIUM_000100422_612GNAAXX:7:108:5640:3823#0/1_sub[28..127] {\"ali_dir\":\"left\",\"ali_length\":62,\"direction\":\"direct\",\"experiment\":\"wolf_diet\",\"forward_match\":\"ttagataccccactatgc\",\"forward_mismatches\":0,\"forward_primer\":\"ttagataccccactatgc\",\"forward_tag\":\"gcctcct\",\"mode\":\"alignment\",\"pairing_mismatches\":{\"(T:26)->(G:13)\":35,\"(T:34)->(G:18)\":21},\"reverse_match\":\"tagaacaggctcctctag\",\"reverse_mismatches\":0,\"reverse_primer\":\"tagaacaggctcctctag\",\"reverse_tag\":\"gcctcct\",\"sample\":\"29a_F260619\",\"score\":484,\"score_norm\":0.968,\"seq_a_single\":46,\"seq_ab_match\":60,\"seq_b_single\":46}\nttagccctaaacacaagtaattaatataacaaaattgttcgccagagtactaccggcaatagcttaaaactcaaaggacttggcggtgctttataccctt\n+\nCCCBCCCCCBCCCCCCC<CcCccbe[`F`accXV<TA\\RYU\\\\ee_e[XZ[XEEEEEEEEEE?EEEEEEEEEEDEEEEEEECCCCCCCCCCCCCCCCCCC\n```\n\n### Dereplicate reads into uniq sequences\n\nThe same DNA molecule can be sequenced several times. In order to reduce\nboth file size and computations time, and to get easier interpretable\nresults, it is convenient to work with unique *sequences* instead of\n*reads*. To *dereplicate* such *reads* into unique *sequences*, we use\nthe `obiuniq` command.\n\n+-------------------------------------------------------------+\n| Definition: Dereplicate reads into unique sequences |\n+-------------------------------------------------------------+\n| 1. compare all the reads in a data set to each other |\n| 2. group strictly identical reads together |\n| 3. output the sequence for each group and its count in the |\n| original dataset (in this way, all duplicated reads are |\n| removed) |\n| |\n| Definition adapted from @Seguritan2001-tg |\n+-------------------------------------------------------------+\n\nFor dereplication, we use the `obiuniq ` command with the `-m sample`. The `-m sample` option is used\nto keep the information of the samples of origin for each uniquesequence.\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nobiuniq -m sample \\\n results/wolf.ali.assigned.fastq \\\n > results/wolf.ali.assigned.uniq.fasta\n```\n:::\n\n\n\nNote that `obiuniq` returns a fasta file.\n\nThe first sequence record of `wolf.ali.assigned.uniq.fasta` is:\n\n```\n>HELIUM_000100422_612GNAAXX:7:93:6991:1942#0/1_sub[28..126] {\"ali_dir\":\"left\",\"ali_length\":63,\"count\":1,\"direction\":\"reverse\",\"experiment\":\"wolf_diet\",\"forward_match\":\"ttagataccccactatgc\",\"forward_mismatches\":0,\"forward_primer\":\"ttagataccccactatgc\",\"forward_tag\":\"gaatatc\",\"merged_sample\":{\"26a_F040644\":1},\"mode\":\"alignment\",\"pairing_mismatches\":{\"(A:10)->(G:34)\":76,\"(C:06)->(A:34)\":58},\"reverse_match\":\"tagaacaggctcctctag\",\"reverse_mismatches\":0,\"reverse_primer\":\"tagaacaggctcctctag\",\"reverse_tag\":\"gaatatc\",\"score\":730,\"score_norm\":0.968,\"seq_a_single\":45,\"seq_ab_match\":61,\"seq_b_single\":45}\nttagccctaaacataaacattcaataaacaagaatgttcgccagagaactactagcaaca\ngcctgaaactcaaaggacttggcggtgctttatatccct\n```\n\nThe run of `obiuniq` has\nadded two key=values entries in the header of the fasta sequence:\n\n- `\"merged_sample\":{\"29a_F260619\":1}`{.interpreted-text\n role=\"mod\"}: this sequence have been found once in a single sample\n called **29a_F260619**\n- `\"count\":1` : the total count for this sequence is $1$\n\nTo keep only these two attributes, we can use the `obiannotate` command:\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nobiannotate -k count -k merged_sample \\\n results/wolf.ali.assigned.uniq.fasta \\\n > results/wolf.ali.assigned.simple.fasta\n```\n:::\n\n\n\nThe first five sequence records of `wolf.ali.assigned.simple.fasta`\nbecome:\n\n```\n>HELIUM_000100422_612GNAAXX:7:26:18930:11105#0/1_sub[28..127] {\"count\":1,\"merged_sample\":{\"29a_F260619\":1}}\nttagccctaaacacaagtaattaatataacaaaatwattcgcyagagtactacmggcaat\nagctyaaarctcamagrwcttggcggtgctttataccctt\n>HELIUM_000100422_612GNAAXX:7:58:5711:11399#0/1_sub[28..127] {\"count\":1,\"merged_sample\":{\"29a_F260619\":1}}\nttagccctaaacacaagtaattaatataacaaaattattcgccagagtwctaccgssaat\nagcttaaaactcaaaggactgggcggtgctttataccctt\n>HELIUM_000100422_612GNAAXX:7:100:15836:9304#0/1_sub[28..127] {\"count\":1,\"merged_sample\":{\"29a_F260619\":1}}\nttagccctaaacatagataattacacaaacaaaattgttcaccagagtactagcggcaac\nagcttaaaactcaaaggacttggcggtgctttataccctt\n>HELIUM_000100422_612GNAAXX:7:55:13242:9085#0/1_sub[28..126] {\"count\":4,\"merged_sample\":{\"26a_F040644\":4}}\nttagccctaaacataaacattcaataaacaagagtgttcgccagagtactactagcaaca\ngcctgaaactcaaaggacttggcggtgctttacatccct\n>HELIUM_000100422_612GNAAXX:7:86:8429:13723#0/1_sub[28..127] {\"count\":7,\"merged_sample\":{\"15a_F730814\":5,\"29a_F260619\":2}}\nttagccctaaacacaagtaattaatataacaaaattattcgccagagtactaccggcaat\nagcttaaaactcaaaggactcggcggtgctttataccctt\n```\n\n### Denoise the sequence dataset\n\nTo have a set of sequences assigned to their corresponding samples does\nnot mean that all sequences are *biologically* meaningful i.e. some of\nthese sequences can contains PCR and/or sequencing errors, or chimeras.\n\n#### Tag the sequences for PCR errors (sequence variants) {.unnumbered}\n\nThe `obiclean` program tags sequence variants as potential error generated during\nPCR amplification. We ask it to keep the [head]{.title-ref} sequences (`-H` option) \nthat are sequences which are not variants of another sequence with a count greater than 5% of their own count\n(`-r 0.05` option).\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nobiclean -s sample -r 0.05 -H \\\n results/wolf.ali.assigned.simple.fasta \\\n > results/wolf.ali.assigned.simple.clean.fasta \n```\n:::\n\n\n\nOne of the sequence records of\n`wolf.ali.assigned.simple.clean.fasta` is:\n\n```\n>HELIUM_000100422_612GNAAXX:7:66:4039:8016#0/1_sub[28..127] {\"count\":17,\"merged_sample\":{\"13a_F730603\":17},\"obiclean_head\":true,\"obiclean_headcount\":1,\"obiclean_internalcount\":0,\"obi\nclean_samplecount\":1,\"obiclean_singletoncount\":0,\"obiclean_status\":{\"13a_F730603\":\"h\"},\"obiclean_weight\":{\"13a_F730603\":25}}\nctagccttaaacacaaatagttatgcaaacaaaactattcgccagagtactaccggcaac\nagcccaaaactcaaaggacttggcggtgcttcacaccctt\n```\n\nTo remove such sequences as much as possible, we first discard rare\nsequences and then rsequence variants that likely correspond to\nartifacts.\n\n\n\n#### Get some statistics about sequence counts {.unnumbered}\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nobicount results/wolf.ali.assigned.simple.clean.fasta\n```\n\n\n::: {.cell-output .cell-output-stdout}\n```\ntime=\"2023-02-23T18:43:37+01:00\" level=info msg=\"Appending results/wolf.ali.assigned.simple.clean.fasta file\\n\"\n 2749 36409 273387\n```\n:::\n:::\n\n\n\nThe dataset contains $4313$ sequences variant corresponding to 42452 sequence reads.\nMost of the variants occur only a single time in the complete dataset and are usualy\nnamed *singletons*\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nobigrep -p 'sequence.Count() == 1' results/wolf.ali.assigned.simple.clean.fasta \\\n | obicount\n```\n\n\n::: {.cell-output .cell-output-stdout}\n```\ntime=\"2023-02-23T18:43:37+01:00\" level=info msg=\"Reading sequences from stdin in guessed\\n\"\ntime=\"2023-02-23T18:43:37+01:00\" level=info msg=\"Appending results/wolf.ali.assigned.simple.clean.fasta file\\n\"\ntime=\"2023-02-23T18:43:37+01:00\" level=info msg=\"On output use JSON headers\"\n 2623 2623 261217\n```\n:::\n:::\n\n\n\nIn that dataset sigletons corresponds to $3511$ variants.\n\nUsing *R* and the `ROBIFastread` package able to read headers of the fasta files produced by *OBITools*,\nwe can get more complete statistics on the distribution of occurrencies.\n \n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(ROBIFastread)\nlibrary(ggplot2)\n\nseqs <- read_obifasta(\"results/wolf.ali.assigned.simple.clean.fasta\",keys=\"count\")\n\nggplot(data = seqs, mapping=aes(x = count)) +\n geom_histogram(bins=100) +\n scale_y_sqrt() +\n scale_x_sqrt() +\n geom_vline(xintercept = 10, col=\"red\", lty=2) +\n xlab(\"number of occurrencies of a variant\") \n```\n\n::: {.cell-output-display}\n{fig-pos='H'}\n:::\n:::\n\n\n\nIn a similar way it is also possible to plot the distribution of the sequence length.\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nggplot(data = seqs, mapping=aes(x = nchar(sequence))) +\n geom_histogram() +\n scale_y_log10() +\n geom_vline(xintercept = 80, col=\"red\", lty=2) +\n xlab(\"sequence lengths in base pair\")\n```\n\n::: {.cell-output-display}\n{fig-pos='H'}\n:::\n:::\n\n\n\n\n#### Keep only the sequences having a count greater or equal to 10 and a length shorter than 80 bp {.unnumbered}\n\nBased on the previous observation, we set the cut-off for keeping\nsequences for further analysis to a count of 10. To do this, we use the\n`obigrep <scripts/obigrep>`{.interpreted-text role=\"doc\"} command. The\n`-p 'count>=10'` option means that the `python` expression\n:py`count>=10`{.interpreted-text role=\"mod\"} must be evaluated to\n:py`True`{.interpreted-text role=\"mod\"} for each sequence to be kept.\nBased on previous knowledge we also remove sequences with a length\nshorter than 80 bp (option -l) as we know that the amplified 12S-V5\nbarcode for vertebrates must have a length around 100bp.\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nobigrep -l 80 -p 'sequence.Count() >= 10' results/wolf.ali.assigned.simple.clean.fasta \\\n > results/wolf.ali.assigned.simple.clean.c10.l80.fasta\n```\n:::\n\n\n\nThe first sequence record of `results/wolf.ali.assigned.simple.clean.c10.l80.fasta` is:\n \n```\n>HELIUM_000100422_612GNAAXX:7:22:2603:18023#0/1_sub[28..127] {\"count\":12182,\"merged_sample\":{\"15a_F730814\":7559,\"29a_F260619\":4623},\"obiclean_head\":true,\"obiclean_headcount\":2,\"obiclean_internalcount\":0,\"obiclean_samplecount\":2,\"obiclean_singletoncount\":0,\"obiclean_status\":{\"15a_F730814\":\"h\",\"29a_F260619\":\"h\"},\"obiclean_weight\":{\"15a_F730814\":9165,\"29a_F260619\":6275}}\nttagccctaaacacaagtaattaatataacaaaattattcgccagagtactaccggcaat\nagcttaaaactcaaaggacttggcggtgctttataccctt\n```\n\nAt that time in the data cleanning we have conserved : \n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nobicount results/wolf.ali.assigned.simple.clean.c10.l80.fasta\n```\n\n\n::: {.cell-output .cell-output-stdout}\n```\ntime=\"2023-02-23T18:43:40+01:00\" level=info msg=\"Appending results/wolf.ali.assigned.simple.clean.c10.l80.fasta file\\n\"\n 26 31337 2585\n```\n:::\n:::\n\n\n\n### Taxonomic assignment of sequences\n\nOnce denoising has been done, the next step in diet analysis is to\nassign the barcodes to the corresponding species in order to get the\ncomplete list of species associated to each sample.\n\nTaxonomic assignment of sequences requires a reference database\ncompiling all possible species to be identified in the sample.\nAssignment is then done based on sequence comparison between sample\nsequences and reference sequences.\n\n#### Download the taxonomy {.unnumbered}\n\nIt is always possible to download the complete taxonomy from NCBI using the following commands.\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nmkdir TAXO\ncd TAXO\ncurl http://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz \\\n | tar -zxvf -\ncd ..\n```\n:::\n\n\n\nFor people have a low speed internet connection, a copy of the `taxdump.tar.gz` file is provided in the wolf_data directory.\nThe NCBI taxonomy is dayly updated, but the one provided here is ok for running this tutorial.\n\nTo build the TAXO directory from the provided `taxdump.tar.gz`, you need to execute the following commands\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nmkdir TAXO\ncd TAXO\ntar zxvf wolf_data/taxdump.tar.gz \ncd ..\n```\n:::\n\n\n\n#### Build a reference database {.unnumbered}\n\nOne way to build the reference database is to use the `obipcr` program to simulate a PCR and extract all sequences from a general purpose DNA database such as genbank or EMBL that can be\namplified *in silico* by the two primers (here **TTAGATACCCCACTATGC** and **TAGAACAGGCTCCTCTAG**)\nused for PCR amplification.\n\nThe two steps to build this reference database would then be\n\n1. Today, the easiest database to download is *Genbank*. But this will take you more than a day and occupy more than half a terabyte on your hard drive. In the `wolf_data` directory, a shell script called `download_gb.sh` is provided to perform this task. It requires that the programs `wget2` and `curl` are available on your computer.\n\n1. Use `obipcr` to simulate amplification and build a reference database based on the putatively amplified barcodes and their recorded taxonomic information.\n\nAs these steps can take a long time (about a day for the download and an hour for the PCR), we already provide the reference database produced by the following commands so you can skip its construction. Note that as the Genbank and taxonomic database evolve frequently, if you run the following commands you may get different results.\n\n##### Download the sequences {.unnumbered}\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nmkdir genbank\ncd genbank\n../wolf_data/install_gb.sh\ncd ..\n```\n:::\n\n\n\nDO NOT RUN THIS COMMAND EXCEPT IF YOU ARE REALLY CONSIENT OF THE TIME AND DISK SPACE REQUIRED.\n\n\n##### Use obipcr to simulate an in silico\\` PCR {.unnumbered}\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nobipcr -t TAXO -e 3 -l 50 -L 150 \\ \n --forward TTAGATACCCCACTATGC \\\n --reverse TAGAACAGGCTCCTCTAG \\\n --no-order \\\n genbank/Release-251/gb*.seq.gz\n > results/v05.pcr.fasta\n```\n:::\n\n\n\nNote that the primers must be in the same order both in\n`wolf_diet_ngsfilter.txt` and in the `obipcr` command.\nThe part of the path indicating the *Genbank* release can change.\nPlease check in your genbank directory the exact name of your release.\n\n##### Clean the database {.unnumbered}\n\n1. filter sequences so that they have a good taxonomic description at\n the species, genus, and family levels\n (`obigrep` command command below).\n2. remove redundant sequences (`obiuniq` command below).\n3. ensure that the dereplicated sequences have a taxid at the family\n level (`obigrep` command below).\n4. ensure that sequences each have a unique identification\n (`obiannotate` command below)\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nobigrep -t TAXO \\\n --require-rank species \\\n --require-rank genus \\\n --require-rank family \\\n results/v05.ecopcr > results/v05_clean.fasta\n\nobiuniq -c taxid \\\n results/v05_clean.fasta \\\n > results/v05_clean_uniq.fasta\n\nobirefidx -t TAXO results/v05_clean_uniq.fasta \\\n > results/v05_clean_uniq.indexed.fasta\n```\n:::\n\n\n\n\n\n::: warning\n::: title\nWarning\n:::\n\nFrom now on, for the sake of clarity, the following commands will use\nthe filenames of the files provided with the tutorial. If you decided to\nrun the last steps and use the files you have produced, you\\'ll have to\nuse `results/v05_clean_uniq.indexed.fasta` instead of `wolf_data/db_v05_r117.indexed.fasta`.\n:::\n\n### Assign each sequence to a taxon\n\nOnce the reference database is built, taxonomic assignment can be\ncarried out using the `obitag` command.\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nobitag -t TAXO -R wolf_data/db_v05_r117.indexed.fasta \\\n results/wolf.ali.assigned.simple.clean.c10.l80.fasta \\\n > results/wolf.ali.assigned.simple.clean.c10.l80.taxo.fasta\n```\n:::\n\n\n\nThe `obitag` adds several attributes in the sequence record header, among\nthem:\n\n- obitag_bestmatch=ACCESSION where ACCESSION is the id of hte sequence in\n the reference database that best aligns to the query sequence;\n- obitag_bestid=FLOAT where FLOAT\\*100 is the percentage of identity\n between the best match sequence and the query sequence;\n- taxid=TAXID where TAXID is the final assignation of the sequence by\n `obitag`\n- scientific_name=NAME where NAME is the scientific name of the\n assigned taxid.\n\nThe first sequence record of `wolf.ali.assigned.simple.clean.c10.l80.taxo.fasta` is:\n\n``` bash\n>HELIUM_000100422_612GNAAXX:7:81:18704:12346#0/1_sub[28..126] {\"count\":88,\"merged_sample\":{\"26a_F040644\":88},\"obiclean_head\":true,\"obiclean_headcount\":1,\"obiclean_internalcount\":0,\"obiclean_samplecount\":1,\"obiclean_singletoncount\":0,\"obiclean_status\":{\"26a_F040644\":\"h\"},\"obiclean_weight\":{\"26a_F040644\":208},\"obitag_bestid\":0.9207920792079208,\"obitag_bestmatch\":\"AY769263\",\"obitag_difference\":8,\"obitag_match_count\":1,\"obitag_rank\":\"clade\",\"scientific_name\":\"Boreoeutheria\",\"taxid\":1437010}\nttagccctaaacataaacattcaataaacaagaatgttcgccagaggactactagcaata\ngcttaaaactcaaaggacttggcggtgctttatatccct\n```\n\n### Generate the final result table\n\nSome unuseful attributes can be removed at this stage.\n\n- obiclean_head\n- obiclean_headcount\n- obiclean_internalcount\n- obiclean_samplecount\n- obiclean_singletoncount\n\n\n\n::: {.cell}\n\n```{.bash .cell-code}\nobiannotate --delete-tag=obiclean_head \\\n --delete-tag=obiclean_headcount \\\n --delete-tag=obiclean_internalcount \\\n --delete-tag=obiclean_samplecount \\\n --delete-tag=obiclean_singletoncount \\\n results/wolf.ali.assigned.simple.clean.c10.l80.taxo.fasta \\\n > results/wolf.ali.assigned.simple.clean.c10.l80.taxo.ann.fasta\n```\n:::\n\n\n\nThe first sequence record of\n`wolf.ali.assigned.simple.c10.l80.clean.taxo.ann.fasta` is then:\n \n``` \n>HELIUM_000100422_612GNAAXX:7:84:16335:5083#0/1_sub[28..126] {\"count\":96,\"merged_sample\":{\"26a_F040644\":11,\"29a_F260619\":85},\"obiclean_status\":{\"26a_F040644\":\"s\",\"29a_F260619\":\"h\"},\"obiclean_weight\":{\"26a_F040644\":14,\"29a_F260619\":110},\"obitag_bestid\":0.9595959595959596,\"obitag_bestmatch\":\"AC187326\",\"obitag_difference\":4,\"obitag_match_count\":1,\"obitag_rank\":\"subspecies\",\"scientific_name\":\"Canis lupus familiaris\",\"taxid\":9615}\nttagccctaaacataagctattccataacaaaataattcgccagagaactactagcaaca\ngattaaacctcaaaggacttggcagtgctttatacccct\n```\n\n### Looking at the data in R\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nlibrary(ROBIFastread)\nlibrary(vegan)\n```\n\n::: {.cell-output .cell-output-stderr}\n```\nLe chargement a nécessité le package : permute\n```\n:::\n\n::: {.cell-output .cell-output-stderr}\n```\nLe chargement a nécessité le package : lattice\n```\n:::\n\n::: {.cell-output .cell-output-stderr}\n```\nThis is vegan 2.6-4\n```\n:::\n\n```{.r .cell-code}\nlibrary(magrittr)\n \n\ndiet_data <- read_obifasta(\"results/wolf.ali.assigned.simple.clean.c10.l80.taxo.fasta\") \ndiet_data %<>% extract_features(\"obitag_bestmatch\",\"obitag_rank\",\"scientific_name\",'taxid')\n\ndiet_tab <- extract_readcount(diet_data,key=\"obiclean_weight\")\ndiet_tab\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n4 x 26 sparse Matrix of class \"dgCMatrix\"\n```\n:::\n\n::: {.cell-output .cell-output-stderr}\n```\n [[ suppressing 26 column names 'HELIUM_000100422_612GNAAXX:7:100:4828:3492#0/1_sub[28..127]', 'HELIUM_000100422_612GNAAXX:7:7:2880:4021#0/1_sub[28..127]', 'HELIUM_000100422_612GNAAXX:7:7:18108:9040#0/1_sub[28..126]' ... ]]\n```\n:::\n\n::: {.cell-output .cell-output-stdout}\n```\n \n13a_F730603 22 . 9 19 25 1 . . . . . . . . . 20 . . . .\n29a_F260619 . 44 . 1 . 13 . 25 . . . 16 391 . . . . 6275 110 .\n15a_F730814 . . 4 5 . . . . . . . . . . . . . 9138 . .\n26a_F040644 . . . 481 . . 14 . 43 208 72 . . 52 88 . 31 . 14 18\n \n13a_F730603 . . . . 15 8409\n29a_F260619 . . . 353 . .\n15a_F730814 . . . . . .\n26a_F040644 12265 15 17 . . .\n```\n:::\n:::\n\n\n\nThis file contains 26 sequences. You can deduce the diet of each sample: \n\n: - 13a_F730603: Cervus elaphus\n - 15a_F730814: Capreolus capreolus\n - 26a_F040644: Marmota sp. (according to the location, it is\n Marmota marmota)\n - 29a_F260619: Capreolus capreolus\n\nNote that we also obtained a few wolf sequences although a wolf-blocking\noligonucleotide was used.\n",
|
||
"supporting": [
|
||
"tutorial_files/figure-pdf"
|
||
],
|
||
"filters": [
|
||
"rmarkdown/pagebreak.lua"
|
||
],
|
||
"includes": {},
|
||
"engineDependencies": {
|
||
"knitr": [
|
||
"{\"type\":\"list\",\"attributes\":{},\"value\":[]}"
|
||
]
|
||
},
|
||
"preserve": null,
|
||
"postProcess": false
|
||
}
|
||
} |