Workshop 11: Metagenomics Analysis

40
Workshop 11: Metagenomics Analysis Shi, Baochen Department of Pharmacology, UCLA

Transcript of Workshop 11: Metagenomics Analysis

Page 1: Workshop 11: Metagenomics Analysis

Workshop11:MetagenomicsAnalysis

Shi,BaochenDepartmentofPharmacology,UCLA

Page 2: Workshop 11: Metagenomics Analysis

Outlines

Theworkshop:2hoursperdayover3days.   Day1.i)howtoperformthe16SrRNA-basedanalysisusingbioinformaEcspipelineQIIME.

Day2.i)IntroducestaEsEcalanalysesinQIIME

Day3.

i)FuncEonalanalysesofthemicrobiome

ii)OpenQ&A

Page 3: Workshop 11: Metagenomics Analysis

Outlines

Wewilldemonstrate16SampliconanalysisusingQIIME

a)RunQIIMEonHoffman2orlocalinstallaEon

b)SequencedatapreparaEon

c)OperaEonalTaxonomicUnits(OTU)picking,Taxonomicassignment&inferringphylogeny

d)microbiomediversityanalyses

Page 4: Workshop 11: Metagenomics Analysis

Useful UNIX Commands: Covered in Workshop 1 & 2

•  Where am I? pwd •  Current directory ./ •  Home directory ~/ •  Change directory cd ~/data •  Move up one level cd .. •  List files in folder ls •  Look at a file less fileName •  Copy a file cp ~/data/file ~/otherdir/ •  Delete a file rm fileName •  Delete a directory rmdir ~/dirName/ •  Move a file mv ~/data/file ~/otherdir/file •  Secure copy scp user@host1:dir/file user@host2:dir/file •  Compress a file gzip –c file > file.gz •  Uncompress a file gunzip file.gz •  Make a new folder mkdir data2 •  Count lines in a file wc –l fileName

Page 5: Workshop 11: Metagenomics Analysis

Questions/In Doubt/Lost?

•  Unix manual: man functionX •  Google is your best friend!

•  Any of your friendly QCB fellows

Page 6: Workshop 11: Metagenomics Analysis

a)  RunonHoffman2

Asharedaccountonmacforstudents:login:workshoppassword:NGS_AnalysisLogininhoffman2: [email protected]

Qiimeisin:

cd /u/local/apps

LoadQiime:

module load qiime

Page 7: Workshop 11: Metagenomics Analysis

Logging into Hoffman2

ssh [email protected]

change to your user ID

Page 8: Workshop 11: Metagenomics Analysis

Useful Tools on Hoffman2 ls /u/local/apps/

Page 9: Workshop 11: Metagenomics Analysis

a)MacQIIMElocalinstallaAon

QIIMEhavealotofdependencies.ThequickestwaytogetstartedusingQIIMEVirtualBoxorMacQIIMEh\p://qiime.org/1.9.0/install/install.htmlMacQIIME:a1)DownloadMacQIIME(h\p://www.wernerlab.org/so`ware/macqiime/macqiime-installaEon)a2)installMacQIIMECopymacqiimefoldertoroot,andthencopy"macqiime"scriptto/usr/bin/sourcetheenvironmentvariablesTutorial,testdata&testscript:/macqiime/QIIME/

tar -xvf MacQIIME_*.tgz

./install.s

source /macqiime/configs/bash_profile.txt

Page 10: Workshop 11: Metagenomics Analysis

a)QIIMEVirtualBoxinstallaAon

QIIMEVirtualBox(Linux,windows,Mac):a1)DownloadandinstalloracleVirtualBox(h\p://qiime.org/1.9.0/install/virtual_box.html)a2)DownloadtheQIIMEVirtualBoxa3)Createanewvirtualmachine

Page 11: Workshop 11: Metagenomics Analysis

Outlines

Wewilldemonstratestepsfor

a)RunQIIMEonHoffman2orlocalinstallaEon

b)SequencedatapreparaEon

c)OperaEonalTaxonomicUnits(OTU)picking,Taxonomicassignment&inferringphylogeny

d)microbiomediversityanalyses

Page 12: Workshop 11: Metagenomics Analysis

Flowchart

(b) (c)

(d)

Page 13: Workshop 11: Metagenomics Analysis

