Giter Site home page Giter Site logo

microsud / microbiomeutilities Goto Github PK

View Code? Open in Web Editor NEW
32.0 5.0 7.0 40.99 MB

The is mostly a wrapper tool using phyloseq and microbiome R packages.

Home Page: https://microsud.github.io/microbiomeutilities/

License: Other

R 99.73% Shell 0.27%
microbiome microbiome-analysis microbial-communities metagenomics amplicon sequencing 16s core-microbiome qc-pipeline

microbiomeutilities's People

Contributors

microsud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

microbiomeutilities's Issues

Error with plot_taxa_cv()

Hello,

Thanks for a great package! I am running into this error when attempting to run plot_taxa_cv() on my phyloseq object:

Here is my phyloseq information:
> merged_phyloseq_80 phyloseq-class experiment-level object otu_table() OTU Table: [ 32450 taxa and 69 samples ] sample_data() Sample Data: [ 69 samples by 10 sample variables ] tax_table() Taxonomy Table: [ 32450 taxa by 9 taxonomic ranks ]

Here is the error:
> p1 <- plot_taxa_cv(merged_phyloseq_80, plot.type = "scatter") Error: Problem with mutate()inputMeanAbun. x Input MeanAbuncan't be recycled to size 32450. ℹ InputMeanAbunisx.mean.rel. ℹ Input MeanAbun must be size 32450 or 1, not 69.

Here is the error in more detail:
├─<error/dplyr:::mutate_error> │ Problem with mutate()inputMeanAbun. │ x Input MeanAbuncan't be recycled to size 32450. │ ℹ InputMeanAbunisx.mean.rel. │ ℹ Input MeanAbun` must be size 32450 or 1, not 69.
└─<error/dplyr:::mutate_incompatible_size>
Backtrace:

  1. ├─microbiomeutilities::plot_taxa_cv(merged_phyloseq_80, plot.type = "scatter")
  2. │ └─%>%(...)
  3. ├─dplyr::mutate(., MeanAbun = x.mean.rel, CV = x.cvs)
  4. ├─dplyr:::mutate.data.frame(., MeanAbun = x.mean.rel, CV = x.cvs)
  5. │ └─dplyr:::mutate_cols(.data, ...)
  6. │ ├─base::withCallingHandlers(...)
  7. │ └─mask$eval_all_mutate(quo)
  8. └─dplyr:::abort_glue(character(0), list(x_size = 69L), "dplyr:::mutate_incompatible_size")
  9. └─rlang::exec(abort, class = class, !!!data)`

Please let me know if there is something wrong with my phyloseq object that is causing this error - I'm not sure I am catching it if that's the case. The example with the zackular2014 works fine.

error with plot_taxa_heatmap

Hello! I'm fairly new to your package, apologies if this issue is a syntax thing on my end. I'm trying to create a heatmap of a bacterial community dataset, but have run into an error. Here's my code and the error that I run into:

bact.heat <- plot_taxa_heatmap(top50.phy, subset.top = NA,
VariableA=c("tissue_type","field"),
heatcolors = grad_ab_pal,
transformation = "log10",
cluster_rows = T,
cluster_cols = T,
show_colnames = F,
annotation_colors=meta_colors)

Top NA OTUs selected
Error in seq_len(n) : argument must be coercible to non-negative integer

For context, I subsetted my phyloseq object to show the top 50 ASVs/OTUs before using this function to deal with a separate error. My thinking was that since some of my OTUs have very low abundances, the log10 transformation was producing negative values. However, I get the same error when I use "compositional" and "NA" for the transformation argument. This phyloseq object is transformed to relative abundances, but I also ran into this error using raw read counts. Any suggestions on how to troubleshoot?

Thanks,
Gillian

Error in `check_aesthetics()`: ! plot_ordination_utils

I am trying with my own phyloseq object (that works with plot_ordination) but when I try 👍

nmordinationbray = ordinate(ps_aa, method="NMDS", distance = "bray") plot_ordination_utils(ps_aa, nmordinationbray, color = "group", plot.arrow = TRUE, scale.arrow = NULL, top.taxa = 5)

I receive:

Error in check_aesthetics(): ! Aesthetics must be either length 1 or the same as the data (1): xend and yend Run rlang::last_error() to see where the error occurred.

Problem to load

Hi there,

I installed microbiomeutilities on our Rocky Linux 9 system, with R version 4.3.2.
I did not get any ERROR but only warinigs:

`> devtools::install_github("microsud/microbiomeutilities",force=T)
Downloading GitHub repo microsud/microbiomeutilities@HEAD
Skipping 3 packages not available: Biostrings, microbiome, phyloseq
── R CMD build ───────────────────────────────────────────────────────────────────────────────────────────────
✔ checking for file ‘/tmp/Rtmp89BVzJ/remotes63a264c7e39b/microsud-microbiomeutilities-046a9f9/DESCRIPTION’ ...
─ preparing ‘microbiomeutilities’:
✔ checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘microbiomeutilities_1.00.17.tar.gz’

