cozygene / FEAST

Fast expectation maximization for microbial source tracking
Other
114 stars 59 forks source link

Error in if (!is.element(class(x), c("matrix", "data.frame", "array"))) x <- matrix(x, : the condition has length > 1 #37

Open b-robinson opened 2 years ago

b-robinson commented 2 years ago

Hello,

I am following the tutorial with the example files posted on this github:

knitr::opts_chunk$set(
  collapse = FALSE,
  comment = "##",
  highlight = TRUE,
  prompt = FALSE,
  results = "markup"
)
Packages <- c("Rcpp", "RcppArmadillo", "vegan", "dplyr", "reshape2", "gridExtra", "ggplot2", "ggthemes")
# install.packages(Packages)
lapply(Packages, library, character.only = TRUE)
devtools::install_github("cozygene/FEAST", ref = "FEAST_beta")
library(FEAST)
metadata <- Load_metadata(metadata_path = "~/FEAST/Data_files/metadata_example_multi.txt")
otus <- Load_CountMatrix(CountMatrix_path = "~/FEAST/Data_files/otu_example_multi.txt")
FEAST_output <- FEAST(C = otus, COVERAGE=NULL, metadata = metadata, different_sources_flag = 1, dir_path = "~/FEAST/Data_files/",
                      outfile="demo")

After this line, I keep getting this error: Error in if (!is.element(class(x), c("matrix", "data.frame", "array"))) x <- matrix(x, : the condition has length > 1

Do you have any suggestions for how to troubleshoot this? I know I am correctly loading the example data as-is into the program.

Thank you, Ben

liashenhav commented 2 years ago

Please use the master and not "FEAST_beta". This is the correct line: devtools::install_github("cozygene/FEAST")

NeginValizadegan commented 1 month ago

This error still shows up when using the metadata_example.txt instead of multi file.

AprilJauhal commented 1 month ago

@NeginValizadegan Have you tried to ensure that the metadata file contains an id column? The metadata_example.txt file requires an id column, which you can add by editing the file, or including this line after running the metadata but prior to running FEAST: if(length(metadata$id)<1) {metadata$id <-1}