cozygene / FEAST

Fast expectation maximization for microbial source tracking
Other
115 stars 60 forks source link

'list' object cannot be coerced to type 'integer' #48

Open melissaszy opened 1 year ago

melissaszy commented 1 year ago

Hello,

sorry for the potentially amateur question.

this is what i have:

str(otus) 'data.frame': 2139 obs. of 175 variables: $ LF004d: int 0 0 0 0 0 0 0 0 0 0 ... $ LF004e: int 0 0 0 0 0 0 0 0 0 0 ... $ LF005c: int 0 0 0 0 0 0 0 0 0 0 ... $ LF005d: int 0 0 0 0 0 0 0 0 0 0 ... $ LF005e: int 0 0 0 0 0 0 0 0 0 0 ... $ LF006a: int 0 0 0 0 0 0 0 0 0 0 ... [list output truncated]

str(metadata) 'data.frame': 175 obs. of 4 variables: $ SampleID : chr "LF004d" "LF004e" "LF005c" "LF005d" ... $ Env : chr "d" "e" "c" "d" ... $ SourceSink: chr "Source" "Source" "Source" "Source" ... $ id : chr "NA" "NA" "NA" "NA" ...

metadata$id contains numbers from 1 to 15 (I have 15 different sinks) and NA (for all sources)

i am trying the FEAST function: FEAST_output <- FEAST(C = otus, metadata = metadata)

this is the error message: Error in FEAST(C = otus, metadata = metadata2) : 'list' object cannot be coerced to type 'integer'

I am not sure how to proceed. Is the issue with metadata$id? i attempted to make metadata$id numeric by typing: metadata$id<-as.numeric(metadata$id)

but the same error message results.

thank you so much for your help.

Sincerely, Melissa

MarieBraadLund commented 11 months ago

Hi I'm having the exact same problem as Mellisaszy. I get the same issue when I run the example data and when I run my own data.

Error message: Error in FEAST(C = data.asv.bac.dna, metadata = metadata, different_sources_flag = 1, : 'list' object cannot be coerced to type 'integer'

R version 4.3.1, FEAST_0.1.0

str(metadata) 'data.frame': 45 obs. of 3 variables: $ Env : Factor w/ 6 levels "air","SBW","seaice",..: 1 1 1 1 1 1 1 1 1 1 ... $ SourceSink: chr "Sink" "Sink" "Sink" "Sink" ... $ id : int 1 1 1 1 1 1 1 1 1 1 ...

str(data.asv.bac.dna.df) 'data.frame': 45 obs. of 13483 variables: $ ASV_2 : int 55 0 0 0 0 0 0 0 0 0 ... $ ASV_5 : int 356 7256 1382 1625 1981 786 4268 1662 724 128 ... $ ASV_6 : int 0 0 0 0 0 0 0 0 0 0 ... $ ASV_8 : int 324 0 122 0 0 0 11 13 7 25 ... $ ASV_9 : int 19307 0 529 0 0 0 2620 28 0 63 ... $ ASV_12 : int 0 0 478 186 68 208 744 330 118 0 ...

Does anybody have a solution to this?

Best regards, Marie

purtyboiii commented 5 months ago

Hello all! I have the same issue as both commenter above and can't figure out the reason. I made sure all data is factors or integer and formatted the same way as in the examples. In my ASV file, the column names are the sample name, but I get the same error if I transpose the matrix or add a SampleID column (it's a character string). Thanks for your help!

`path="~/stats/FEAST/bac/FEAST_to_sessile"

FEAST_output <- FEAST(C = asv, metadata = feast_meta, different_sources_flag = 0)`

asv.csv feast_meta.csv

lowrda commented 3 months ago

Hello! I am having the exact same problem. First, I wanted to confirm that the row names for both the otu table and the sample metadata need to be the sample id names? On the main page the otu table has taxa as rows and sample id's as columns, but I keep seeing online that it is the opposite that works.

Second, if the case is that the columns all need to be intergers... how can we do that when the example data has characters?

AprilJauhal commented 3 months ago

Hopefully I can clarify some of the issues discussed in this thread:

  1. If you are including multiple sources that should be applied to all the sinks, leave the entry for that row blank instead of adding an NA. (In the event that you are using one sink you can set id to 1 for all sources and the one sink and it should run fine)
  2. Every sink must have a unique ID number. If you have 3 sinks for example they should have ids 1, then 2, then 3 (this is regardless of what environment they are in).
  3. The final metadata that is used as input for FEAST should be formatted as follows: Metadata: sample names as rownames, "Env" column specifying sample type, "SourceSink" (Sink or Source), and id column Data: sample names as rownames, taxa names as column names, cells should contain integers.

Note that the Load_CountMatrix function transposes the table, which is why the example data is flipped from what is required for the FEAST function to run. (The Load_metadata function does not transpose data).

Good luck and please let me know if there is still any confusion.

purtyboiii commented 3 months ago

A colleague and I had to add a 'SampleID' column to the meta data table to make it work. The column is the name of each samples, which confusingly, also needs to be the row name. We ended up with 4 columns in the metadata files. It doesn't seem to be what is written in the help files, but it worked for us. Let me know if you have any more questions! Here is what my data looks like

image

lowrda commented 3 months ago

Hey! Thanks for the help everyone! My mistake turns out to have been due to a real rookie move.... My count matrix was a data frame, not a matrix... thank you so much for your help!