Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
melissaszy opened this issue Mar 2, 2023 · 6 comments
Open

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

melissaszy opened this issue Mar 2, 2023 · 6 comments

Comments

@melissaszy
Copy link

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
Copy link

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

@SamuelBeauregard
Copy link

SamuelBeauregard commented May 14, 2024

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
Copy link

lowrda commented Jul 4, 2024

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
Copy link

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.

@SamuelBeauregard
Copy link

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
Copy link

lowrda commented Jul 8, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants