leffj / mctoolsr

Microbial community analysis tools in R
http://leffj.github.io/mctoolsr/
20 stars 8 forks source link

mctoolsr not working after R update #36

Closed dmsande2 closed 2 years ago

dmsande2 commented 2 years ago

I've recently updated R and R Studio to the latest versions, however the exact same lines of code that I ran before updating are now giving errors as if mctoolsr is now having trouble reading my .txt files properly when I try using the load_taxa_table command. I did need to reinstall all of my packages, including mctoolsr, after updating so I am not sure if this is an installation issue or an issue with my files. I've tried quitting and restarting R to no avail, is there anything else I can try so I won't get these errors and I can run my code as normal?

This is the error I get running the same code and files that I have previously:

input_r <- load_taxa_table("data_16S.txt", "metadata.txt") Error in if (class(tmp) == "list") { : the condition has length > 1

I thought there may be an issue with the # in the first line, so I made another file removing the hashtag in the OTU table file and re-ran the code, then received this error instead:

Warning in load_taxa_table("data_16S.txt", "metadata.txt") : No taxonomy loaded. If taxonomy should have been loaded, check that "taxonomy" header exists. 0 samples loaded

realmichaelhoffert commented 2 years ago

Hi! First, I don't think this package is maintained any more, so I would recommend weaning yourself off of mctoolsR at some point. A workaround to this problem is:

  1. Cloning the repo locally
  2. Changing line 77 of taxonomy-based.R to something like class(tmp)[1] == "list"
  3. reinstalling the local version with devtools: devtools::install('/path/to/cloned/version')

Basically, it's caused by class(tmp) returning a vector which is compared to a string, which R doesn't like. R may have updated how the class function describes objects in a recent update.

leffj commented 2 years ago

Thanks for the post @dmsande2 and solution @realmichaelhoffert. Fixed.