1 / 18

Lab 1: Using data output from Qiime , transformations, quality control

Lab 1: Using data output from Qiime , transformations, quality control. Where to find useful output from QIIME. OTU table: wf_da/uclust_picked_otus/rep_set/pynast_aligned_seqs/rdp_assigned_taxonomy/otu_table/ seqs_otu_table.txt Mapping file: Fasting_Map.txt Tree file:

olwen
Download Presentation

Lab 1: Using data output from Qiime , transformations, quality control

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab 1: Using data output from Qiime, transformations, quality control

  2. Where to find useful output from QIIME • OTU table: wf_da/uclust_picked_otus/rep_set/pynast_aligned_seqs/rdp_assigned_taxonomy/otu_table/seqs_otu_table.txt • Mapping file: Fasting_Map.txt • Tree file: wf_da/uclust_picked_otus/rep_set/pynast_aligned_seqs/fasttree_phylogeny/seqs_rep_set.tre

  3. OTU table d = read.table(’otu_table.txt', header=T, row.names=1, sep='\t') taxa.names = d$Consensus.Lineage d = as.matrix(d[,-dim(d)[2]])

  4. Absolute abundance to relative abundance d = scale(d, center=F, scale=colSums(d)) d = t(d) Because the number of sequences for each sample is different, we need to standardize each sample to make them comparable. The most natural normalization is to go from absolute abundance to relative abundances. So each number in the OTU table will represent the proportion of sequences from that samples belonging to that OTU.

  5. Writing an R function • A function is an R object that can be called (executed) • Function has inputs: parameters • Function returns an output: value • A value is either through explicit return command or by default the value of the last function called from within that function extract.name.level = function(x, level){ a=c(unlist(strsplit(x,';')),'Other') paste(a[1:min(level,length(a))],collapse=';') }

  6. Execute the new function a = as.character(d$Consensus.Lineage[1]) a extract.name.level(a, 2) extract.name.level(a, 3) extract.name.level(a, 5) Call the function that we have just created and see what the results are.

  7. Function to summarize data at different taxonomic levels otu2taxonomy = function(x, level, taxa=NULL){ if(is.null(taxa)){ taxa = colnames(x) } if(length(taxa)!=dim(x)[2]){ print("ERROR: taxonomy should have the same length as the number of columns in OTU table") return; } level.names = sapply(as.character(taxa), function(x) extract.name.level(x,level=level)) t(apply(x, 1, function(y) tapply(y,level.names,sum))) }

  8. Summarize the OTU table Explore the OTU tables, summarized at different taxonomic levels by running the following commands. How many Phyla, Classes, Orders, Families, Genera, OTUs are represented in the dataset? Hint: use dim function. d.genus = otu2taxonomy(d,level=7,taxa=taxa.names) d.family = otu2taxonomy(d,level=6,taxa=taxa.names) d.order = otu2taxonomy(d,level=5,taxa=taxa.names) d.class = otu2taxonomy(d,level=4,taxa=taxa.names) d.phylum = otu2taxonomy(d,level=3,taxa=taxa.names)

  9. Mapping file ff = read.table('mapping.txt', header=T)

  10. Matching up the rows of the mapping file with the OTU table Run the following commands: ff$SampleID rownames(d.phylum) Notice that the rows in the OTU table are in a different order (sorted alphanumerically) then in the mapping table. The following command orders the rows of the mapping table: ff=ff[order(ff$SampleID),] Check that the rows now match up: ff$SampleID == rownames(d.phylum)

  11. Subsetting the data # select columns by name vars = c("Root;Bacteria;Bacteroidetes", "Root;Bacteria;Firmicutes", "Root;Bacteria;Proteobacteria") d.phylum[,vars] # select columns by number cnum = c(1,3,6) d.phylum[,cnum] # dropping columns d.phylum[,!colnames(d.phylum) %in% vars] # selecting/dropping rows d.phylum[1:3,] d.phylum[-(1:90),] # subset function week16fecal = subset(d.phylum, ff$Location == ‘Fecal’ & ff$Week == 16, select = vars)

  12. Basic plotting: explore on your own plot(week16fecal) week16map = subset(ff, ff$Location == 'Fecal' & ff$Week == 16) plot(week16fecal ~ week16map$Treatment) plot(week16fecal[,1] ~ week16map$Treatment, main=colnames(week16fecal)[1], xlab='Treatment', ylab='Relative abundance (fraction of the total)') plot(week16fecal[,2] ~ week16map$Treatment, main = colnames(week16fecal)[2], xlab='Treatment', ylab='Relative abundance (fraction of the total)')

  13. Plotting (cont’d) # two plots on one figure par(mfrow=c(1,2)) plot(week16fecal[,1] ~ week16map$Treatment, main = colnames(week16fecal)[1], xlab='Treatment', ylab='Relative abundance (fraction of the total)') plot(week16fecal[,2] ~ week16map$Treatment, main = colnames(week16fecal)[2], xlab='Treatment', ylab='Relative abundance (fraction of the total)')

  14. Plotting (cont’d) #saving the plot pdf(file='bf.pdf') par(mfrow=c(1,2)) plot(week16fecal[,1] ~ week16map$Treatment, main = colnames(week16fecal)[1], xlab='Treatment', ylab='Relative abundance (fraction of the total)') plot(week16fecal[,2] ~ week16map$Treatment, main = colnames(week16fecal)[2], xlab='Treatment', ylab='Relative abundance (fraction of the total)') dev.off()

  15. Heatmaps # heatmaps ma.phylum = subset(d.phylum, ff$Location=='Fecal', colMeans(d.phylum) > 0.01) ma.ff = subset(ff, ff$Location=='Fecal') library(gplots) heatmap.2(ma.phylum, dendrogram="both", scale="col", col=redgreen(75), distfun = function(x) dist(x, method='euclidean'), key=T, tracecol=NULL)

  16. Heatmaps (factors as side colors) heatmap.2(ma.phylum, dendrogram="both", scale="col", col=redgreen(75), distfun = function(x) dist(x, method='euclidean'), key=T, tracecol=NULL, RowSideColors=rainbow(2)[as.integer(ma.ff$Treatment)]) heatmap.2(ma.phylum, dendrogram="both", scale="col", col=redgreen(75), distfun = function(x) dist(x, method='euclidean'), key=T, tracecol=NULL, RowSideColors=rainbow(3)[as.integer(factor(ma.ff$Week))])

  17. On your own • Using plot() and heatmap.2() visually explore the data at a different taxonomic level (Class, Order, Family or Phylum) • Tip: Focus only on highly abundant taxa (>1%, >5%)

  18. Useful commands: find help pages on these and use for exploring the data • colnames(), rownames() • dim() • max(), min() • mean(), sd() • scale() • boxplot() • heatmap.2()

More Related