Flowchart

1.  SFF(raw454data,opEonal)2.  fasta/qualfiles3.  demulEplexing/qualityfiltering

4.  OTUpicking5.  representaEvesequences6.  taxonomicassignments/treebuilding

7.  OTUtableanddownstreamprocessing

(b)SequencedatapreparaEon

(c)OperaEonalTaxonomicUnits(OTU)picking,Taxonomicassignment&inferringphylogeny (d)microbiomediversityanalyses

Page 14: Workshop 11: Metagenomics Analysis

Flowchart

(b)

Page 15: Workshop 11: Metagenomics Analysis

b)DatapreparaEon Wewillstartoutwithrawsequencingdatageneratedon454

• Sequences(.fna):454generatedFASTAfile.• QualityScores(.qual):454generatedqualityscorefile

• experimentaldataaboutthesamples(MappingFile)generatedbyuser.

On Hoffman2, copy all the files you need to scratch folder cd /u/scratch/f/xxx/ cd/u/local/apps/qiime/1.8.0/examples/qiime_tutorial/ cp /u/local/apps/qiime/1.8.0/examples/qiime_tutorial/file/u/scratch/f/xxx/

change to your ID

Page 16: Workshop 11: Metagenomics Analysis

b)DatapreparaEon Standardflowgramformat(SFF)isabinaryfileformatusedtoencoderesultsof454pyrosequencing

• Sequences(.fna):454generatedFASTAfile.• QualityScores(.qual):454generatedqualityscorefile

process_sff.py -i sffs/ -f -o output_dir

Page 17: Workshop 11: Metagenomics Analysis

b)DatapreparaEon

MappingFile

split_libraries.py -m Map.txt -f Example.fna -q Example.qual -o split_library_output

assignthemulEplexedreadstosamplesbasedontheirnucleoEdebarcode(demul<plexing)

Page 18: Workshop 11: Metagenomics Analysis

b)DatapreparaEon

split_libraries.py -m Map.txt -f Example.fna -q Example.qual -o split_library_output

•  split_library_log.txt:summaryofdemulEplexingandqualityfiltering,includingthenumberofreadsdetectedforeachsampleandabriefsummaryofanyreadsthatwereremovedduetoqualityconsideraEons.

•  histograms.txt:tab-delimitedfileshowsthenumberofreadsatregularsizeintervalsbeforeanda`ersplijng.

•  seqs.fna:fastaforma\ed

ThisstepalsoperformsqualityfilteringbasedonthecharacterisEcsofeachsequence,removinganylowqualityorambiguousreads.

-l,--min_seq_lengthMinimumsequencelength,innucleoEdes[default:200]-t,--trim_seq_lengthCalculatesequencelengthsa`ertrimmingprimersandbarcodes[default:False]-s,--min_qual_scoreMinaveragequalscoreallowedinread[default:25]

Page 19: Workshop 11: Metagenomics Analysis

b)DatapreparaEon

split_libraries_fastq.py –i fastq.gz –b barcode.fastq.gz --rev_comp_mapping_barcodes –o out_dir/ -m map.txt -q 19

Illuminaruns:demulEplexingofFastqsequencedatawherebarcodesandsequencesarecontainedintwoseparatefastqfiles.DemulEplexandqualityfilter(atPhred>=Q20)onelaneofIlluminafastqdata

Page 20: Workshop 11: Metagenomics Analysis

Flowchart

(c)

Page 21: Workshop 11: Metagenomics Analysis

Flowchart

1.  SFF(raw454data,opEonal)2.  fasta/qualfiles3.  demulEplexing/qualityfiltering

4.  OTUpicking5.  representaEvesequences6.  taxonomicassignments/treebuilding

7.  OTUtableanddownstreamprocessing

(b)SequencedatapreparaEon

(c)OperaEonalTaxonomicUnits(OTU)picking,Taxonomicassignment&inferringphylogeny (d)microbiomediversityanalyses

Page 22: Workshop 11: Metagenomics Analysis

c)OTUanalysis Thisworkflowconsistsofthefollowingsteps:

OTUpicking,Taxonomicassignment

