Hi!

R indeed cannot distinguish between your Site and Species columns. You either need to state "row.names=1" while loading your csv-files into workspace or you can rearrange your dataframe like this:

|bats2 <-bats[,-1]rownames(bats2)<-bats[,1] Alternatively, you can tell R which columns of your dataframes should be excluded in the adonis call. About your other questions: You may want to look into ?vegdist to see the different methods adonis() accepts. I think Soerensen is the presence/absence version of Bray-Curtis. Jaccard is another simple index for occurence data, and can be computed by vegdist. Since you are doing post hoc hypothesis testing, you might want to state a number of permutations within the adonis call. I think (you should update yourself on this) that the permutations also removes possible autocorrelation from the dataset, which would be possibly convenient in your study question. For starters, i suggest reading the many vegan tutorials available or - if you can get your hands on it - the Numerical Ecology textbook by Legendre & Legendre. I did so, and it served me quite well. Also, tutorials on basic data handling and navigation in R would come in quite handily, i guess. Cheers|,


On 23.12.2015 10:07, michael.eisenr...@agroscope.admin.ch wrote:
Dear Erica and Hazel,
Thank you very much for your help.
Based on Ericas feedback I use now a the raw data giving me information on 
abundance of bat species (I changed the data set) that were caught at 6 
different sites (file named bats)

Thanks to Hazels input I use now an additional file (named forest_type) 
assigning a forest type (O or Y) to each site.
Using Adonis I would like to convert my bats in a first step to a soerenson 
(dis)similarity matrix and then use the Adonis function to see how bat 
communities differ between forest types.

With the help of you I was now able to write some code
The code seems to work. However, I have 2 more (basic) questions.

1) Do I have to convert my data sets in a specific way (I structured it as in the R help example using the 
dune data)? I have the problem that R thinks the first row (the very left one) with the header 
"Site" is just another species of bat ( if you open the bat file in R and scroll to the top you see 
what I mean, "Site" is next to "Kerivoula...." and it is treated just like another bat 
species). How can I solve the problem?

2)Is the code correct? I am especially unsure if my conversion to a dissimilarity matrix 
worked, since the results are exactly the same , regardless if I add 
method="bray" or not to my code.

Below is the code and the 2 data sets (dput)



#load data sets
#file with abundance information of each caught bat at each site
bats<-read.csv("bats_abundance.csv",sep=";",header=T)
#file with forest type (O,Y) information
forest_type<-read.csv("forest_type_6.csv",sep=";")
attach(bats)
attach(forest_type)
bats
forest_type

#Aim: compare how bat communities differ between O and Y forests
#How can I convert bats first to soerenson dissimilarity matrix ()
adonis(bats~forest, data=forest_type,method="bray")


dput(bats)
structure(c(1L, 2L, 3L, 4L, 5L, 6L, 1L, 1L, 1L, 1L, 1L, 1L, 0L,
0L, 1L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L,
0L, 1L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L,
0L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L,
0L, 0L, 1L, 0L, 0L, 0L, 0L), .Dim = c(6L, 14L), .Dimnames = list(
     NULL, c("Site", "Kerivoula_smithii", "Scotophilus_nigrita",
     "Minipoterus_natalensis", "Miniopterus_fraterculus", "Neoromicia_nana",
     "Otomops_martiensseni", "Chaerephon_pumilus", "Rhinolophus_clivosus",
     "Hipposideros_caffer", "Lissonycteris_angolensis", 
"Pipistrellus_hesperidus",
     "Pipistrellus_nanulus", "Rhinolophus_fumigatus")))


dput(forest_type)
structure(list(Site = 1:6, forest = structure(c(1L, 2L, 2L, 2L,
1L, 1L), .Label = c("O", "Y"), class = "factor")), .Names = c("Site",
"forest"), class = "data.frame", row.names = c(NA, -6L))





Thanks a lot,
Mike















Eisenring Michael, Msc.
PhD Student

Federal Department of Economic Affairs, Education and Research
EAER
Institute of Sustainability Sciences ISS
Biosafety

Reckenholzstrasse 191, CH-8046 Zürich
Tel. +41 44 37 77181
Fax +41 44 37 77201
michael.eisenr...@agroscope.admin.ch
www.agroscope.ch

