MicrobiomeStat icon indicating copy to clipboard operation
MicrobiomeStat copied to clipboard

Error in midpoint(data.obj$tree) : could not find function "midpoint"

Open nutrimol opened this issue 1 month ago • 2 comments

Dear developer,

Congratulations for this great tool. I have a problem while trying to convert my phyloseq object to microbiomeStat object. It seems it does not found midpoint function.

I installed all the dependencies following the installation guide. Then, I execute the code below. Do you have any clue of what is going on here?

Thank you for your time!

library(MicrobiomeStat) library(tidyverse) library(phyloseq)

Required package

library(microbiome) library(ape)

setwd("/Users/virginia/Dropbox/rrr/emu_phyloseq/") # mac

################################################################################

load Phyloseq object

################################################################################ ps <- readRDS(file= "./phylo_obj/ps.rds")

Check if taxa are rows in the Phyloseq object

phyloseq::taxa_are_rows(ps) str(ps)

Convert the Phyloseq object to a MicrobiomeStat data object

data.obj <- mStat_convert_phyloseq_to_data_obj(ps)

output:

``

phyloseq::taxa_are_rows(ps) [1] TRUE str(ps) Formal class 'phyloseq' [package "phyloseq"] with 5 slots ..@ otu_table:Formal class 'otu_table' [package "phyloseq"] with 2 slots .. .. ..@ .Data : num [1:275, 1:24] 0 0 14 0 0 0 0 0 0 0 ... .. .. .. ..- attr(, "dimnames")=List of 2 .. .. .. .. ..$ : chr [1:275] "100176" "1042156" "105841" "106588" ... .. .. .. .. ..$ : chr [1:24] "AC.16" "TC.16" "DC.16" "AC.18" ... .. .. ..@ taxa_are_rows: logi TRUE .. .. ..$ dim : int [1:2] 275 24 .. .. ..$ dimnames:List of 2 .. .. .. ..$ : chr [1:275] "100176" "1042156" "105841" "106588" ... .. .. .. ..$ : chr [1:24] "AC.16" "TC.16" "DC.16" "AC.18" ... ..@ tax_table:Formal class 'taxonomyTable' [package "phyloseq"] with 1 slot .. .. ..@ .Data: chr [1:275, 1:7] "Bacteria" "Bacteria" "Bacteria" "Bacteria" ... .. .. .. ..- attr(, "dimnames")=List of 2 .. .. .. .. ..$ : chr [1:275] "100176" "1042156" "105841" "106588" ... .. .. .. .. ..$ : chr [1:7] "Kingdom" "Phylum" "Class" "Order" ... .. .. ..$ dim : int [1:2] 275 7 .. .. ..$ dimnames:List of 2 .. .. .. ..$ : chr [1:275] "100176" "1042156" "105841" "106588" ... .. .. .. ..$ : chr [1:7] "Kingdom" "Phylum" "Class" "Order" ... ..@ sam_data :'data.frame': 24 obs. of 6 variables: Formal class 'sample_data' [package "phyloseq"] with 4 slots .. .. ..@ .Data :List of 6 .. .. .. ..$ : Factor w/ 3 levels "AC","TC","DC": 1 2 3 1 2 3 1 2 3 1 ... .. .. .. ..$ : num [1:24] 16 16 16 18 18 18 1 1 1 2 ... .. .. .. ..$ : chr [1:24] "AC.16" "TC.16" "DC.16" "AC.18" ... .. .. .. ..$ : Factor w/ 3 levels "stage1","stage2",..: 3 3 3 3 3 3 1 1 1 1 ... .. .. .. ..$ : Factor w/ 2 levels "distal","proximal": 2 1 1 2 1 1 2 1 1 2 ... .. .. .. ..$ : chr [1:24] "1" "2" "3" "4" ... .. .. ..@ names : chr [1:6] "Compartment" "Day" "label" "Stage" ... .. .. ..@ row.names: chr [1:24] "AC.16" "TC.16" "DC.16" "AC.18" ... .. .. ..@ .S3Class : chr "data.frame" ..@ phy_tree :List of 4 .. ..$ edge : int [1:547, 1:2] 276 276 276 277 278 296 298 341 341 298 ... .. ..$ edge.length: num [1:547] 0.0811 0.1241 0.0112 0.0166 0.0134 ... .. ..$ tip.label : chr [1:275] "100176" "1042156" "105841" "106588" ... .. ..$ Nnode : int 273 .. ..- attr(, "class")= chr "phylo" .. ..- attr(, "order")= chr "cladewise" ..@ refseq : NULL

Convert the Phyloseq object to a MicrobiomeStat data object

data.obj <- mStat_convert_phyloseq_to_data_obj(ps) Root the tree by midpointing ... Error in midpoint(data.obj$tree) : could not find function "midpoint" ``

nutrimol avatar May 08 '24 17:05 nutrimol