# Undefined columns error in MaAsLin2

**URL:** <https://forum.biobakery.org/t/undefined-columns-error-in-maaslin2/1182>\
**Category:** MaAsLin\
**Created:** [October 22, 2020, 5:50pm UTC](https://forum.biobakery.org/t/undefined-columns-error-in-maaslin2/1182 "2020-10-22T17:50:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackckoch](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/jackckoch/32/442_2.png) [@jackckoch](https://forum.biobakery.org/u/jackckoch)\
**Post date:** [October 22, 2020, 5:50pm UTC](https://forum.biobakery.org/t/undefined-columns-error-in-maaslin2/1182/1 "2020-10-22T17:50:32Z")

</div>

I am trying to run MaAsLin2 on my metagenomics data, but have run into the following errors:

1. Error in `[.data.frame`(input\_df\_all, c(x\_label, y\_label)) : undefined columns selected
2. 1: In max(nchar(x\_axis\_labels), na.rm = TRUE) : no non-missing arguments to max; returning -Inf

I have attached my metadata and abundance files. Any ideas what might be going on or how to fix this error?

The code that I am running (R version 3.6.2):

```
#BiocManager::version() #3.10
library(tidyverse)
library(Maaslin2) 
library(data.table)
library(vegan)
library(broom)
rm(list=ls())
getwd() #lists current working directory
setwd("~/Desktop")
dir.create("R_Maaslin")
setwd("R_Maaslin")
getwd()

data <- "humann_filtered_genefamilies_cpm_gofeatures.tsv"
df_input_data = read_tsv(data)
df_input_data <- df_input_data[-c(11,39),] #removed unknown samples
map <- "maptranspose3.txt"
map <- read_tsv(map)
map <- map[-c(11,39),] #removed unknown samples
fit_data3=Maaslin2(
  input_data = df_input_data,
  input_metadata = map,
  output = "sym_output",
  fixed_effects = c("ph","Sym")
)

```

[humann\_filtered\_genefamilies\_cpm\_gofeatures.tsv](https://forum.biobakery.org/uploads/short-url/s01Rg1tcYFLuSGxq5bdH3TbQgUP.tsv) (1.3 MB) [maptranspose3.txt](https://forum.biobakery.org/uploads/short-url/jhhVvy41iApsFtAant5vg91yzTP.txt) (2.2 KB)

---

<div class="post-metadata">

**Author:** ![Kelsey\_Thompson](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/kelsey_thompson/32/65_2.png) [@Kelsey\_Thompson](https://forum.biobakery.org/u/Kelsey_Thompson)\
**Post date:** [October 26, 2020, 5:37pm UTC](https://forum.biobakery.org/t/undefined-columns-error-in-maaslin2/1182/2 "2020-10-26T17:37:25Z")

</div>

Hi!

This error is often the result of special characters in the feature table (gene families). If you remove those you should have no issues running. Doing something as simple as transposing the dataframe in R without the check.names = F call, will allow you to quickly check if that is the issue.

We are aware of this issue and have added a fix to our list of improvements, but hopefully the above suggestion is a quick fix.

Let me know if you keep experiencing issues!

Best,  
Kelsey

---

<div class="post-metadata">

**Author:** ![jackckoch](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/jackckoch/32/442_2.png) [@jackckoch](https://forum.biobakery.org/u/jackckoch)\
**Post date:** [October 30, 2020, 11:23pm UTC](https://forum.biobakery.org/t/undefined-columns-error-in-maaslin2/1182/3 "2020-10-30T23:23:46Z")

</div>

Hi Kelsey,

Thanks for you reply. I tried transposing my file, but am unsure what to look for in the output.

Here is the code I ran:  
data \<- “humann\_filtered\_genefamilies\_cpm\_gofeatures.tsv”  
df\_input\_data = read\_tsv(data)  
specchar \<- transpose(df\_input\_data)

Specchar is listed as a Large list in R with each sample as an element.

---

<div class="post-metadata">

**Author:** ![Kelsey\_Thompson](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/kelsey_thompson/32/65_2.png) [@Kelsey\_Thompson](https://forum.biobakery.org/u/Kelsey_Thompson)\
**Post date:** [November 5, 2020, 5:12pm UTC](https://forum.biobakery.org/t/undefined-columns-error-in-maaslin2/1182/4 "2020-11-05T17:12:57Z")

</div>

Hi!

Can you make the Specchar object a data.frame? So changing the Specchar command to specchar = data.frame(t(df\_input\_data)). Then you will probably have to flip it back so that the specchar object matches the metadata you are comparing it to.

I hope this helps!

---

<div class="post-metadata">

**Author:** ![jackckoch](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/jackckoch/32/442_2.png) [@jackckoch](https://forum.biobakery.org/u/jackckoch)\
**Post date:** [November 10, 2020, 1:15am UTC](https://forum.biobakery.org/t/undefined-columns-error-in-maaslin2/1182/5 "2020-11-10T01:15:21Z")

</div>

Hi Kelsey,

I will try this out!

I did get things working by replacing all potential special characters with underscores. On to the next issue.

Thanks,  
Jack

---

<div class="post-metadata">

**Author:** ![Kelsey\_Thompson](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/kelsey_thompson/32/65_2.png) [@Kelsey\_Thompson](https://forum.biobakery.org/u/Kelsey_Thompson)\
**Post date:** [November 11, 2020, 1:20pm UTC](https://forum.biobakery.org/t/undefined-columns-error-in-maaslin2/1182/6 "2020-11-11T13:20:18Z")

</div>

Hi Jack,

Great! Yes it was definitely an issue with special characters. Apologies if I confused you with my hacky fix. Glad that you were able to find a work around. I have downloaded your above data so that I can look into the issue you are having in your next post.

Best,  
Kelsey
