LebeerLab / tidytacos

Functions to manipulate and visualize microbial community data
https://lebeerlab.github.io/tidytacos/
GNU General Public License v3.0
9 stars 1 forks source link

[BUG] Sample clustering fails when "sample_name" columns exists #19

Closed SWittouck closed 9 months ago

SWittouck commented 9 months ago

When a column called "sample_name" is present in the sample table, plotting a stack plot fails (produces a single stack called "NA" instead of one per sample).

Code that produces the error (tidytacos v1.0.0, R v4.3.2):

library(tidyverse)
library(tidytacos)

# read data
data <- read_rds("tacoplot_bug.rds")

# this fails (only one stack called "NA")
data %>% tacoplot_stack() 

# this fixes the problem! 
data$samples$sample_name <- NULL
data %>% tacoplot_stack() 

I'm pretty sure it has to do with one of the counts_matrix function (or a similar one) using the "sample_name" column as rownames for the count matrix instead of the "sample_id" column.

The dataset: tacoplot_bug.zip

TheOafidian commented 9 months ago

https://github.com/LebeerLab/tidytacos/blob/65697f8027a02fe91694716607112c4b13450159/R/getters.R#L343 problem lies here, I'll fix it on monday!