EESI / themetagenomics

Other
23 stars 4 forks source link

Error in which(sapply(category_level[[level]], function(x) any(x %in% : argument to 'which' is not logical #19

Open danisangi opened 3 years ago

danisangi commented 3 years ago

hi! I am trying to let my code run. I have followed the DAVID example and it worked. Then I have prepared my tax, meta and abund data in order to get the data as in the example. Everything works well until I try to run the estimate.function (FUNCTION_EFFECTS <- est(FUNCTIONS, iters=300, chains=1,cores=1, return_summary=TRUE)).

then the error I get is the following Error in which(sapply(category_level[[level]], function(x) any(x %in% : argument to 'which' is not logical

My data are arranged as in the example except for a small detail in metadata. Thus, in the david example I have noticed they have additional information (attr (*, "spec")=.. whereas mine data are lacking them. But for metadata I just have information about cultivar and organ of my plants.

here is my code, could you please help me? thank you a lot

**library(themetagenomics) library(shiny) library(Rcpp) library(huge) library(networkD3) library (stm) library("data.table") setwd("/Users/danisangi/Desktop/Rsheets")

tax

data<-read.csv(file="NGS1.csv", header = TRUE, sep = ";", dec = ",") TAX <- data[1:26434,50:56] str(TAX) taxm<-as.matrix(TAX) str(taxm)

abund

data1<- data[,2:49] nomi <- data[,1] row.names(data1) <- nomi str(data1) datat<- t(data1) ABUND <- datat[1:48, 1:26434] str(ABUND) ABUND1<-as.matrix(ABUND) str(ABUND1) e<- ABUND1[1:20,1:20]

meta

meta<-read.csv(file="NGST.csv", header = TRUE, sep = ";", dec = ",")
nomi2 <-meta[,1] row.names(meta) <- nomi2 META1<-meta[1:48, 1:3] colnames(META1) <- c('ID', 'Organ', 'Cv') str(META1) META1$Cv <- as.character(META1$Cv) META1$Organ <- as.character(META1$Organ) str(META1)

strawb<- list(ab1=ABUND1, met=META1, tax=taxm)

clean funzionante

CLEAN <- prepare_data(otu_table=ABUND1, rows_are_taxa=F, tax_table=taxm, metadata=META1, formula=~Organ + (Cv), refs=c('Root','Ds'), cn_normalize=F, drop=F)

clean funzionante

CLEAN <- prepare_data(otu_table=strawb$ab1, rows_are_taxa=F, tax_table=strawb$tax, metadata=strawb$met, formula=~Organ + (Cv), refs=c('Root','Ds'), cn_normalize=F, drop=F)

system.time(TOPICS <- find_topics(CLEAN,K=15))

TOPICS

system.time(TOPIC_EFFECTS <- est(TOPICS))

TOPIC_EFFECTS

system.time({ tmp <- tempdir() download_ref(tmp,reference='silva',overwrite=FALSE) FUNCTIONS <- predict(TOPICS,reference='silva',reference_path=tmp,cn_normalize=T,sample_normalize=FALSE,drop=F, scalar=25) })

problem...

FUNCTION_EFFECTS <- est(FUNCTIONS, iters=300, chains=1,cores=1, return_summary=TRUE)**