c1)PickOTUsbasedonsequencesimilaritywithinthereads(pick_otus.py)c2)PickarepresentaEvesequenceforeachOTU(pick_rep_set.py)c3)AssigntaxonomytoOTUrepresentaEvesequences(assign_taxonomy.py)Inferringphylogenyc4)AlignOTUrepresentaEvesequences(align_seqs.py)c5)Filterthealignment(filter_alignment.py)c6)BuildaphylogeneEctree(make_phylogeny.py)SummarizetheOTUtablec7)MaketheOTUtable(make_otu_table.py)

Page 23: Workshop 11: Metagenomics Analysis

c1)PickOTUsbasedonsequencesimilaritywithinthereadsTheOTUpickingstepassignssimilarsequencestooperaEonaltaxonomicunits(OTUs)byclusteringsequencesbasedonauser-definedsimilaritythreshold.SequenceswhicharesimilaratorabovethethresholdlevelaretakentorepresentthepresenceofataxonomicunitinthesequencecollecEon.

DenovoOTUpickingbasedonsequencesimilaritywithinthereads(pick_otus.py)

-s97%sequencesimilarity&–zenablereversestrandmatching

e.g.,agenus,whenthesimilaritythresholdissetat0.94;oraspecies,whenthesimilaritythresholdissetat0.97

Theoutputfile:

pick_otus.py -i seqs.fna -o picked_otus_90_percent_rev/ -s 0.97 -z

c)OTUanalysis

Page 24: Workshop 11: Metagenomics Analysis

Closed-referenceOTUpickingIftheuserprovidestaxonomicassignmentsforsequencesinthereferencedatabase,thoseareassignedtoOTUs.-s,--assign_taxonomyAssigntaxonomytoeachsequence-a,--parallelRuninparallelwhereavailable

OTUpickingstrategiesinQIIME

pick_closed_reference_otus.py –i seqs.fna –r ref/refseqs.fna –o dir-out/ -t ref/taxa.txt

Page 25: Workshop 11: Metagenomics Analysis

Open-referenceOTUpickingpreferredstrategyforOTUpicking:-a,--parallelRuninparallelwhereavailable

OTUpickingstrategiesinQIIME

pick_open_reference_otus.py –i seqs.fna –r refseqs.fna –o dir/

Page 26: Workshop 11: Metagenomics Analysis

Thisworkflowconsistsofthefollowingsteps:

