Adonis analysis

Hello everyone,

I want to perform adonis analysis in R using the Bray-curtis matrix that I have. I do not know what the error is that I am getting.
I am using the following codes:

#Adonis analysis

library(tidyverse)
library(readxl)
library(vegan)

metadata <- read_excel("metadata.xlsx")

distance <- read_excel("bray_curtis.xlsx")
dist_mat <- distance %>% remove_rownames %>% column_to_rownames(var="sample_id")
colnames(dist_mat) <- c("sample_id")
meta_distance <- inner_join(metadata, distance, by="sample_id")

all_dist <- meta_distance %>%
  select(all_of(.[["sample_id"]])) %>%
  as.dist()

adonis(all_dist~Farm, data = meta_distance)

The bray_curtis matrix:

The metadata:

I would appreciate any help!

Thanks

Hi, can you provide reproducible examples of your dataset instead of screenshots?

Yes, of course.

> head(metadata)
# A tibble: 6 x 14
  sample_id Farm  Variety Treat Location Treatment Copper BarcodeSequence
  <chr>     <chr> <chr>   <chr> <chr>    <chr>      <dbl> <chr>          
1 ID1468-1~ Moli~ PI      TE    West     soil        34.2 ACTCGCTATTATGC~
2 ID1468-1~ Moli~ PI      TE    West     soil        51.9 ACTCGCTAGAGCCT~
3 ID1468-1~ Moli~ PI      TE    West     soil        38.9 ACTCGCTAAAGGCT~
4 ID1468-1~ Moli~ PI      TE    West     soil        51.2 ACTCGCTACTATTA~
5 ID1468-1~ Moli~ PI      TE    West     soil        44.0 ACTCGCTAGCGTAA~
6 ID1468-1~ Moli~ PI      TE    East     soil        32.6 ACTCGCTACCTAGA~
# ... with 6 more variables: LinkerPrimerSequence <chr>, ReversePrimer <chr>,
#   LinkerPrimerSequence_RC <chr>, ReversePrimer_RC <chr>, Demultiplexer <chr>,
#   Description <chr>
> head(distance)
# A tibble: 6 x 49
  sample_id ID1468.16S.3 ID1468.16S.9 ID1468.16S.11 ID1468.16S.44 ID1468.16S.27
  <chr>            <dbl>        <dbl>         <dbl>         <dbl>         <dbl>
1 ID1468.1~        0            0.403         0.444         0.556         0.512
2 ID1468.1~        0.403        0             0.448         0.529         0.496
3 ID1468.1~        0.444        0.448         0             0.581         0.559
4 ID1468.1~        0.556        0.529         0.581         0             0.523
5 ID1468.1~        0.512        0.496         0.559         0.523         0    
6 ID1468.1~        0.635        0.600         0.671         0.560         0.598

Is it fine like this?

Sorry, but no. Can you please read the guide ? its a relatively fast read and packed with useful information for interacting with the forum effectively. It really will benefit you in your search for help.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.