vmikk / metagMisc

Miscellaneous functions for metagenomic analysis.
MIT License
44 stars 11 forks source link

Error in dimnames(x) when trying to normalize OTU table in a phyloseq object #12

Closed sklasek closed 4 years ago

sklasek commented 4 years ago

Hello, I am trying to run a cumulative sum scaling normalization on a phyloseq object and got an error: sr4css <- phyloseq_transform_css(sr4, norm = TRUE, log = TRUE) # Error in dimnames(x) <- dn : length of 'dimnames' [1] not equal to array extent I am not quite sure what this means, but was able to successfully run this transformation on the Global Patterns phyloseq object: gp.css <- phyloseq_transform_css(GlobalPatterns, norm = TRUE, log = TRUE) I couldn't find any obvious differences between the layout of these objects except that my object had taxa arranged as columns. I transformed this matrix and created a new object: uto_table <- t(otu_table(sr4)) # transformed my otu table in case they needed to be rows sr4tOTU <- phyloseq(tax_table(tax_table(sr4)), sample_data(sample_data(sr4)), otu_table(uto_table), taxa_are_rows=TRUE) sr4css <- phyloseq_transform_css(sr4tOTU, norm = TRUE, log = TRUE) This returned the same error. Same result when I omit the norm = TRUE, log = TRUE. Any suggestions? I am running R 3.6.2 with phyloseq version 1.30.0, metagMisc 0.0.4, and metagenomeSeq 1.28.0. Thanks, Scott

vmikk commented 4 years ago

Hello @sklasek , My apologies for the slow reply, I must have missed this issue.

It is difficult to say why it's not working without seeing the data. Essentially, phyloseq_transform_css is just a wrapper for metagenomeSeq::MRcounts and you may try to call it directly:

sr4_m <- phyloseq::phyloseq_to_metagenomeSeq(sr4)
otu_norm <- metagenomeSeq::MRcounts(sr4_m, norm = TRUE, log = TRUE)

Please let me know if it works for you.

With best regards, Vladimir

sklasek commented 4 years ago

Hi Vladimir, Calling it directly solves the problem. Thanks! Scott