c1)PickOTUsbasedonsequencesimilaritywithinthereads(pick_otus.py)c2)PickarepresentaEvesequenceforeachOTU(pick_rep_set.py)A`erpickingOTUs,youcanpickarepresentaEvesetofsequences.ForeachOTU,youwillendupwithonesequencethatcanbeusedinsubsequentanalyses.pick_rep_set.py -i seqs_otus.txt -f seqs.fna -o rep_set.fna

c)OTUanalysis

Page 27: Workshop 11: Metagenomics Analysis

Thisworkflowconsistsofthefollowingsteps:

c1)PickOTUsbasedonsequencesimilaritywithinthereads(pick_otus.py)c2)PickarepresentaEvesequenceforeachOTU(pick_rep_set.py)c3)AssigntaxonomytoOTUrepresentaEvesequences(assign_taxonomy.py)Assignmentwiththeconsensustaxonomyassigner(default,uclust)Referenceandid-to-taxonomyfor16SrRNAsequencesfromGreengenes(gg_13_5.fasta&gg_13_5_taxonomy)(h\p://greengenes.secondgenome.com/downloads/database/13_5)AssignmentwiththeRDPClassifier:TheRDPClassifierassignstaxonomiesusingNaiveBayesclassificaEon.

-c,--confidenceMinimumconfidencetorecordanassignmentTheoutput:sequenceid(1stcolumn),taxonomy(2ndcolumn)andqualityscore(3rdcolumn).

assign_taxonomy.py -i repr_set.fna -r ref_seq_set.fna -t id_to_taxonomy.txt

assign_taxonomy.py -i repr_set.fna -m rdp -c 0.80

denovo367 k__Bacteria; p__Bacteroidetes; c__Bacteroidia; o__Bacteroidales; f__S24-7; g__; s__ 1.00

c)OTUanalysis

Page 28: Workshop 11: Metagenomics Analysis

Thisworkflowconsistsofthefollowingsteps:

c1)PickOTUsbasedonsequencesimilaritywithinthereads(pick_otus.py)c2)PickarepresentaEvesequenceforeachOTU(pick_rep_set.py)c3)AssigntaxonomytoOTUrepresentaEvesequences(assign_taxonomy.py)AlignmentoftheOTUrepresentaEvesequencesandphylogenyinferenceisnecessaryifphylogeneEcmetricssuchasUniFracwillbeusedinmicrobiomediversityanalyses.c4)AlignOTUrepresentaEvesequences(align_seqs.py)c5)Filterthealignment(filter_alignment.py)c6)BuildaphylogeneEctree(make_phylogeny.py)c7)MaketheOTUtable(make_otu_table.py)

c)OTUanalysis

Page 29: Workshop 11: Metagenomics Analysis

Thisworkflowconsistsofthefollowingsteps:

c1)PickOTUsbasedonsequencesimilaritywithinthereads(pick_otus.py)c2)PickarepresentaEvesequenceforeachOTU(pick_rep_set.py)c3)AssigntaxonomytoOTUrepresentaEvesequences(assign_taxonomy.py)c4)AlignOTUrepresentaEvesequences(align_seqs.py)PyNAST-Thedefaultalignment,implementaEonoftheNASTalignmentalgorithm.TheNASTalignseachcandidatesequencetothebest-matchingsequenceinapre-aligneddatabaseofsequences(“template”sequence).Candidatesequencesarenotpermi\edtointroducenewgapintotemplatedatabase,thealgorithmintroduceslocalmis-alignmentstopreservetheexisEngtemplatesequence.align_seqs.py-irep_set.fna

c)OTUanalysis

Page 30: Workshop 11: Metagenomics Analysis

ApplyingChimeraSlayer:or

removechimericsequencesfromyouralignmentusingyourchimericsequencelist

idenEfy_chimeric_seqs.py-mChimeraSlayer-irep_set_aligned.fasta-a/macqiime/microbiomeuEl_2010-04-29/RESOURCES/rRNA16S.gold.NAST_ALIGNED.fasta-ochimeric_seqs.txt

ChimeracheckingsequenceswithQIIME

perl/macqiime/microbiomeuEl_2010-04-29/ChimeraSlayer/ChimeraSlayer.pl--queryrep_set_aligned.fasta

filter_fasta.py-frep_set_aligned.fasta-onon_chimeric_rep_set_aligned.fasta-schimeric_seqs.txt-n

Page 31: Workshop 11: Metagenomics Analysis

Thisworkflowconsistsofthefollowingsteps:

c1)PickOTUsbasedonsequencesimilaritywithinthereads(pick_otus.py)c2)PickarepresentaEvesequenceforeachOTU(pick_rep_set.py)c3)AssigntaxonomytoOTUrepresentaEvesequences(assign_taxonomy.py)c4)AlignOTUrepresentaEvesequences(align_seqs.py)c5)Filterthealignment(filter_alignment.py)ThisscriptwillremoveposiEonswhicharegapsineverysequence(notcoveredbyamplicon).AddiEonally,thiswillremovenon-conservedposiEons,whichareuninformaEvefortreebuilding.

filter_alignment.py -i seqs_rep_set_aligned.fasta -o filtered_alignment/

c)OTUanalysis

Page 32: Workshop 11: Metagenomics Analysis

Thisworkflowconsistsofthefollowingsteps:

c1)PickOTUsbasedonsequencesimilaritywithinthereads(pick_otus.py)c2)PickarepresentaEvesequenceforeachOTU(pick_rep_set.py)c3)AssigntaxonomytoOTUrepresentaEvesequences(assign_taxonomy.py)c4)AlignOTUrepresentaEvesequences(align_seqs.py)c5)Filterthealignment(filter_alignment.py)c6)BuildaphylogeneEctree(make_phylogeny.py)

make_phylogeny.py –i rep_set_aligned_pfiltered.fasta -o rep_phylo.tre

c)OTUanalysis

Page 33: Workshop 11: Metagenomics Analysis

Thisworkflowconsistsofthefollowingsteps:

c1)PickOTUsbasedonsequencesimilaritywithinthereads(pick_otus.py)c2)PickarepresentaEvesequenceforeachOTU(pick_rep_set.py)c3)AssigntaxonomytoOTUrepresentaEvesequences(assign_taxonomy.py)AlignmentoftheOTUrepresentaEvesequencesandphylogenyinferenceisnecessaryifphylogeneEcmetricssuchasUniFracwillbeusedinmicrobiomediversityanalyses.c4)AlignOTUrepresentaEvesequences(align_seqs.py)c5)Filterthealignment(filter_alignment.py)c6)BuildaphylogeneEctree(make_phylogeny.py)SummarizetheOTUtablec7)MaketheOTUtable(make_otu_table.py)

c)OTUanalysis

Page 34: Workshop 11: Metagenomics Analysis

Thisworkflowconsistsofthefollowingsteps:

c1)PickOTUsbasedonsequencesimilaritywithinthereads(pick_otus.py)c2)PickarepresentaEvesequenceforeachOTU(pick_rep_set.py)c3)AssigntaxonomytoOTUrepresentaEvesequences(assign_taxonomy.py)c4)AlignOTUrepresentaEvesequences(align_seqs.py)c5)Filterthealignment(filter_alignment.py)c6)BuildaphylogeneEctree(make_phylogeny.py)c7)MaketheOTUtable(make_otu_table.py)ThescripttabulatesthenumberofEmesanOTUisfoundineachsample,andaddsthetaxonomicpredicEonsforeachOTU-eremovechimericOTUmake_otu_table.py –i seqs_otus.txt–t rep_set_tax_assignments.txt -o otu_table.biom -echimeric_seqs.txt

c)OTUanalysis

Page 35: Workshop 11: Metagenomics Analysis

SummarizetheOTUtableConverttablefromBIOMtotab-separatedtextformat

biom summarize-table –i otu_table.biom

Num samples: 9 Total count: 1337 Counts/sample summary: Min: 146.0 Max: 150.0 Median: 149.000 Mean: 148.556 Std. dev.: 1.257 Counts/sample detail: PC.481: 146.0 PC.355: 147.0 PC.636: 148.0 ………………..

c)OTUanalysis

biom convert –i otu_table.biom -o otu_table.txt -b

Page 36: Workshop 11: Metagenomics Analysis

SummarizecommuniEesbytaxonomiccomposiEonsummarize_taxa_through_plots.py -i otu_table.biom -o taxa_summary –m FasAng_Map.txt

#OTU ID PC.636 PC.635 PC.356 PC.481 PC.354 PC.593 PC.355 PC.607 PC.634 k__Bacteria;Other;Other 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.00671140939597 0.0 k__Bacteria;p__Actinobacteria;c__Coriobacteriia 0.00675675675676 0.0 0.0 0.00684931506849 0.0 0.0 0.0 0.0134228187919 0.0133333333333 k__Bacteria;p__Bacteroidetes;c__Bacteroidia 0.675675675676 0.530201342282 0.2 0.143835616438 0.0805369

therelaEveabundancesoftaxa(atthedifferentlevel)withineachsample

c)OTUanalysis

Page 37: Workshop 11: Metagenomics Analysis

Makeataxonomyheatmapmake_otu_heatmap.py-mFasEng_Map.txt-iotu_table.biom-ootu_table_heatmap.pdf

c)OTUanalysis

Page 38: Workshop 11: Metagenomics Analysis

MakeanOTUnetworkmake_otu_network.py-mFasEng_Map.txt-iotu_table.biom-onetwork

redcirclerepresentsasampleandwhitesquarerepresentsanOTU.ThelinesrepresenttheOTUspresentinaparEcularsample

c)OTUanalysis

Page 39: Workshop 11: Metagenomics Analysis

c)OTUanalysis Thisworkflowconsistsofthefollowingsteps:

OTUpicking,Taxonomicassignment

c1)PickOTUsbasedonsequencesimilaritywithinthereads(pick_otus.py)c2)PickarepresentaEvesequenceforeachOTU(pick_rep_set.py)c3)AssigntaxonomytoOTUrepresentaEvesequences(assign_taxonomy.py)Inferringphylogenyc4)AlignOTUrepresentaEvesequences(align_seqs.py)c5)Filterthealignment(filter_alignment.py)c6)BuildaphylogeneEctree(make_phylogeny.py)SummarizetheOTUtablec7)MaketheOTUtable(make_otu_table.py)

Page 40: Workshop 11: Metagenomics Analysis

Flowchart

(c)