This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Error while doing shannon and pielou index analysis using Vegan in R

Hi there, I am able to run richness, but unable to run Shannon or Pielou index. I am attaching the file and scripts here. Thanks in advance

https://www.dropbox.com/s/0w2l6ijo6cl0vy6/rarify_table_1378.xlsx?dl=0

library(vegan) #Load vegan library library(agricolae) # for ANOVA HSD

library( BiodiversityR) # For rank abundance curve

library(readxl) library(tibble) # To work with data frames library(xlsx) library(ggplot2) # Generates nice plots library(ggrepel) # Adds in to ggplot library("corrplot") # Corelation plots library("RcmdrMisc")

Diversity analyses on rarefied tables

rarify_table = read_excel("rarify_table_1378.xlsx", col_names = TRUE, na = "", sheet = 1) rarify_table <- column_to_rownames(rarify_table, var = "OTU_ID")
str(rarify_table) attach(rarify_table)

check numerical and chr datatypes

attach(new_meta_table)

Diversity calculation - OTUs richness

Richness<-specnumber(rarify_table)

richness<-estimateR(rarify_table)

Shannon diversity index (H) index (considers richness and evenness)

H <- diversity(rarify_table, index="shannon",MARGIN = 1, base = exp(1)) plot(H, type="l", col="blue")

Pielou's index of evenness (range 0-1, 1 = maximum evenness)

J=H/Hmax

J=Shannon (H) / log(S=species richness)

J=H/log(rowSums(rarify_table>0)) plot(J, type="l", col="blue")

I am getting the following error for Shannon **> H <- diversity(rarify_table, index="shannon",MARGIN = 1, base = exp(1)) Error in diversity(rarify_table, index = "shannon", MARGIN = 1, base = exp(1)) : input data must be numeric

plot(H, type="l", col="blue") Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'plot': object 'H' not found**

**I am getting the below mentioned error for Pileu index

J=H/log(rowSums(rarify_table>0)) Error: object 'H' not found plot(J, type="l", col="blue") Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'plot': object 'J' not found**

Regards, Dinesh

16s microbiome vegan r

0 answers

No answers yet.

Log in to answer this question.