joey711 / phyloseq

phyloseq is a set of classes, wrappers, and tools (in R) to make it easier to import, store, and analyze phylogenetic sequencing data; and to reproducibly share that data and analysis with others. See the phyloseq front page:
http://joey711.github.io/phyloseq/
567 stars 187 forks source link

phyloseq x metagMisc phyloseq_coverage_raref: Error "OTU abundance data must have non-zero dimensions" #1728

Open PeSteff opened 4 months ago

PeSteff commented 4 months ago

Hello community, I have been tinkering with phyloseq and many related packages e.g. microViz for a while without any unsolvable error, but now I am stuck. I have loaded my data into R without any warnings or errors and done a whole lot of computations and graphs. Great! I recently wanted to try to rarefy to equal coverage, using the same data as always by running

myphylo_cov_rare <- phyloseq_coverage_raref(physeq = phy_total_filtered, iter = 1, replace = F, correct_singletons = TRUE, seeds = 711, multithread = 4, drop_lowcoverage = F)

from the package metagMisc Link here. Another function from this package phyloseq_coverage ran without error using the exact same input data.

Yet now I get the following error:

Error in validObject(.Object) : invalid class “otu_table” object: OTU abundance data must have non-zero dimensions.

I went through many forum posts but couldn't find the solution yet. Learning from these posts I already checked the following:

phy_total_filtered

phyloseq-class experiment-level object
otu_table()   OTU Table:         [ 25804 taxa and 100 samples ]
sample_data() Sample Data:       [ 100 samples by 44 sample variables ]
tax_table()   Taxonomy Table:    [ 25804 taxa by 7 taxonomic ranks ]
phy_tree()    Phylogenetic Tree: [ 25804 tips and 25767 internal nodes ]
refseq()      DNAStringSet:      [ 25804 reference sequences ]

class(phy_total_filtered)

[1] "phyloseq"
attr(,"package")
[1] "phyloseq"

class(otu_table(phy_total_filtered))

[1] "otu_table"
attr(,"package")
[1] "phyloseq"

dim(otu_table(phy_total_filtered))

[1] 25804   100

otu_table(phy_total_filtered)[1:9,1:3]

OTU Table:          [9 taxa and 3 samples]
                     taxa are rows
       S228 S229 S230
ASV87     0    0    0
ASV135    0    0    0
ASV176    0    0    0
ASV177    0    0    0
ASV187    0    0    0
ASV254    0    0    0
ASV314    0    0    0
ASV315    3    3    0
ASV372    0    0    2

length(dim(otu_table(phy_total_filtered)))

[1] 2

sum(!is_wholenumber(otu_table(phy_total_filtered)))

[1] 0

colnames(otu_table(phy_total_filtered))[1:10]

 [1] "S228" "S229" "S230" "S231" "S232" "S233" "S234" "S235" "S236" "S237"

rownames(otu_table(phy_total_filtered))[1:10]

 [1] "ASV87"  "ASV135" "ASV176" "ASV177" "ASV187" "ASV254" "ASV314" "ASV315" "ASV372" "ASV390"

So it seems to me that the dimensions, the structure, class, content, names etc. of the otu-table is just fine. I do not know what else to check.

Package versions are phyloseq: 1.42.0, metagMisc 0.5.0

> sessionInfo()
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

The error I get seems like a phyloseq related error related to this to me which is why I am posting here, but eventually I just don't know. If this is an issue of compatability of this one specific function and my data is fine as it is, is there maybe a way to circumvent the error and have the code run anyways?

Also I tested

> any(dim(otu_table(phy_total_filtered))) == 0
[1] FALSE
> any(dim(phy_total_filtered)) == 0
[1] TRUE
> dim(phy_total_filtered)
NULL

So if I feed the entire phyloseq object, the dimension is NULL, so I tried to only input the otu-table like this

myphylo_cov_rare <- phyloseq_coverage_raref(physeq = otu_table(phy_total_filtered), iter = 1, replace = F, correct_singletons = TRUE, seeds = 711, multithread = 4, drop_lowcoverage = F)

but the error still appeared.

Any help is appreciated.