Skip to contents
library(MiscMetabar)
#> Warning: replacing previous import 'S4Arrays::makeNindexFromArrayViewport' by
#> 'DelayedArray::makeNindexFromArrayViewport' when loading 'SummarizedExperiment'
library(formattable)
data(data_fungi)
data(data_fungi_sp_known)

Export phyloseq object

You can export a phyloseq object to csv (and txt for phylogenetic tree) files in a folder. It is possible to export each table into one file or to merge all slot (except phytree) in one file (args one_file = TRUE). Finally, if rdata is set to TRUE, a rdata file containing the phyloseq object is also writed.

write_pq(data_fungi, path = "fungi_phyloseq")
write_pq(data_fungi, path = "fungi_phyloseq", one_file = TRUE)
write_pq(data_fungi, path = "fungi_phyloseq", rdata = TRUE)

Finally, you can use the function save_pq() to write the phyloseq object in all 3 versions (one table for each slot, a file merging each slot and an Rdata file).

save_pq(data_fungi)

Import

To import a Rdata file, just use load() base function. In order to import phyloseq object from a folder create using write_pq() or save_pq(), please use the function read_pq().

d <- read_pq(path = "fungi_phyloseq")

Tracking sequences, clusters and samples

In bioinformatic pipeline, we often need to track the number of samples, sequences and clusters across step in the pipeline. MiscMetabar propose two utilities to achieve this goal : track_wkflow() and a version to compute value per samples : track_wkflow_samples(). The function track_wkflow() can deal with (i) fastq and fastg.gz files, dada-class object, derep-class object, matrix of samples x clusters (e.g. otu_table) and phyloseq-class object.

track_wkflow(list(data_fungi, data_fungi_sp_known))
#>   nb_sequences nb_clusters nb_samples
#> 1      1839124        1420        185
#> 2      1106581         651        185

Session information

sessionInfo()
#> R version 4.3.2 (2023-10-31)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 22.04.3 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0
#> 
#> locale:
#>  [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
#>  [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
#>  [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
#> [10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
#> 
#> time zone: UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] formattable_0.2.1 MiscMetabar_0.7.8 dplyr_1.1.4       dada2_1.30.0     
#> [5] Rcpp_1.0.12       ggplot2_3.4.4     phyloseq_1.46.0  
#> 
#> loaded via a namespace (and not attached):
#>   [1] bitops_1.0-7                pbapply_1.7-2              
#>   [3] deldir_2.0-2                permute_0.9-7              
#>   [5] rlang_1.1.3                 magrittr_2.0.3             
#>   [7] ade4_1.7-22                 matrixStats_1.2.0          
#>   [9] compiler_4.3.2              mgcv_1.9-0                 
#>  [11] png_0.1-8                   systemfonts_1.0.5          
#>  [13] vctrs_0.6.5                 reshape2_1.4.4             
#>  [15] stringr_1.5.1               pkgconfig_2.0.3            
#>  [17] crayon_1.5.2                fastmap_1.1.1              
#>  [19] XVector_0.42.0              utf8_1.2.4                 
#>  [21] Rsamtools_2.18.0            rmarkdown_2.25             
#>  [23] ragg_1.2.7                  purrr_1.0.2                
#>  [25] xfun_0.42                   zlibbioc_1.48.0            
#>  [27] cachem_1.0.8                GenomeInfoDb_1.38.6        
#>  [29] jsonlite_1.8.8              biomformat_1.30.0          
#>  [31] rhdf5filters_1.14.1         DelayedArray_0.28.0        
#>  [33] Rhdf5lib_1.24.2             BiocParallel_1.36.0        
#>  [35] jpeg_0.1-10                 parallel_4.3.2             
#>  [37] cluster_2.1.4               R6_2.5.1                   
#>  [39] bslib_0.6.1                 stringi_1.8.3              
#>  [41] RColorBrewer_1.1-3          GenomicRanges_1.54.1       
#>  [43] jquerylib_0.1.4             SummarizedExperiment_1.32.0
#>  [45] iterators_1.0.14            knitr_1.45                 
#>  [47] IRanges_2.36.0              Matrix_1.6-1.1             
#>  [49] splines_4.3.2               igraph_2.0.1.1             
#>  [51] tidyselect_1.2.0            abind_1.4-5                
#>  [53] yaml_2.3.8                  vegan_2.6-4                
#>  [55] codetools_0.2-19            hwriter_1.3.2.1            
#>  [57] lattice_0.21-9              tibble_3.2.1               
#>  [59] plyr_1.8.9                  Biobase_2.62.0             
#>  [61] withr_3.0.0                 ShortRead_1.60.0           
#>  [63] evaluate_0.23               desc_1.4.3                 
#>  [65] survival_3.5-7              RcppParallel_5.1.7         
#>  [67] Biostrings_2.70.2           pillar_1.9.0               
#>  [69] MatrixGenerics_1.14.0       foreach_1.5.2              
#>  [71] stats4_4.3.2                generics_0.1.3             
#>  [73] RCurl_1.98-1.14             S4Vectors_0.40.2           
#>  [75] munsell_0.5.0               scales_1.3.0               
#>  [77] glue_1.7.0                  tools_4.3.2                
#>  [79] interp_1.1-6                data.table_1.15.0          
#>  [81] GenomicAlignments_1.38.2    fs_1.6.3                   
#>  [83] rhdf5_2.46.1                grid_4.3.2                 
#>  [85] ape_5.7-1                   latticeExtra_0.6-30        
#>  [87] colorspace_2.1-0            nlme_3.1-163               
#>  [89] GenomeInfoDbData_1.2.11     cli_3.6.2                  
#>  [91] textshaping_0.3.7           fansi_1.0.6                
#>  [93] S4Arrays_1.2.0              gtable_0.3.4               
#>  [95] sass_0.4.8                  digest_0.6.34              
#>  [97] BiocGenerics_0.48.1         SparseArray_1.2.4          
#>  [99] htmlwidgets_1.6.4           memoise_2.0.1              
#> [101] htmltools_0.5.7             pkgdown_2.0.7              
#> [103] multtest_2.58.0             lifecycle_1.0.4            
#> [105] MASS_7.3-60