Installing package into ‘/home/silviat/R/x86_64-redhat-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)

  • installing source package ‘microbiomeutilities’ ...
    ** using staged installation
    ** R
    ** data
    *** moving datasets to lazyload DB
    ** inst
    ** byte-compile and prepare package for lazy loading
    Warning: replacing previous import ‘ggplot2::alpha’ by ‘microbiome::alpha’ when loading ‘microbiomeutilities’
    ** help
    *** installing help indices
    converting help for package ‘microbiomeutilities’
    finding HTML links ... done
    add_refseq html
    finding level-2 HTML links ... done

    aggregate_top_taxa2 html
    dominant_taxa html
    find_samples_taxa html
    format_to_besthit html
    get_group_abundances html
    get_microbiome_data html
    get_tibble html
    hmp2 html
    join_otu_tax html
    list_microbiome_data html
    make_pairs html
    peak-methods html
    percent_classified html
    phy_to_ldf html
    plasticity html
    plot_abund_prev html
    plot_alpha_diversities html
    plot_alpha_rcurve html
    plot_area html
    plot_diversity_stats html
    plot_listed_taxa html
    plot_ordination_utils html
    plot_ordiplot_core html
    plot_paired_abundances html
    plot_read_distribution html
    plot_select_taxa html
    plot_spaghetti html
    plot_taxa_boxplot html
    plot_taxa_composition html
    plot_taxa_cv html
    plot_taxa_heatmap html
    prep_tern_otu html
    prep_ternary html
    print_ps html
    rarefy_util html
    simple_heatmap html
    taxa_distribution html
    taxa_pooler_mcola html
    taxa_summary html
    theme_biome_utils html
    zackular2014 html
    ** building package indices
    ** installing vignettes
    ** testing if installed package can be loaded from temporary location
    Warning: replacing previous import ‘ggplot2::alpha’ by ‘microbiome::alpha’ when loading ‘microbiomeutilities’
    ** testing if installed package can be loaded from final location
    Warning: replacing previous import ‘ggplot2::alpha’ by ‘microbiome::alpha’ when loading ‘microbiomeutilities’
    ** testing if installed package keeps a record of temporary installation path

  • DONE (microbiomeutilities)`

But if I then load the package:
library("microbiomeutilities")
I get:

library("microbiomeutilities")
Error: package or namespace load failed for ‘microbiomeutilities’:
(converted from warning) replacing previous import ‘ggplot2::alpha’ by ‘microbiome::alpha’ when loading ‘microbiomeutilities’

What could be the problem??
Thanks

heatmap

hello, I would like to ask your help if possible.
I used the microbiomeutilities to generate a heatmap from my biom file and I go the species of my otu.
is there isn't any other way to specify which taxa-level to plot as heat map?.
also is possible to omit the prevalence function?
thank you for your help.
I attached the map I generated.

rlang::last_error()

pn_phylum <- plot_taxa_boxplot(phy,

  •                     taxonomic.level = "Phylum",
    
  •                     top.otu = 10, group = "treatment",
    
  •                     title = "Rel plot", group.colors = "Set2")
    

The phy_tree slot is empty, easy to make the plot
错误: More than one expression parsed
Run rlang::last_error() to see where the error occurred.

A

A

White grid in plot_taxa_heatmap

Hi,

I can't seem to figure out why but when using the plot_taxa_heatmap function, it always returns a heatmap with each cell separated by a small white border. I guess there is some setting which can be passed to pheatmap to alter this behaviour but I can't find out which. Do you have any idea? I attached an example of the output.
Rplot

Relative abundance plot for selected taxa

i tried to use code from microbiomeutilites package to make a relative abundance plot for selected taxa across different groups but the code doesn't work , even i tried to rerun your code using your example data
E

workflowr

You make like to have a look at the recently released workflowr package.

Unable to install microbiome utilities

Hi,

I am getting the following error when trying to install. Can you kindly help in sintalling the package.

Thanks
Yugandhar

devtools::install_github("microsud/microbiomeutilities")
Error in utils::download.file(url, path, method = download_method(), quiet = quiet, :
cannot open destfile 'C:\Users\YUGAND1.S1\AppData\Local\Temp\RtmpEnHf9c\filef304bc37608', reason 'No such file or directory'
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning message:
In gzfile(file, mode) :
cannot open compressed file 'C:\Users\YUGAND
1.S1\AppData\Local\Temp\RtmpEnHf9c/libloc_208_89adf02.rds', probable reason 'No such file or directory'

Taxonomic levels should be either 6 (untill genus) or 7 (until species) level

Hello,

I'm working with 16S data, and have an additional domain column in my tax_table of my phyloseq object. Is there any way I can still make boxplots for specific taxa using your package?

My phyloseq object info:
phyloseq-class experiment-level object
otu_table() OTU Table: [ 15 taxa and 14 samples ]
sample_data() Sample Data: [ 14 samples by 19 sample variables ]
tax_table() Taxonomy Table: [ 15 taxa by 8 taxonomic ranks ]

And specific code I'm trying to use:
p0 <- phy_prune_pa_exp_noChloro_noMito_f__OM190
p0.f <- format_to_besthit(p0)
select.taxa <- c("f__OM190")
mycols <- c("brown3", "steelblue")
p <- plot_listed_taxa(p0, select.taxa, group = "treatment", add.violin = TRUE, group.colors = mycols )

Unable to change levels of group variable in plot_paired_abundances

Hi!
I want to plot_paired_abundances, and are successfully able. However, i would like to change the levels of the group (currently they are post-pre, want it to be pre-post). When I do with this code:
sample_data(p_kombucha_agg)$pre_post <- factor(sample_data(p_kombucha_agg)$pre_post, levels=c('pre', 'post'))
it changes from being a character to a factor. Then running the code I get the following error message (which seem unrelated to the actual problem).

_Error in filter():
! Problem while computing ..1 = group == unique(xmeta_lf_2$group)[1].
✖ Input ..1 must be of size 6 or 1, not size 0.
ℹ The error occurred in group 1: taxa = "d__Bacteria;p__Firmicutes;c__Bacilli;o__Bacillales_B;f__Bacillaceae_C;g__Weizmannia", linevar = 2003.
Backtrace:

  1. microbiomeutilities::plot_paired_abundances(...)
  2. dplyr:::filter.data.frame(., group == unique(xmeta_lf_2$group)[1])_

My question; how can I change the levels of my group variable?
Thanks for a great package!!

Phy_tree not included in the result of format_to_besthit

Is there a way to include the phy_tree in the phyloseq object after using the format_to_besthit function? Ive been following this commands and I need to measure the unifrac distances based on the phylogenetic tree but after using the format_to_besthit, it turns out the phy_tree was not included.

ps2 <- tax_glom(ps, "genus")
ps2f <- format_to_besthit(ps)
orddi <- ordinate(ps2f, method = "PCoA", distance = "unifrac", weighted= FALSE)
Error in access(physeq, "phy_tree", errorIfNULL) :
phy_tree slot is empty.

plot_taxa_barplot -

Hi! I am using the function plot_taxa_barplot and got a question; the input data is as counts, but on the y-axis of the plot it says "relative abundance %". My output shows that I got several at 100% and of that I am surprised. Should I transform my data prior input? THis only applies to genus level data, not e.g phylum level.

image

Thanks!

format_to_besthit edit

Hello! Thank you for this package it has been really helpful.

I was trying to use the format_to_besthit to add arrows to my ordination plot. My tax table includes the string of bases instead of a name, so that complicates seeing the actual bacteria genus on the graph. I tried exporting the mds an deleting the string, re uploading and putting it into the phyloseq object/ordination with errors.
Thanks!

Code with ps2f taxtable and orddi edits

ps1 <- ps_shrimp
ps2 <- tax_glom(ps1, "Genus")
ps2f <- format_to_besthit(ps2, prefix="OTU-")
orddi <- ordinate(ps2f, method = "NMDS", distance = "bray")

alltaxa <- ps2f@tax_table
alltaxa <- as.list.data.frame(alltaxa)
rownamesalltaxa <- rownames(alltaxa)
write.csv(alltaxa,"Miseq2/alltaxa.csv", row.names = FALSE)

=TRIM(RIGHT(G2, LEN(G2) - SEARCH(":", G2)))
alltaxa <- as.matrix(alltaxa)

write.csv(rownamesalltaxa,"Miseq2/rownamesalltaxa.csv", row.names = FALSE)
rownamesalltaxa <- as.data.frame(rownamesalltaxa)

change names in excel using =TRIM(RIGHT(A2, LEN(A2) - SEARCH(":", A2))) and re upload
rownames(alltaxa) <- rownamesalltaxa$X1 *rename alltaxa rows with the edited cut off
alltaxa <- tax_table(alltaxa)

species <- orddi$species
species_genus <- rownames(species)
write.csv(species,"Miseq2/species_genus.csv", row.names = FALSE)

change names in excel using =TRIM(RIGHT(A2, LEN(A2) - SEARCH(":", A2))) and re upload

ps2f@tax_table <- alltaxa
rownames(species) <- species_genus$X1
orddi$species <- species

p <- plot_ordination_utils(ps2f, orddi,
color = "Neotrypaea", plot.arrow = TRUE,
scale.arrow = 1.3, top.taxa = 10
)

}

p

Error if I try to create a tax table with edited rownames:

rownames(alltaxa) <- rownamesalltaxa$x #rename alltaxa rows with the edited cut off
Warning: Setting row names on a tibble is deprecated.
Warning: non-unique values when setting 'row.names': ‘endosymbionts’, ‘Incertae Sedis’
Error in .rowNamesDF<-(x, value = value) :
duplicate 'row.names' are not allowed

Error if I edit best_hit in the tax table + species in orddi:

p <- plot_ordination_utils(ps2f, orddi,
color = "Neotrypaea", plot.arrow = TRUE,
scale.arrow = 1.3, top.taxa = 10
)
Species coordinates not found directly in ordination object. Attempting weighted average (vegan::wascores)

Main Issue: Labels!

image

plot_taxa_boxplot error

when attempting to plot_taxa_boxplot I get the following error.
image
I don't get the error when using the test data phyloseq object. there are some data type differences between my phyloseq object and the test data object but I'm not sure what would cause the error.

my phyloseq object
image

zackular phyloseq object
image

Plot_spaghetti - same results each result-cell. Idea about why?

Hi! I would like to "plot_spaghetti", but I am getting results assume to be wrong as they are the same for all subjects. Do you have any idea about why that is?

plot_spaghetti(physeq_RA_aggregated, plot.var= "by_sample",
               select.taxa=tax,
               group= "host_study_id",
               xvar="time",
               line.bg.color="#8d99ae",
               focus.color="brown3",
               focus.line.size = 1,
               ncol=5,
               nrow=6,
               line.size=0.2)

image

Thanks, Maria

double genus name in heatmap

hello,
I generate the heatmap using the following code:

library(microbiomeutilities)
library(microbiome)
library(knitr)
library(tibble)
library(dplyr)
library(pheatmap)
library(RColorBrewer)
ps <-phyloseq
tax_tb <- as(tax_table(ps),"matrix") %>% 
  as.data.frame() %>% 
  rownames_to_column("ASV") %>% 
  mutate(Genus.Species = ifelse(!is.na(Species), paste0(Genus, ".", Species), Species)) %>% 
  select(-Species)   %>% 
  rename(Species = Genus.Species)

#tax_tb[1:30, 5:9]
rownames(tax_tb) <- tax_tb$ASV
tax_tb <- tax_tb[,-1]

tax_table(ps) <- tax_table(as.matrix(tax_tb))

ps.genus <- aggregate_taxa(ps, "Genus")
display.brewer.all()
grad_ab <- brewer.pal(11, "Spectral")
grad_ab_pal <- grad_ab 
gray_grad <- colorRampPalette(c("white", "steelblue"))
gray_grad_cols <- gray_grad(10)
meta_colors <- list(c("winter" = "#8dd3c7", 
                      "spring" = "#fb8072", 
                      "summer"="#b3de69",
                      "autumn"="#fbb4ae"))
names(meta_colors) <- c("season")
p <- plot_taxa_heatmap(ps.genus,
                       subset.top = 30,
                       VariableA = c("season"),
                       heatcolors = grad_ab_pal, 
                       transformation = "clr",
                       cluster_rows = T,
                       cluster_cols = T,
                       show_colnames = T,
                       annotation_colors=meta_colors)

however, the column names are double instead of single name:
Rplot42
how to correct the code to have only a single name?
the taxa table is as follow:
image

thank you.

get_group_abundances group argument without NULL as default

Hi, when running get_group_abundances, the default of "group" is NULL as stated in the documentation. However, if this argument was left missing, an error of argument "group" is missing, with no default could be seen. Is it a bug with the package?

Thank you!

Update readme and website

Suggest one citation for both microbiome and microbiomeutilities as a part of the microbiome-verse idea?
Link pkg website with main page for microbiome
@antagomir thoughts?

Taxonomic_Levels Percent_Classification

Hi,
I am trying to identify my dataset taxonomic resolution using microbiomeutilities package. I found a small problem in calculation. The domain and Phylum percent classification should be 100% in my dataset. But I get the following.

##upload required libraries
library(phyloseq)
library(file2meco)
library(microbiomeutilities)
library(ggplot2)

#taxonomy resolution calculation
percent_classified(pseq)

##output
Taxonomic_Levels Percent_Classification
1 Domain 99.9998 %
2 Phylum 99.9998 %
3 Class 99.9442 %
4 Order 99.7169 %
5 Family 98.2093 %
6 Genus 94.0961 %
7 Species 59.1211 %
8 OTUs/ASVs 438997

Could you kindly provide me the reason or any correction needed? I have attached my dataset for your reference.
physeq.rds.zip

Problem to install

Hi,
how can I download a zip file of microbiomeutilities 1.00.15 for manually installation?
I used devtools::install_github("microsud/microbiomeutilities")
but it failed saying "~/microbiomeutilities_1.00.16.tar.gz’ had non-zero exit status".
Thank you.
Fuad

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.