yiluheihei / microbiomeMarker

R package for microbiome biomarker discovery
https://yiluheihei.github.io/microbiomeMarker
GNU General Public License v3.0
169 stars 40 forks source link

Error when trying to write as a CSV the marker_table #116

Open mdtorohernando opened 3 months ago

mdtorohernando commented 3 months ago

Hi! I was using microbiomeMarker for a long time, but I've recently update the package and I find a problem.

I usually make the analysis in this way...

mm_lefse_Phylum <- run_lefse(
  ps, 
  norm = "CPM",
  taxa_rank = "Phylum",
  wilcoxon_cutoff = 0.05, 
  group = "Group", 
  kw_cutoff = 0.05, 
  multigrp_strat = TRUE, 
  lda_cutoff = 3
)

mm_lefse_Phylum

# microbiomeMarker-class inherited from phyloseq-class
# normalization method:              [ CPM ]
# microbiome marker identity method: [ lefse ]
# marker_table() Marker Table:       [ 1 microbiome markers with 5 variables ]
# otu_table()    OTU Table:          [ 10 taxa and  28 samples ]
# sample_data()  Sample Data:        [ 28 samples by  6 sample variables ]
# tax_table()    Taxonomy Table:     [ 10 taxa by 1 taxonomic ranks ]

marker_table(mm_lefse_Phylum)
write.csv(marker_table(mm_lefse_Phylum), file = 'mm_lefse_Phylum.csv', row.names = F)

pdf("mm_lefse_phylum.pdf")
plot_abundance(mm_lefse_Phylum, group = "Group")
plot_ef_bar(mm_lefse_Phylum)
plot_ef_dot(mm_lefse_Phylum)
dev.off()

So now... all is OK (pdf graphs are OK), but, when I'm trying to write as CSV I find this error:

> write.csv(marker_table(mm_lefse_Phylum), file = 'mm_lefse_Phylum.csv', row.names = F)
Error en validObject(.Object): 
  invalid class “marker_table” object: marker table must have non-zero dimensions

When I visualize the mm_lefse_Phylum it is not empty

> marker_table(mm_lefse_Phylum)
Object of class "marker_table"
               feature enrich_group   ef_lda     pvalue       padj
marker1 Proteobacteria           WT 4.189638 0.02068083 0.02068083

It seems that now marker_table is not treated as a data frame... I really don't know what to do, as I've tried to convert into a data frame but it seems not to work.

Thanks!

María

mdtorohernando commented 3 months ago

sorry, my version of microbiomeMarker is v1.10.0