Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in check_rank_names(ps) : ranks of taxonimic profile must be one of Kingdom, Phylum, Class, Order, Family, Genus, Species #101

Open
KatrinaLutap opened this issue Jun 6, 2023 · 3 comments

Comments

@KatrinaLutap
Copy link

Dear @yiluheihei, thank you for this package.

I had this error message while using the package:
Error in check_rank_names(ps) :
ranks of taxonimic profile must be one of Kingdom, Phylum, Class, Order, Family, Genus, Species

I think it is because my phyloseq object has 8 taxonomic ranks based from my taxonomy database:

rank_names(ps)
[1] "Domain" "Subdomain" "Kingdom" "Phylum" "Subphylum" "Class" "Genus"
[8] "Species"

Does this mean I can not use more than 8 taxonomic ranks and is there a way to go around this?

Thank you.

Best,
Katrina

@Luke-ebbis
Copy link

Hey @KatrinaLutap and @yiluheihei I get the same error with this script. What may help to prevent the error?

#'@title Linear discriminant analysis Effect Size analysis script.
#'@description In this script the LDA effect sizes are investigated for: 


# Prepare the environment ----
library(tidyverse)
library(phyloseq)
library(microbiomeMarker)
library(microViz)
library(readxl)

source("utils/utils.R")


# Reading in the data ----

otu_mat <- read.csv("data/OTU_table_Exp2_24hrs.csv")
tax_mat <- read.csv("data/Taxa_Exp_1_2_Cleaned.csv")
samples_df <- read.csv("data/Metadata_Exp2_24hrs.csv")

# phy <- make_phyloseq(otu_mat, tax_mat, samples_df)

otu_mat <- otu_mat %>%
  tibble::column_to_rownames("asv")
tax_mat <- tax_mat %>%
  tibble::column_to_rownames("asv")
samples_df <- samples_df %>%
  tibble::column_to_rownames("samples")
otu_mat <- as.matrix(otu_mat)
tax_mat <- as.matrix(tax_mat)
OTU <- otu_table(otu_mat, taxa_are_rows = TRUE)
TAX <- tax_table(tax_mat)
samples <- sample_data(samples_df)
phyloseq_object_all <- phyloseq(OTU, TAX, samples)
phyloseq_object_all <- prune_taxa(taxa_sums(phyloseq_object_all) > 0,
                                  phyloseq_object_all)
message("Created the phyloseq object")


lef_out <- run_lefse(phyloseq_object_all,
                     taxa_rank = "none",
                     group = "Treatment", norm = "CPM",
                     kw_cutoff = 0.05, lda_cutoff = 2)
                     

@DebnathSanjit
Copy link

Dear @KatrinaLutap and @Luke-ebbis I'm also having a similar issue with my 18S (microeukaryotes) dataset with 9 taxonomic ranks (Domain, Supergroup, Division, Subdivision, Class, Order, Family, Genus, Species" ). Have you got any solution for this?

@Luke-ebbis
Copy link

Looking at the code, the function check_rank_names checks whether the names of the taxa are all in the variable available_ranks.

if (!all(ps_ranks %in% available_ranks)) {
stop(
"ranks of taxonimic profile must be one of ",
paste(available_ranks, collapse = ", ")
)
}

This global constant is defined here:

# available taxonomic ranks, Summarize represents summarized tax
available_ranks <- c(
"Kingdom", "Phylum", "Class", "Order",
"Family", "Genus", "Species"
)
available_ranks <- factor(
available_ranks,
levels = available_ranks
)
usethis::use_data(available_ranks, internal = TRUE, overwrite = TRUE)

So in my view the one way to deal with this is to

  1. Make sure your taxa names match available_ranks ranks exactly.
  2. Modify the package in some way to allow more classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants