Appropriate rownames error (new error with version update)

Hi -

I’m having a new issue with an update to Maaslin2 (I’m running the same code as I ran in version 1.10.0 now in version 1.14.1 and now experiencing an error). I believe the error is related to my input data and input metadata, but I’m not sure how to fix it. I am getting two different errors depending on how I import my data/metadata. The first way I tried is the exact same way as I was successfully importing the data/metadata before with 1.10.0. The second way is the suggested import method from the Maaslin2 tutorial online. There are NAs in the matrix, but I don’t believe that is the issue as I have replaced them with 0’s and still have the same errors. I have included a subset of my data to help troubleshoot/replicate the errors.

Thank you for any help.

Main session information:

R version 4.3.0 (2023-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.6 LTS

> packageVersion("Maaslin2")
[1] ‘1.14.1’

First version of the code I have tried to run:

library(dplyr) # v. 1.1.2
library(Maaslin2) # v. 1.14.1
library(ggplot2) # v. 3.4.2
library(ggpubr) # v. 0.6.0

# 1. Load metadata ####
metadata <- read.csv(file = "metadata_subset.csv", sep = ",", header= TRUE)

# 2. Load Data ####
df <- read.csv(file = "OTU_FUNguild_subset.csv", sep = ",", header= TRUE)

# 3. Run MaAsLin2 - subset ####

fit_data_cplm_none_category <-
  Maaslin2(
    input_data = df, 
    input_metadata = metadata, 
    output = "fit_data_cplm_none_category", 
    analysis_method = "CPLM",
    normalization = "NONE",
    transform = "NONE",
    fixed_effects = c("category_broad")
  )

Error:

Error in Maaslin2(input_data = df, input_metadata = metadata, output = "fit_data_cplm_none_category",  : 
  If supplying input_data as a data frame, it must have appropriate rownames!

Second version of the code I have tried to run:

library(dplyr) # v. 1.1.2
library(Maaslin2) # v. 1.14.1
library(ggplot2) # v. 3.4.2
library(ggpubr) # v. 0.6.0

# 1. Load metadata ####
metadata <- read.csv(file = "metadata_subset.csv", sep = ",", header= TRUE, row.names = 1, stringsAsFactors = FALSE)

# 2. Load Data ####
df <- read.csv(file = "OTU_FUNguild_subset.csv", sep = ",", header= TRUE, row.names = 1, stringsAsFactors = FALSE)

# 3. Run MaAsLin2 - subset ####

fit_data_cplm_none_category <-
  Maaslin2(
    input_data = df, 
    input_metadata = metadata, 
    output = "fit_data_cplm_none_category", 
    analysis_method = "CPLM",
    normalization = "NONE",
    transform = "NONE",
    fixed_effects = c("category_broad")
  )

Error:

Error in `rownames<-`(x, value) : 
  attempt to set 'rownames' on an object with no dimensions

Other session info:

> sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/Chicago
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggpubr_0.6.0    ggplot2_3.4.2   dplyr_1.1.2     Maaslin2_1.14.1

loaded via a namespace (and not attached):
 [1] gtable_0.3.3      ggsignif_0.6.4    compiler_4.3.0    crayon_1.5.2      tidyselect_1.2.0  optparse_1.7.3   
 [7] tidyr_1.3.0       scales_1.2.1      R6_2.5.1          generics_0.1.3    pcaPP_2.0-3       biglm_0.9-2.1    
[13] robustbase_0.99-0 backports_1.4.1   tibble_3.2.1      car_3.1-2         munsell_0.5.0     DBI_1.1.3        
[19] pillar_1.9.0      rlang_1.1.1       utf8_1.2.2        getopt_1.20.3     broom_1.0.5       cli_3.6.1        
[25] withr_2.5.0       magrittr_2.0.3    grid_4.3.0        rstudioapi_0.14   mvtnorm_1.2-2     logging_0.10-108 
[31] lifecycle_1.0.3   DEoptimR_1.0-14   vctrs_0.6.3       rstatix_0.7.2     glue_1.6.2        data.table_1.14.8
[37] abind_1.4-5       hash_2.2.6.2      carData_3.0-5     fansi_1.0.3       colorspace_2.1-0  purrr_1.0.1      
[43] tools_4.3.0       pkgconfig_2.0.3  

metadata_subset.csv (603 Bytes)
OTU_FUNguild_subset.csv (7.8 KB)

Hi @Alix_Matthews,

I suspect your issue is that your metadata file only has one column other than the sampleID which you are reading in as the row.names. I would double check two things.

  1. Make sure that when you read in the file the variable is read in as a data.frame. Often times R will turn files with only one column into a vector. You can prevent this using
metadata <- as.data.frame(metadata)
  1. Once this is done I would also double check to make sure the rowNames of the data.frame match the expected input and match up with your taxonomic abundance table.

Cheers,
Jacob Nearing

Hi Jacob -

Thanks for your quick reply!

Both the metadata object and the taxonomic abundance table are read in as a data.frame (I added a few more columns from my actual metadata file for reproducibility and attached here).

metadata_subset.csv (1.1 KB)

Also, the rowNames of both of these data.frames match up. I also tried putting the row.names in the exact same order within both data.frames, but that made no difference (order of the sample.id’s didn’t matter in the previous version I used, but I wanted to double check).


Previously, I had no issues with this first way of importing my data using v. 1.10.1… now Maaslin does not run with this way of importing data and throws this error.

Error in Maaslin2(input_data = df, input_metadata = metadata, output = "fit_data_cplm_none_category", : If supplying input_data as a data frame, it must have appropriate rownames!

# 1. Load metadata ####
> metadata <- read.csv(file = "metadata_subset.csv", sep = ",", header= TRUE)

> str(metadata)
'data.frame':	48 obs. of  4 variables:
 $ sample.id     : chr  "PM01" "PF01" "PM02" "PF02" ...
 $ category_broad: chr  "mites" "feather" "mites" "feather" ...
 $ bird_sex      : chr  "Male" "Male" "Male" "Male" ...
 $ bird_age      : chr  "ASY" "ASY" "ASY" "ASY" ...

> # 2. Load Data ####

> df <- read.csv(file = "OTU_FUNguild_subset.csv", sep = ",", header= TRUE)

> str(df)
'data.frame':	48 obs. of  46 variables:
 $ SampleID                         : chr  "PF01" "PF02" "PF04" "PF05" ...
 $ X6e5c88724ce4ad5457ab9e3e47170818: num  NA 0 0 0 0 NA NA 0 NA NA ...
 $ X2a57bb2d180f703fc42c5c6a09daeb2c: num  NA 0 0 0 0 NA NA 0 NA NA ...
 $ a91aab690b10d15fa4bb3f92f4bcb1bb : num  NA 0 0 0 0 NA NA 0 NA NA ...
[[truncated]]

But then with this way from the tutorial (I’m not sure if this import step was updated since v. 1.10.1), if I load with row.names = 1, stringsAsFactors = FALSE… it starts to run… but then gets stuck on this error:

Error in rownames<-(x, value) : attempt to set 'rownames' on an object with no dimensions

> # 1. Load metadata ####
> metadata <- read.csv(file = "metadata_subset.csv", sep = ",", header= TRUE, row.names = 1, stringsAsFactors = FALSE)

> str(metadata)
'data.frame':	48 obs. of  3 variables:
 $ category_broad: chr  "mites" "feather" "mites" "feather" ...
 $ bird_sex      : chr  "Male" "Male" "Male" "Male" ...
 $ bird_age      : chr  "ASY" "ASY" "ASY" "ASY" ...

> # 2. Load Data ####
> df <- read.csv(file = "OTU_FUNguild_subset.csv", sep = ",", header= TRUE, row.names = 1, stringsAsFactors = FALSE)

> str(df)
'data.frame':	48 obs. of  45 variables:
 $ X6e5c88724ce4ad5457ab9e3e47170818: num  NA 0 0 0 0 NA NA 0 NA NA ...
 $ X2a57bb2d180f703fc42c5c6a09daeb2c: num  NA 0 0 0 0 NA NA 0 NA NA ...
 $ a91aab690b10d15fa4bb3f92f4bcb1bb : num  NA 0 0 0 0 NA NA 0 NA NA ...
[[truncated]]

Any other ideas of what the issue could be? Thank you again!

Hi @nearinj again!

I think I figured out the issue trying again on another set of data that I know worked with v. 1.10.1… it seems like the row.names = 1, stringsAsFactors = FALSE is required with v. 1.14.1 to satisfy the row.names parameter. When I did not include these arguments, I got the first appropriate rownames! error. When I included them, the model ran normally.

This subsequent error ( Error in rownames<-(x, value) : attempt to set 'rownames' on an object with no dimensions) with my current taxonomic abundance table is (I think) trying to tell me that all of my features have been filtered out and none are left to run the model with! There are 45 features and my .log file says, Total filtered features: 45 and I also see that
the Min samples required with min abundance for a feature not to be filtered: 4.800000 and I do not have >4.8 samples associated with any feature…

This taxonomic table is really sparse so I took a closer look at it and it turns out that the fixed effect I am interested in (category_broad) has completely unique features with no overlap within each group… so I guess that makes sense why there would be nothing to compare!

Thank you for your help troubleshooting and hopefully this discussion can also help someone in the future!

Hi @Alix_Matthews ,

Great to hear you were able to resolve the error!

Cheers,
Jacob Nearing