-----Ursprüngliche Nachricht-----
Von: Hazel Knipe [mailto:hazel_kn...@hotmail.co.uk]
Gesendet: Dienstag, 22. Dezember 2015 18:34
An: Eisenring Michael Agroscope <michael.eisenr...@agroscope.admin.ch>
Betreff: Re: How to conduct a PERMANOVA using a dissimilarity matrix

Dear Michael,

You need to create another file dividing the different categories/ variables 
(make sure that they are in the same order for the variable you are testing), 
then attach it and run the adonis function. For example:

attach(metadata)

adonis(formula = vegdist(matrixfile, method = "bray") ~ Site, data = metadata)

It's also important to think about if you have nestedness in your design, in 
which case you would need to add strata = factor:

adonis(formula = vegdist(matrixfile, method = "bray") ~ Species, data = 
metadata,      strata = Site)

I hope this helps for now! Let me know if you need more detail.

Hazel (BSc student).



________________________________________
From: R-help <r-help-boun...@r-project.org> on behalf of 
michael.eisenr...@agroscope.admin.ch <michael.eisenr...@agroscope.admin.ch>
Sent: 22 December 2015 16:18
To: r-help@r-project.org
Subject: [R] How to conduct a PERMANOVA using a dissimilarity matrix

Dear R-List members,

I have to compare how similar two types of forest (old growth=O) and (young 
forest=Y) in terms of moth communities are.
I sampled moths at 4 O and 4 Y sites.
I need to analyse the data using a PERMANOVA approach. But I am having a really 
hard time to do this in R.

I found out that I need to create a dissimilarity matrix and read this matrix 
then into R to conduct a one-way Permanova with forest type (O or Y) as factor.
The package vegan with the function "adonis" seems to be able to do a permanova.

I created the matrix (based on Soerenson (dis)similarities) and imported it 
into R.

Could anyone help me with the next step? How can I conduct a permanova on my 
dataset? In the end I would need an R value and significance level telling me 
if community compositions differ significantly between sites.

Below is my code (not too much) and the data for the matrix.

#dput for matrix:

structure(c("", "O", "Y", "Y", "Y", "O", "O", "Y", "O", "O", "0", "0.544", "0.519", "0.533", "0.481", "0.548", "0.518", "0.479", "Y", "0.544", "0", "0.383", "0.416", "0.383", "0.358", "0.434", "0.399", "Y", "0.519", "0.383", "0", "0.398", "0.359", "0.392", "0.401", "0.374", "Y", "0.533", "0.416", "0.398", "0", "0.398", "0.399", "0.358", "0.348", "O", "0.481", "0.383", "0.359", "0.398", "0", "0.37", "0.317", "0.354", "O", 
"0.548", "0.358", "0.392", "0.399", "0.37", "0", "0.39", "0.365", "Y", "0.518", "0.434", "0.401", "0.358", "0.317", "0.39", "0", "0.371", "O", "0.479", "0.399", "0.374", "0.348", "0.354", "0.365", "0.371", "0"), .Dim = c(9L, 9L), .Dimnames = list(NULL, c("V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8", "V9")))


#Code
#load dissimilarity matrix (based on Soerenson similarity) 
moth_dta<-read.csv("Geo_sorenson_8.csv",header=T,sep=";")#Creates matrix from 
imported data
moth_dta<-as.matrix(moth_dta)
moth_dta
library(vegan)


Thank you very much,
Michael

Eisenring Michael, Msc.
PhD Student

Federal Department of Economic Affairs, Education and Research EAER Institute 
of Sustainability Sciences ISS Biosafety

Reckenholzstrasse 191, CH-8046 Z rich
Tel. +41 44 37 77181
Fax +41 44 37 77201
michael.eisenr...@agroscope.admin.ch<mailto:michael.eisenr...@agroscope.admin.ch>
www.agroscope.ch<http://www.agroscope.ch/>


         [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


--
Tim Richter-Heitmann (M.Sc.)
PhD Candidate



International Max-Planck Research School for Marine Microbiology
University of Bremen
Microbial Ecophysiology Group (AG Friedrich)
FB02 - Biologie/Chemie
Leobener Straße (NW2 A2130)
D-28359 Bremen
Tel.: 0049(0)421 218-63062
Fax: 0049(0)421 218-63069

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to