Tool:R code for ecological data analysis
1
12
Entering edit mode
9.9 years ago

I am sharing my R code for ecological data analysis in the hope that they will be useful for your research:

http://userweb.eng.gla.ac.uk/umer.ijaz/bioinformatics/ecological.html

along with a toy dataset to play with.

You can use the scripts mentioned in the above link when you have processed your data through different metagenomics pipelines, for instance, VSEARCH, CONCOCT, AMPLICON processing & UPARSE, HumanN, gefes, SEQenv and QIIME and have obtained abundance tables (OTUs, taxonomic assignments from RDP, CREST classifier) in comma-delimited format. Most of the functions are ggplot2 equivalent of what you normally obtain from R's vegan package.

I'll keep on updating the webpage with further information or any other scripts that I may find useful and relevant, so keep on visiting it from time to time.

Best Wishes,

Umer

next-gen R Metagenomics • 5.1k views
ADD COMMENT
2
Entering edit mode

Sorry guys, just bear with this structure for a while. As soon as I get some time free, I'll annotate and update the page. Many thanks for your feedback!

Much appreciated!

ADD REPLY
0
Entering edit mode

No worries, it was just a suggestion. Thanks again for sharing and for all effort it must have took to put this together. I've got it bookmarked!

ADD REPLY
1
Entering edit mode

This is really nice but it would be more useful if you put the code on github so people could contribute and provide feedback. Or, create an R package to provide these functions. Copy and pasting code from a webpage is not the best way to share code. Also, the function links make the code harder to read, for me at least. Thanks for sharing.

ADD REPLY
0
Entering edit mode

Was this done using knitr? Maybe you can then share Rmd too :-)?

ADD REPLY
0
Entering edit mode

Hi Umer,

Thank you very much for your sharing, I am learning from your code. I am trying to run your code again and everything seem to be work, but it does not show anyHappen chart as the attached pictures. Could you please tell me what's happen?. I am not good at bioinformatic, so I am sorry if that is a silly question.

Thank you very much

Cheers

Thanh

ADD REPLY
3
Entering edit mode
9.9 years ago

While you are at it, please also check my interactive SUMMARIZEplot for abundance tables: http://userweb.eng.gla.ac.uk/umer.ijaz/bioinformatics/summarize_v0.2/summarize.html

You can get the source files from here: http://userweb.eng.gla.ac.uk/umer.ijaz/bioinformatics/summarize_v0.2/

All you then need is summarize.html and a data.js file.

You can generate data.js quite easily by using the following R code if your abundance table is in a csv format

rm(list=ls())
library(vegan)
x<- read.csv("PTS_phylotypes_Nov2013_N1_blast_F_ENVO_samples_labels.csv",header=TRUE,row.names=1)

MDS<-metaMDS(x, distance = "bray", k = 2, trymax = 50)

x<-x/rowSums(x)
x<-x[,order(colSums(x),decreasing=TRUE)]
#Extract list of top N Taxa
N<-21
taxa_list<-colnames(x)[1:N]
#remove "__Unknown__" and add it to others
taxa_list<-taxa_list[!grepl("__Unknown__",taxa_list)]
N<-length(taxa_list)

new_x<-data.frame(x[,colnames(x) %in% taxa_list],Others=rowSums(x[,!colnames(x) %in% taxa_list]))
names<-gsub("\\.","_",gsub(" ","_",colnames(new_x)))
sink("data.js")
cat("var freqData=[\n")
for (i in (1:dim(new_x)[1])){ 
  cat(paste("{Samples:\'",rownames(new_x)[i],"\',",sep=""))
  cat(paste("freq:{",paste(paste(names,":",new_x[i,],sep=""),collapse=","),"},",sep=""))
  cat(paste("MDS:{",paste(paste(colnames(MDS$points),MDS$points[rownames(new_x)[i],],sep=":"),collapse=","),"}}\n",sep=""))
  if(i!=dim(new_x)[1]){cat(",")}
}
cat("];")
sink()

I still have to update the D3 code by incorporating legends for different sample types though.

There is also a D3 interactive webpage for plotting collapsible trees in Newick format (Instructions and source code given on the page itself with tree shown in the bottom):

http://userweb.eng.gla.ac.uk/umer.ijaz/bioinformatics/PHYLObar_v0.1/PHYLObar.html

Best Wishes,
Umer

ADD COMMENT

Login before adding your answer.

Traffic: 1866 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6