Last updated: 2021-07-03
Checks: 7 0
Knit directory: wildlife-haemoprotozoa/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20210212)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 63bd5ef. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .DS_Store
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: analysis/.DS_Store
Ignored: analysis/.Rhistory
Ignored: analysis/_footer.html
Ignored: data/.DS_Store
Ignored: output/.DS_Store
Untracked files:
Untracked: ENA_submission/
Untracked: NCBI_submission/
Untracked: Rplot02.pdf
Untracked: data/NGS_18S_kinet/
Untracked: data/Sanger-piroplasm/
Untracked: data/haemoprotozoa.csv
Untracked: data/haemoprotozoa.xlsx
Untracked: data/tryp-phyloseq/count_data_QC.xlsx
Untracked: data/tryp-phyloseq/count_data_raw.csv
Untracked: data/tryp-phyloseq/sampledata.xlsx
Untracked: melt.csv
Untracked: melt.xlsx
Untracked: microscopy/
Untracked: output/plots/
Unstaged changes:
Modified: README.md
Modified: code/usearchv11_18S_Kineto.sh
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/tryp-01-NGS-bioinfo.Rmd
) and HTML (docs/tryp-01-NGS-bioinfo.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | 63bd5ef | siobhon-egan | 2021-07-03 | Formatting and setup updates |
html | 4608186 | siobhon-egan | 2021-07-02 | footer |
html | a36fbcb | siobhon-egan | 2021-07-02 | Build site. |
Rmd | 8e3850e | siobhon-egan | 2021-07-02 | Major update |
Analysis of Illumina MiSeq pair-end reads using USEARCH pipeline.
This script was run on Pawsey nimbus virtual machine but can be fun on any macOS or linux operating systems.
The following script was run using USEARCH version 11
A free 32-bit version is available for download here.
To install it, all you do is download or copy the binary to a directory that is accessible from the computer where you want to run the code. For convenience, you may want to rename the binary file to USEARCH to avoid typing long names like usearchXX.X.XX_iXXOS32. You can also update your $PATH
to save you referring to the path.
Execute permissions if required
chmod +x usearch11
To update profile add the following to the .bash_profile
#Adding USEARCH
export PATH="~/Programs/USEARCH:$PATH"
Check path is updated with
echo $PATH
Full script available at in the GitHub repository under the code/ directory here.
To execute run $ ./usearchv11_18S_Kineto.sh
from your terminal with raw data saved in directory called raw_data
.
#!/bin/bash
# author: Siobhon L. Egan
# License: MIT
# Date: Jan 2021
##########################################################################################
##########################################################################################
############################# USEARCH v11 complete pipeline ##############################
##########################################################################################
##########################################################################################
# Requirements: usearch11 must be installed on the PATH as "usearch11".
# Remeber if you have a large dataset you will need the 64 bit version.
# This script will work in unix and linux environments.
#
# This script taked raw MiSeq demultiplexed .fastq files for input and performs the following tasks:
#
# 1) Merge paired reads
# 2) Retrieve sequences matching primers
# 3) Quality filtering of `.fastq` sequence data and removal of short dimer seqs to generate `.fasta` sequence files
# 4) Removal low abundant sequences & singletons
# 5) Perform clustering sequences with
# 5a) UPARSE - to produce otus (using 97% similarity threshold)
# 5b) UNOISE3 - to produce zotus (i.e. zero-radius operational taxonomic units)
##########################################################################################
# Input raw unmerged filenames must be named "sample_id_SXXX_L001_R1.fastq" (read 1)
# and "sample_id_SXXX_L001_R2.fastq" (read 2) and all deposited in a directory specified
# by the "$raw_data" variable. "SXXX" is the sample number given by the MiSeq
# in the order you entered them in the Sample Sheet.
#
# Before use: $chmod 775 this_script.sh
# To run: $./this_script.sh
# This script will read any input directory specified by the "raw_data" variable, but will deposit all
# output into the current working diretory.
##########################################################################################
# Enter raw data directorry
raw_data="raw_data"
# Enter directory for merged output
merged_data="1.merged_data"
# Enter max diff for merging - default 5 but should increase for paired end
maxdiffs="15"
# Enter minimum merge overlap - default is 16 bp
overlap="20"
# Enter directory for sequences that are matched to primers
primer_matched="2a.primer_matches"
# Enter directory for sequences that do not match primers
primer_not_matched="2b.primer_not_matched"
# Enter forward sequences (5'-3'). Wildcard letters indicating degenerate positions in the primer are supported. See IUPAC(https://drive5.com/usearch/manual/IUPAC_codes.html) codes for details.
fwd_primer="ACCGTTTCGGCTTTTGTTGG" #18S kinetoplastid 825F Maslov et al. Biochem Parasitol (1996) 75(2): 197-205
rev_primer="GACTACAATGGTCTCTAATC" #18S kinetoplastid 662R Maslov et al. Biochem Parasitol (1996) 75(2): 197-205
# Enter directory for quality filtered output
QF="3.quality_filtered"
# Enter max error rate. Natural choice is 1, however may want to decrease to 0.5 or 0.25 for more stringent filtering.
max_ee="1"
# Enter min length of sequence for trimming in bp (eg. to keep all seqs above 200 bp enter "200")
minlen="150"
# Enter directory for labeled data
labeled_data="4.labeled_data"
# Enter directory for dereplicated sequences
derep_dir="5.derep_data"
# Enter directory for singlteton filter data
SF="6.singleton_filtered"
# Enter directory for singlteton sequences
low_abund_seqs="7.singleton_sequences"
# Enter max size to discard i.e. to discard singletons = 1, duplicates = 2
maxsize="1"
# Enter directory for sequence clustering
cluster="8.cluster"
# Enter sub-directory for uparse_otu clustering
uparse_otus="8a.otus"
# Enter sub-directory for unoise_zotu clustering
unoise_zotus="8b.zotus"
##########################################################################################
# DO NOT EDIT BELOW THIS LINE
##########################################################################################
# unzip raw_data
gunzip ${raw_data}/*.fastq.gz
##########################################################################################
##########################################################################################
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
echo Merging paried illumina fastq sequences
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Merge paired-end reads using `-fastq_mergepairs` command, and rename sequences. This would be done before primers are trimmed.
mkdir ${merged_data}
mkdir working1
#*****************************************************************************************
# Part 1: merge reads
for file1 in ${raw_data}/*R1.fastq
do
echo ""
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Merging paired reads
echo forward reads are:
echo $(basename ${file1})
echo reverse reads are:
echo $(basename ${file1} R1.fastq)R2.fastq
usearch11.0.667_i86osx64 -fastq_mergepairs ${file1} -reverse "${raw_data}/$(basename -s R1.fastq ${file1})R2.fastq" -fastqout "working1/$(basename "$file1")" -fastq_maxdiffs ${maxdiffs} -fastq_minovlen ${overlap} -report ${merged_data}/2a_merging_seqs_report.txt -tabbedout ${merged_data}/2b_tabbedout.txt
done
#*****************************************************************************************
# Part 2: Remove "_L001_R1" from filenames
for file2 in working1/*.fastq
do
rename="$(basename ${file2} _L001_R1.fastq).fastq"
mv ${file2} ${merged_data}/${rename}
done
#*****************************************************************************************
# Removing working directory
rm -r working1
##########################################################################################
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
echo Triming primers and distal bases
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# The `-search_pcr2` command searches for matches to a primer pair and outputs the sequence in between (i.e. amplicon with primers removed) into `primer_matched` file
mkdir ${primer_matched}
mkdir ${primer_not_matched}
for file3 in ${merged_data}/*.fastq
do
usearch11.0.667_i86osx64 -search_pcr2 ${file3} -fwdprimer ${fwd_primer} \
-revprimer ${rev_primer} \
-strand both -fastqout "${primer_matched}/$(basename ${file3})" -notmatchedfq "${primer_not_matched}/$(basename ${file3})" -tabbedout ${primer_matched}pcr2_output.txt
done
##########################################################################################
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
echo Quality control and removing dimer seqs
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Quality filtering of fastq files using the `-fastq_filter` command, output gives fasta files.
mkdir ${QF}
for file4 in ${primer_matched}/*.fastq
do
echo ""
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Quality control and removing dimer seqs
echo input is:
echo ${file4}
usearch11.0.667_i86osx64 -fastq_filter ${file4} -fastaout "${QF}/$(basename "$file4" .fastq).fasta" -fastq_maxee ${max_ee} -fastq_minlen ${minlen}
done
##########################################################################################
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
echo Renameing sequences with ">barcodelabel=sample_id;sequence_id"
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# For this script to run correctly input fasta label must be formatted >sequence_id and filename must be sample_id.fasta.
# Result will be ">barcodelabel=sample_id;sequenceid"
mkdir ${labeled_data}
mkdir working2
#*****************************************************************************************
# Part 1: Remove ">" from start of sequence_ID
for file5 in ${QF}/*.fasta
do
sed -e 's/>/>barcodelabel=;/g' ${file5} > working2/$(basename "$file5" .fasta).txt
done
#*****************************************************************************************
# Part 2: Add sample_ID (should be filename) to produce ">barcodelabel=sample_ID;sequence_ID"
for file6 in working2/*.txt
do
sample_id=$(basename ${file6} .txt)
echo ${sample_id}
sed -e "s/;/${sample_id};/g" ${file6} > "${labeled_data}/$(basename "$file6" .txt).fasta"
done
#*****************************************************************************************
# Remove working directories
rm -r working2
################################################################################################
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
echo Removing low abundant seqs singletons per sample
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Remove low abundant sequences (e.g. singletons) in samples using the `-fastx_uniques` command
mkdir ${derep_dir}
mkdir ${SF}
mkdir ${low_abund_seqs}
#*****************************************************************************************
# Part 1: Dereplicating
for file7 in ${labeled_data}/*.fasta
do
echo ""
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Removing singletons step 1: derep_fulllength
echo input is:
echo ${file7}
usearch11.0.667_i86osx64 -fastx_uniques ${file7} -fastaout "${derep_dir}/$(basename "$file7" .fasta).fasta" -sizeout
done
#*****************************************************************************************
# Part 2: Filtering low abundant seqs {maxsize}
for file8 in ${derep_dir}/*.fasta
do
echo ""
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Removing singletons step 2: sorting uniques
echo input is:
echo ${file8}
usearch11.0.667_i86osx64 -sortbysize ${file8} -fastaout "${low_abund_seqs}/$(basename "$file8" .fasta).fasta" -maxsize ${maxsize}
done
#*****************************************************************************************
# Step 3: Mapping reads
for file9 in ${labeled_data}/*.fasta
do
echo ""
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Removing singletons step 3: mapping reads to low abundant uniques
echo input is:
echo ${file9}
usearch11.0.667_i86osx64 -search_exact ${file9} -db "${low_abund_seqs}/$(basename "$file9" .fasta).fasta" -strand plus -notmatched "${SF}/$(basename "$file9" .fasta).fasta"
done
################################################################################################
################################################################################################
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
echo CLUSTERING
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Concatenate all singleton filter sequences into a single fasta file
# Find the set of unique sequences in an input file, also called dereplication using `-fastx_uniques` command
mkdir ${cluster}
cat ${SF}/*.fasta > ${cluster}/all_SF.fasta
cd ${cluster}
usearch11.0.667_i86osx64 -fastx_uniques all_SF.fasta -fastaout all_SF_DR.fasta -sizeout
#*****************************************************************************************
echo ----------------------------------------------------------------------------
echo Part a - Generating UPARSE OTUs
echo ----------------------------------------------------------------------------
# Cluster sequences in 97% operational taxonomic units (OTUs) using UPARSE algorithm `-cluster_otus` command and generate an OTU table
mkdir ${uparse_otus}
cd ${uparse_otus}
usearch11.0.667_i86osx64 -cluster_otus ../all_SF_DR.fasta -otus uparse_otus.fasta -relabel OTU
usearch11.0.667_i86osx64 -usearch_global ../all_SF.fasta -db uparse_otus.fasta -strand both -id 0.97 -otutabout uparse_otu_tab.txt -biomout uparse_otu_biom.biom
# The next two lines are options - they produce a distance matrix file and then a tree (newick format)
# Current parameters are a guide only and you will need to optimse them for your data
# Large datasets can take a long time, so you can skip this part for now to speed up analysis
# usearch11.0.667_i86osx64 -calc_distmx uparse_otus.fasta -tabbedout uparse_otus_distmx.txt -maxdist 0.2 -termdist 0.3
# usearch11.0.667_i86osx64 -cluster_aggd uparse_otus_distmx.txt -treeout uparse_otus_clusters.tree -clusterout uparse_otus_clusters.txt \
# -id 0.80 -linkage min
cd ..
#*****************************************************************************************
echo ----------------------------------------------------------------------------
echo Part b - Generating UNOISE ZOTUs
echo ----------------------------------------------------------------------------
# Cluster sequences in zero-radius operational taxonomic units (ZOTUs) using `-unoise3` command and generate a ZOTU table
mkdir ${unoise_zotus}
cd ${unoise_zotus}
usearch11.0.667_i86osx64 -unoise3 ../all_SF_DR.fasta -zotus unoise_zotus.fasta -tabbedout unoise_tab.txt
usearch11.0.667_i86osx64 -fastx_relabel unoise_zotus.fasta -prefix Otu -fastaout unoise_zotus_relabeled.fasta -keep_annots
usearch11.0.667_i86osx64 -otutab ../all_SF.fasta -zotus unoise_zotus_relabeled.fasta -otutabout unoise_otu_tab.txt -biomout unoise_otu_biom.biom -mapout unoise_map.txt -notmatched unoise_notmatched.fasta -dbmatched dbmatches.fasta -sizeout
# The next two lines are options - they produce a distance matrix file and then a tree (newick format)
# Current parameters are a guide only and you will need to optimse them for your data
# Large datasets can take a long time, so you can skip this part for now to speed up analysis
# usearch11.0.667_i86osx64 -calc_distmx unoise_zotus.fasta -tabbedout unoise_zotus_distmx.txt -maxdist 0.2 -termdist 0.3
# usearch11.0.667_i86osx64 -cluster_aggd unoise_zotus_distmx.txt -treeout unoise_zotus_clusters.tree -clusterout unoise_zotus_clusters.txt \
# -id 0.80 -linkage min
cd ..
cd ..
################################################################################################
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
echo ANALYSIS COMPLETE
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
################################################################################################
Resulting zOTUs were then subject to BLAST analysis (BLASTN 2.11.0+) against NCBI nucleotide collection (nt) database. The top 100 BLAST hits were then downloaded for downstream taxonomy analysis.
Nucleotide sequences were subject to BLAST analysis (BLASTN 2.11.0+1 using MegaBLAST2 against NCBI nucleotide collection (nt) database.
Filtered tops hit by evalue, percentage identity and query coverage to retrieve the top hit.
Using the top hit nucleotide accession number I then retrieved the taxonid using the following:
for ACC in A00002 X53307 BB145968 CAA42669 V00181 AH002406 HQ844023
do
echo -n -e "$ACC\t"
curl -s "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=${ACC}&rettype=fasta&retmode=xml" |\
grep TSeq_taxid |\
cut -d '>' -f 2 |\
cut -d '<' -f 1 |\
tr -d "\n"
echo
done
To get sequence description information use the following:
for ACC in A00002 X53307 BB145968 CAA42669 V00181 AH002406 HQ844023
do
echo -n -e "$ACC\t"
curl -s "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=${ACC}&rettype=fasta&retmode=xml" |\
grep TSeq_defline |\
cut -d '>' -f 2 |\
cut -d '<' -f 1 |\
tr -d "\n"
echo
done
Use TaxonKit to get lineage information. Documentation here, GitHub repo here
Install - for linux, other platforms available here
wget https://github.com/shenwei356/taxonkit/releases/download/v0.7.1/taxonkit_linux_amd64.tar.gz
wget https://github.com/shenwei356/csvtk/releases/download/v0.22.0/csvtk_linux_amd64.tar.gz
#unzip
tar -zxvf *.tar.gz
Download and decompress taxdump
wget -c ftp://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz
tar -zxvf taxdump.tar.gz
mkdir -p $HOME/.taxonkit
cp names.dmp nodes.dmp delnodes.dmp merged.dmp $HOME/.taxonkit
Show lineage consisting of taxids:
taxonkit lineage -t taxids.txt \
| csvtk pretty -t
Write lineage information to text file
taxonkit lineage taxids.txt | awk '$2!=""' > lineage.txt
Reformat lineage file to the following output: {k};{p};{c};{o};{f};{g};{s}
taxonkit reformat lineage.txt | tee lineage.txt.reformat
cut -f 1,3 lineage.txt.reformat
Align output to show taxonomic classification clearly
\lineage.txt \
| taxonkit reformat \
| csvtk -H -t cut -f 1,3 \
| csvtk -H -t sep -f 2 -s ';' -R \
| csvtk add-header -t -n taxid,kindom,phylum,class,order,family,genus,species \
| csvtk pretty -t
Note this was run using R version 4.0.3 and RStudo version 1.4. See R info for full details of R session.
Install libraries if required
Only need to run this code once.
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
# phyloseq
source('http://bioconductor.org/biocLite.R')
biocLite('phyloseq')
#tidyverse
install. packages("tidyverse")
#ampvis2
install.packages("remotes")
remotes::install_github("MadsAlbertsen/ampvis2")
#ampvis2extras
install.packages("BiocManager")
BiocManager::install("kasperskytte/ampvis2extras")
#ggpubr
install.packages("ggpubr")
#agricolae
install.packages("agricolae")
install.packages("remotes")
remotes::install_github("DanielSprockett/reltools")
devtools::install_github('jsilve24/philr')
#decontam
BiocManager::install("decontam")
library(decontam)
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("Biostrings")
Load libraries
pkgs <- c( "qiime2R", "phyloseq", "tidyverse", "ampvis2",
"ampvis2extras", "ggpubr", "agricolae", "plotly",
"viridis", "cowplot", "MicrobeR", "microbiome",
"reshape", "decontam", "data.table", "ape", "DESeq2",
"vegan","microbiomeutilities", "knitr", "tibble", "dplyr",
"patchwork","Biostrings")
lapply(pkgs, require, character.only = TRUE)
# set theme
theme_set(theme_bw())
Generate phyloseq object from spreadsheets.
Import ASV/OTU count data
count_data <- read_csv("data/tryp-phyloseq/count_data_raw.csv")
# use first column as label for rows
count_data_lab = column_to_rownames(count_data, var = "#Zotu ID")
# Make matrix
otumat <- as.matrix(count_data_lab)
Import taxonomy data
taxonomy <- read_csv("data/tryp-phyloseq/taxonomy.csv",
col_types = cols(Accession_description = col_skip(),
`Accession no.` = col_skip(), evalue = col_skip(),
`per. Ident` = col_skip(), taxid = col_skip()))
# use first column as label for rows
taxonomy_lab = column_to_rownames(taxonomy, var = "#Zotu ID")
taxmat <- as.matrix(taxonomy_lab)
Check the class of the otumat and taxmat objects, they MUST be in matrix format. Then we can great a phyloseq object called physeq from the otu and taxonomy tables and check the sample names.
class(otumat)
class(taxmat)
OTU = otu_table(otumat, taxa_are_rows = TRUE)
TAX = tax_table(taxmat)
physeq = phyloseq(OTU, TAX)
physeq
sample_names(physeq)
Add metadata and sequence data
Add sequences to phyloseq object
# read sequence file
rep.seqs <- Biostrings::readDNAStringSet("data/tryp-phyloseq/unoise_zotus.fasta", format = "fasta")
Add metadata, importing gDNAID as factor to be able to merge later on
metadata <- read_csv("data/tryp-phyloseq/sampledata.csv")
metadata_lab = column_to_rownames(metadata, var = "SampleID")
sampledata = sample_data(data.frame(metadata_lab))
sampledata
Create final phyloseq object
Now you can merge your data to create a final phyloseq object
ps_raw_tryp = merge_phyloseq(physeq, sampledata, rep.seqs)
Filter out negative controls and after identifying threshold from positive reads transform zOTU count data
ps_raw_tryp@otu_table [, 1:580][ps_raw_tryp@otu_table [, 1:580] < 150] <- 0
QC_otu = ps_raw_tryp@otu_table
write.csv(QC_otu, "data/tryp_phyloseq/count_data_QC.csv")
sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
attached base packages:
[1] parallel stats4 stats graphics grDevices utils datasets
[8] methods base
other attached packages:
[1] Biostrings_2.58.0 XVector_0.30.0
[3] patchwork_1.1.1 knitr_1.31
[5] microbiomeutilities_1.00.12 vegan_2.5-7
[7] lattice_0.20-41 permute_0.9-5
[9] DESeq2_1.30.1 SummarizedExperiment_1.20.0
[11] Biobase_2.50.0 MatrixGenerics_1.2.1
[13] matrixStats_0.58.0 GenomicRanges_1.42.0
[15] GenomeInfoDb_1.26.2 IRanges_2.24.1
[17] S4Vectors_0.28.1 BiocGenerics_0.36.0
[19] ape_5.4-1 data.table_1.14.0
[21] decontam_1.10.0 reshape_0.8.8
[23] microbiome_1.13.9 MicrobeR_0.3.2
[25] cowplot_1.1.1 viridis_0.5.1
[27] viridisLite_0.3.0 plotly_4.9.3
[29] agricolae_1.3-3 ggpubr_0.4.0
[31] ampvis2extras_0.1.5 ampvis2_2.6.7
[33] forcats_0.5.1 stringr_1.4.0
[35] dplyr_1.0.5 purrr_0.3.4
[37] readr_1.4.0 tidyr_1.1.2
[39] tibble_3.1.0 ggplot2_3.3.3
[41] tidyverse_1.3.0 phyloseq_1.34.0
[43] qiime2R_0.99.4 workflowr_1.6.2
loaded via a namespace (and not attached):
[1] bit64_4.0.5 DelayedArray_0.16.2 rpart_4.1-15
[4] RCurl_1.98-1.2 doParallel_1.0.16 generics_0.1.0
[7] RSQLite_2.2.3 combinat_0.0-8 bit_4.0.4
[10] xml2_1.3.2 lubridate_1.7.10 httpuv_1.5.5
[13] assertthat_0.2.1 xfun_0.21 hms_1.0.0
[16] jquerylib_0.1.3 evaluate_0.14 promises_1.2.0.1
[19] fansi_0.4.2 progress_1.2.2 dbplyr_2.1.0
[22] readxl_1.3.1 igraph_1.2.6 DBI_1.1.1
[25] geneplotter_1.68.0 htmlwidgets_1.5.3 ellipsis_0.3.1
[28] backports_1.2.1 picante_1.8.2 annotate_1.68.0
[31] vctrs_0.3.7 abind_1.4-5 cachem_1.0.4
[34] withr_2.4.1 checkmate_2.0.0 treeio_1.14.3
[37] prettyunits_1.1.1 cluster_2.1.1 lazyeval_0.2.2
[40] crayon_1.4.1 genefilter_1.72.1 pkgconfig_2.0.3
[43] zCompositions_1.3.4 nlme_3.1-152 nnet_7.3-15
[46] rlang_0.4.10 questionr_0.7.4 lifecycle_1.0.0
[49] miniUI_0.1.1.1 modelr_0.1.8 cellranger_1.1.0
[52] rprojroot_2.0.2 Matrix_1.3-2 aplot_0.0.6
[55] phangorn_2.5.5 carData_3.0-4 Rhdf5lib_1.12.1
[58] reprex_1.0.0 base64enc_0.1-3 pheatmap_1.0.12
[61] whisker_0.4 png_0.1-7 bitops_1.0-6
[64] rhdf5filters_1.2.0 blob_1.2.1 jpeg_0.1-8.1
[67] rstatix_0.7.0 DECIPHER_2.18.1 ggsignif_0.6.1
[70] rtk_0.2.6.1 klaR_0.6-15 scales_1.1.1
[73] memoise_2.0.0 magrittr_2.0.1 plyr_1.8.6
[76] gghalves_0.1.1 zlibbioc_1.36.0 compiler_4.0.3
[79] philr_1.16.0 RColorBrewer_1.1-2 cli_2.3.1
[82] ade4_1.7-16 htmlTable_2.1.0 Formula_1.2-4
[85] MASS_7.3-53.1 mgcv_1.8-34 tidyselect_1.1.0
[88] stringi_1.5.3 highr_0.8 yaml_2.2.1
[91] locfit_1.5-9.4 latticeExtra_0.6-29 ggrepel_0.9.1
[94] grid_4.0.3 sass_0.3.1 fastmatch_1.1-0
[97] tools_4.0.3 rio_0.5.26 rstudioapi_0.13
[100] foreach_1.5.1 foreign_0.8-81 git2r_0.28.0
[103] gridExtra_2.3 Rtsne_0.15 digest_0.6.27
[106] rvcheck_0.1.8 BiocManager_1.30.10 shiny_1.6.0
[109] quadprog_1.5-8 Rcpp_1.0.6 car_3.0-10
[112] broom_0.7.5 later_1.1.0.1 httr_1.4.2
[115] AnnotationDbi_1.52.0 colorspace_2.0-0 rvest_0.3.6
[118] XML_3.99-0.5 fs_1.5.0 truncnorm_1.0-8
[121] splines_4.0.3 tidytree_0.3.3 multtest_2.46.0
[124] xtable_1.8-4 jsonlite_1.7.2 ggtree_2.4.1
[127] AlgDesign_1.2.0 R6_2.5.0 Hmisc_4.5-0
[130] NADA_1.6-1.1 pillar_1.5.1 htmltools_0.5.1.1
[133] mime_0.10 glue_1.4.2 fastmap_1.1.0
[136] DT_0.17 BiocParallel_1.24.1 ggnet_0.1.0
[139] codetools_0.2-18 utf8_1.2.1 bslib_0.2.4.9001
[142] network_1.16.1 curl_4.3 zip_2.1.1
[145] openxlsx_4.2.3 survival_3.2-7 rmarkdown_2.7.2
[148] biomformat_1.18.0 munsell_0.5.0 rhdf5_2.34.0
[151] GenomeInfoDbData_1.2.4 iterators_1.0.13 labelled_2.7.0
[154] haven_2.3.1 reshape2_1.4.4 gtable_0.3.0
Zhang Z, Schwartz S, Wagner L, Miller W. A greedy algorithm for aligning DNA sequences. J Comput Biol. 2000, 7(1-2):203-14. doi: 10.1089/10665270050081478.↩︎
Morgulis A, Coulouris G, Raytselis Y, Madden TL, Agarwala R, Schäffer AA. Database indexing for production MegaBLAST searches. Bioinformatics. 2008, 24(16):1757-64. doi: 10.1093/bioinformatics/btn322.↩︎
Project website by Siobhon L. Egan, 2021. This site was created in R Markdown with workflowr