cozygene / FEAST

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

Error in if (sum(x[i, ]) > maxdepth) { : missing value where TRUE/FALSE needed using Nonunique_Sources branch #18

Closed sixvable closed 3 years ago

sixvable commented 4 years ago

Hi ! I got error when using FEAST with replicate sinks through Nonunique_Sources branch.

Here is my code

library(FEAST)
library(readr)
library(tibble)

metadata <- Load_metadata(metadata_path = "feast/metadata.txt")
otus <- read.delim("feast/otu_table_with_starter.txt",row.names=1)
otus <- t(otus)
otus <- otus[metadata$SampleID,]
FEAST_output <- FEAST(C=otus,metadata = metadata,different_sources_flag = 1,dir_path = "feast/",outfile = "bac")

#> Error in if (sum(x[i, ]) > maxdepth) { : 
  missing value where TRUE/FALSE needed

The file I used are otu_table_with_starter.txt metadata.txt

Could you check my files and rerun the code to debug?

Thanks very much!

liashenhav commented 4 years ago

Hi,

The 'Nonunique_Sources' branch is suitable in the case of multiple sinks sharing some/all sources. Is that the case in your data? Can you share your metadata? You can email it directly to liashenhav at gmail dot com

Thanks,

Liat

On Sun, Aug 30, 2020 at 6:31 AM sixvable notifications@github.com wrote:

Hi ! I got error when using FEAST with replicate sinks through Nonunique_Sources branch.

Here is my code

library(FEAST) library(readr) library(tibble)

metadata <- Load_metadata(metadata_path = "feast/metadata.txt") otus <- read.delim("feast/otu_table_with_starter.txt",row.names=1) otus <- t(otus) otus <- otus[metadata$SampleID,] FEAST_output <- FEAST(C=otus,metadata = metadata,different_sources_flag = 1,dir_path = "feast/",outfile = "bac")

> Error in if (sum(x[i, ]) > maxdepth) { :

missing value where TRUE/FALSE needed

The file I used are otu_table_with_starter.txt https://github.com/cozygene/FEAST/files/5146640/otu_table_with_starter.txt metadata.txt https://github.com/cozygene/FEAST/files/5146641/metadata.txt

Could you check my files and rerun the code to debug?

Thanks very much!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cozygene/FEAST/issues/18, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIQ7SASPT724BLZ6YVO2XKLSDIS6ZANCNFSM4QPRMN5Q .

-- Liat Shenhav

sixvable commented 4 years ago

otu_table_with_starter.txt metadata.txt Can you see those files I directly upload via github comment

liashenhav commented 4 years ago

Got it, thanks. First, the reason you are getting this error is that multiple sinks share the same identifier in the metadata. Each sink should have a unique identifier (i.e., a unique number in the metadata 'id' column). Second, can you describe the setup of your source tracking analysis? This is important for contracting the metadata.

Thanks,

Liat

On Sun, Aug 30, 2020 at 10:58 AM sixvable notifications@github.com wrote:

otu_table_with_starter.txt https://github.com/cozygene/FEAST/files/5146981/otu_table_with_starter.txt metadata.txt https://github.com/cozygene/FEAST/files/5146983/metadata.txt Can you see those files I directly upload via github comment

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cozygene/FEAST/issues/18#issuecomment-683430629, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIQ7SAVXUO4SPSUKQIOOHZTSDJSJFANCNFSM4QPRMN5Q .

-- Liat Shenhav

sixvable commented 4 years ago

I have two treatment group2.Each group contains 12 samples in replicates(mean there are 36 samples in each group). Inside each group 1 sample is the source (3 for replicating) and I am trying to sourcetracker other 11 samples (total 33 in each group). So I made my metadata 2 id for each treatment!

liashenhav commented 4 years ago

I understand, but you would still need to assign each sink a unique id (even if it a replicate), as this is required input.

On Aug 30, 2020, at 11:12 AM, sixvable notifications@github.com wrote:

I have two treatment group2.Each group contains 12 samples in replicates(mean there are 36 samples in each group). Inside each group 1 sample is the source (3 for replicating) and I am trying to sourcetracker other 11 samples (total 33 in each group). So I made my metadata 2 id for each treatment!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cozygene/FEAST/issues/18#issuecomment-683432223, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIQ7SAVDIUVRGBPWGS5UGNTSDJT5PANCNFSM4QPRMN5Q.

NeginValizadegan commented 3 years ago

I am getting a similar error, just slightly different. I assigned each sink sample with a unique number but left sources as blank as instructed in the github page. I mad sure to convert NAs to blank but still get this error.

Error in if (sum(x[i, ]) > maxdepth) { : missing value where TRUE/FALSE needed Calls: FEAST -> Infer.SourceContribution -> FEAST_rarefy In addition: Warning messages: 1: In if (!is.element(class(x), c("matrix", "data.frame", "array"))) x <- matrix(x, : the condition has length > 1 and only the first element will be used 2: In if (!is.element(class(x), c("matrix", "data.frame", "array"))) x <- matrix(x, : the condition has length > 1 and only the first element will be used 3: In if (!is.element(class(x), c("matrix", "data.frame", "array"))) x <- matrix(x, : the condition has length > 1 and only the first element will be used Execution halted

liashenhav commented 3 years ago

can you share your data and metadata? You can email it to liashenhav@gmail.com mailto:liashenhav@gmail.com

Thanks,

Liat

On Jan 24, 2021, at 1:21 PM, Negin Valizadegan notifications@github.com wrote:

I am getting a similar error, just slightly different. I assigned each sink sample with a unique number but left sources as blank as instructed in the github page. I mad sure to convert NAs to blank but still get this error.

Error in if (sum(x[i, ]) > maxdepth) { : missing value where TRUE/FALSE needed Calls: FEAST -> Infer.SourceContribution -> FEAST_rarefy In addition: Warning messages: 1: In if (!is.element(class(x), c("matrix", "data.frame", "array"))) x <- matrix(x, : the condition has length > 1 and only the first element will be used 2: In if (!is.element(class(x), c("matrix", "data.frame", "array"))) x <- matrix(x, : the condition has length > 1 and only the first element will be used 3: In if (!is.element(class(x), c("matrix", "data.frame", "array"))) x <- matrix(x, : the condition has length > 1 and only the first element will be used Execution halted

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cozygene/FEAST/issues/18#issuecomment-766434161, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIQ7SAWE2ICSJWG54XF7IKLS3SFMFANCNFSM4QPRMN5Q.

NeginValizadegan commented 3 years ago

can you share your data and metadata? You can email it to liashenhav@gmail.com mailto:liashenhav@gmail.com Thanks, Liat On Jan 24, 2021, at 1:21 PM, Negin Valizadegan @.***> wrote: I am getting a similar error, just slightly different. I assigned each sink sample with a unique number but left sources as blank as instructed in the github page. I mad sure to convert NAs to blank but still get this error. Error in if (sum(x[i, ]) > maxdepth) { : missing value where TRUE/FALSE needed Calls: FEAST -> Infer.SourceContribution -> FEAST_rarefy In addition: Warning messages: 1: In if (!is.element(class(x), c("matrix", "data.frame", "array"))) x <- matrix(x, : the condition has length > 1 and only the first element will be used 2: In if (!is.element(class(x), c("matrix", "data.frame", "array"))) x <- matrix(x, : the condition has length > 1 and only the first element will be used 3: In if (!is.element(class(x), c("matrix", "data.frame", "array"))) x <- matrix(x, : the condition has length > 1 and only the first element will be used Execution halted — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#18 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIQ7SAWE2ICSJWG54XF7IKLS3SFMFANCNFSM4QPRMN5Q.

I just did.

NeginValizadegan commented 3 years ago

Thank you @liashenhav for helping me with this.

For other users who might have gotten a similar error, my problem was that I had the same sources for all sinks but I had used different_sources_flag = 1 as per the Github tutorial instructions instead of different_sources_flag = 0. If you check out the R documentation for FEAST, you will see that you should use different_sources_flag = 0 if you are using same sources with all sinks.

Also, on another note, it might be better to use as similar number of sample size as you could for your sources and sink, ideally randomly selected from a large pull of samples. What I mean is that for example, have 10 samples per source and 10 sample for your sink.

liashenhav commented 3 years ago

Can you please share the code you’re running?

On Jun 20, 2021, at 2:22 AM, FredYu1990 @.***> wrote:

Hi @liashenhav https://github.com/liashenhav, I also met this problem but I cannot fix it even double checked the sink id. Hereby attached with my mock files, could you please help me have a look? Many thanks! metadata_example_multi.txt https://github.com/cozygene/FEAST/files/6681826/metadata_example_multi.txt otu_example_multi.txt https://github.com/cozygene/FEAST/files/6681827/otu_example_multi.txt — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cozygene/FEAST/issues/18#issuecomment-864506296, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIQ7SARFW3DYGHXN55I7GCDTTWCL5ANCNFSM4QPRMN5Q.

FredYu1990 commented 3 years ago

Can you please share the code you’re running? On Jun 20, 2021, at 2:22 AM, FredYu1990 @.***> wrote: Hi @liashenhav https://github.com/liashenhav, I also met this problem but I cannot fix it even double checked the sink id. Hereby attached with my mock files, could you please help me have a look? Many thanks! metadata_example_multi.txt https://github.com/cozygene/FEAST/files/6681826/metadata_example_multi.txt otu_example_multi.txt https://github.com/cozygene/FEAST/files/6681827/otu_example_multi.txt — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#18 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIQ7SARFW3DYGHXN55I7GCDTTWCL5ANCNFSM4QPRMN5Q.

Thank you for your reply. I found the mistakes in my files and now it works. :)

CamilaDuitama commented 3 years ago

I had all the same issues described in this thread and I found out that I was making an extra mistake from the ones described here, that kept showing me this same error (https://github.com/cozygene/FEAST/issues/18#issuecomment-766434161).

Beware that the function Load_CountMatrix() transposes your input OTU table that has taxa as rows and samples as columns. So in the end, the function FEAST() uses as input a matrix that has samples as rows and taxa as columns. It was a bit confusing for me reading the documentation because the count matrix shown as an example in the README.md is the input of Load_CountMatrix(), not the input of FEAST() directly.

Also thanks @liashenhav once more for your help!

NeginValizadegan commented 3 months ago

I understand, but you would still need to assign each sink a unique id (even if it a replicate), as this is required input. On Aug 30, 2020, at 11:12 AM, sixvable @.***> wrote: I have two treatment group2.Each group contains 12 samples in replicates(mean there are 36 samples in each group). Inside each group 1 sample is the source (3 for replicating) and I am trying to sourcetracker other 11 samples (total 33 in each group). So I made my metadata 2 id for each treatment! — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#18 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIQ7SAVDIUVRGBPWGS5UGNTSDJT5PANCNFSM4QPRMN5Q.

If we give each sink a unique ID, then how do we fulfill the requirement of having the same id for source and sink when multiple sinks comes from the same source? It might be helpful to provide an example metadata on the readme page for cases when we have multiples sinks that are linked with the same source