benjjneb / dada2

Accurate sample inference from amplicon data with single nucleotide resolution
http://benjjneb.github.io/dada2/
GNU Lesser General Public License v3.0
471 stars 143 forks source link

Problem with using metadata #1358

Closed Tinh1425 closed 5 months ago

Tinh1425 commented 3 years ago

Hello everyone, I am analyzing 16S amplicon sequencing with DADA2 and using phyloseq to get the bacterial composition in the community. I try to import the metadata table in R so that I can later use it to tell R which specific samples (facet_wrap) I want to export a barplot. The problem is my metadata table has 6 variables but when I import in R, it just recognizes 1 variable. Could you help me how to solve this problem? You can see my below picture and the scripts I used. Thank you so much in advance.

Best,

Tinh

prepare metadata file in excel and import with Rstudio

metadata <- read.csv('I:/16S analysis/All samples analysis/All_Metadata.csv')

use samples.out as rownames

rownames(metadata) <- samples.out

image

benjjneb commented 3 years ago

The attached image is at too low a resolution to make sense of it.

But the issue here is almost certainly how you are exporting the data and then importing it into R. This is a common data transfer issue, and you might be best served looking beyond dada2/phyloseq -- transferring data between Excel to R is a common problem in many areas of data science.

Tinh1425 commented 3 years ago

Hello Benjamin,

Thank you for your quick reply. Now I manage to solve the problem. I have used "read.table" instead of "read.csv" and it works.

metadata<- read.table('Metadata2.csv', header = T, sep =';', stringsAsFactors = FALSE)

Tinh