Calculating Evenness

Hi all,

I am interested how mothur calculates evenness from the Shannon index.

When I calculate the evenness from an community using the formula: [(Shannon index value)/ln(sobs)], I get a very different number than when I use the mothur shannoneven command.

I was curious and had some time to kill before seminar so I looked in the file containing the shannoneven code (shown below signature). I saw that the calculation seemed to be off since it used log(sobs) instead of ln(sobs). Is this a bug? Or do I have no idea on how to interpret coding and or perform stats?

Thanks ahead of time for your help and for coming up with such a cool analysis pipeline.

-J

EstOutput ShannonEven::getValues(SAbundVector* rank){
 try {
  //vector<double> simpsonData(3,0);
  data.resize(1,0);
  vector<double> shanData(3,0);
  Shannon* shannon = new Shannon();
  shanData = shannon->getValues(rank);
  
  long int sobs = rank->getNumBins();
  if(sobs > 1){
   data[0] = shanData[0] / log(sobs);
  }
  else{
   data[0] = 1;
  }
  
  delete shannon;
  return data;
 }
 catch(exception& e) {
  m->errorOut(e, "ShannonEven", "getValues");
  exit(1);
 }
}

In C+±speak, “log” is the natural log (base e), which is the same as ln. Do you have an example rabund/sabund file you can share to figure out what might be going wrong?

Hi Pat,

Thanks for the quick response. I realized I made a mistake in my calculation within Excel. I was using total number of sequences for my Sobs instead of total number of OTUs. :roll: So everything is kosher.

Keep up the good work,
-J