ycl6 / 16S-rDNA-V3-V4

16S rDNA V3-V4 amplicon sequencing analysis using dada2, phyloseq, LEfSe, picrust2 and other tools. Demo: https://ycl6.github.io/16S-Demo/
GNU General Public License v3.0
33 stars 18 forks source link

error in evaluating argument 'x' #9

Closed Motteran closed 5 months ago

Motteran commented 5 months ago

Hi Hsuan Lin, Another question arose according to the script.

When I follow the line:

> new_taxtab = taxtab
> rownames(new_taxtab$tax) = df[match(rownames(new_taxtab$tax), df$sequence),]$id

> Error in h(simpleError(msg, call)) :
  error in evaluating argument 'x' when selecting method for function 'match': 'error in evaluating argument 'x' when selecting method for function 'rownames': '$ operator is invalid for atomic vectors''

How can I solve this problem?

ycl6 commented 5 months ago

Hi @Motteran

Can you enclose the R print outs with the code syntax? I edited your post with the proper syntax (see documentation here). For example:

```r x <- sum(c(1, 2, 3, 4)) x ```

You can edit your post to see what I have added to your post.


As to your question, that step is trying to (1) match and order df$sequence with the row names of new_taxtab$tax, and (2) use id from the re-ordered df as new_taxtab$tax's row names.

Something doesn't match up in your case I think. What's the print out if you run str(new_taxtab$tax) and str(df)

Motteran commented 5 months ago

Hi Hsuan Lin The first step of the answer didn't work.. the same error occurred.

As for the later comment:

Input

str(new_taxtab$tax) Error in new_taxtab$tax : $ operator is invalid for atomic vectors

str(df) 'data.frame': 922 obs. of 9 variables: $ sequence : chr "TCCTACGGGAGGCAGCAGTGGGGGATTTTGGACAATGGGCGAAAGCCTGATCCAGCGACGCCGCGTGGAGGACGAAGCCCTTCGGGGTGTAAAACTCCTTTTCTCAGGGAAA"| truncated "TCCTACGGGAGGCAGCAGTAGGGAATATTAGAAATGGACGAAAGTCTGATCTAGCAACACCGCGTGTGCGATGAAGGCCTTCGGGTTGTAAAGCACTTTTTGGAAGGATTA"| truncated "TCCTACGGGAGGCAGCAGTGAGGAATATTGGTCAATGGGCGCAAGCCTGAACCAGCCATCCCGCGTGAAGGAAGAAGGCGCTATGCGTTGTAAACTTCTTTTCCAGGGGGA"| truncated "TCCTACGGGAGGCAGCAGTAGGGAATATTAGTAATGGGCGAAAGCCTGAACTAGCAACGCCGCGTGTGCGAAGAAGGCCTTCGGGTTGTAAAGCACTTTTTGAGAGGATGA"| truncated ... $ abundance: num 1629 1239 1238 1169 1137 ... $id: chr "SV001" "SV002" "SV003" "SV004" ... $ Kingdom : chr "Bacteria" "Bacteria" "Bacteria" "Bacteria" ... $ Phylum : chr "Thermotogae" "Chloroflexi" "Bacteroidetes" "Chloroflexi" ... $ Class : chr "Thermotogae" "Anaerolineae" "Bacteroidia" "Anaerolineae" ... $Order: chr "Thermotogales" "Anaerolineales" "Bacteroidales" "Anaerolineales" ... $ Family : chr "Fervidobacteriaceae" "Anaerolineaceae" "Bacteroidetes_vadinHA17" "Anaerolineaceae" ... $ Genus : chr "Fervidobacterium" NA NA NA ...

In the case of str(new_taxtab$tax), no tax column was found, I don't know why.

ycl6 commented 5 months ago

Hi @Motteran, you are still not using the proper code synthax in your reply. It is very hard to read the content like that. Can you edit your post to enclose the R output with the code syntax please!


As per my tutorial here, new_taxtab is a copy of taxtab.

Hence you need to trace back see what has gone wrong with your taxtab. Maybe starting from the Assign taxonomy step where we first create the taxtab variable.

Motteran commented 5 months ago

Dear Hsuan Lin I managed to find my mistake.

Att.