EESI / themetagenomics

Other
23 stars 4 forks source link

Error in picrust_otu(file.path(reference_path, ref_fn, fsep = platform_sep()), : Not compatible with STRSXP: [type=NULL]. #21

Open FSalOrt opened 1 year ago

FSalOrt commented 1 year ago

I have a problem with the picrust analysis, i got the error: Error in picrust_otu(file.path(reference_path, ref_fn, fsep = platform_sep()), : Not compatible with STRSXP: [type=NULL].

[my feature table is from qiime2 and my taxonomy too] my Rscript is the following:

asv_16s = read.table(file = "CSSren-feature-table", sep = "\t",
                     header = TRUE, row.names = 1, skip = 1, comment.char = "")
taxonomy = read.table(file = "taxonomy_fixed16s.tsv", sep = "\t",
                      header = FALSE, row.names = 1)
tax <- taxonomy %>%
  select(Taxon) %>% 
  separate(Taxon, c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species"), ";")
tax.clean <- data.frame(row.names = row.names(tax),
                        Kingdom = str_replace(tax[,1], "k__",""),
                        Phylum = str_replace(tax[,2], "p__",""),
                        Class = str_replace(tax[,3], "c__",""),
                        Order = str_replace(tax[,4], "o__",""),
                        Family = str_replace(tax[,5], "f__",""),
                        Genus = str_replace(tax[,6], "g__",""),
                        Species = str_replace(tax[,7], "s__",""),
                        stringsAsFactors = FALSE)

tax.clean[is.na(tax.clean)] <- ""
tax.clean[tax.clean=="__"] <- ""

for (i in 1:nrow(tax.clean)){
  if (tax.clean[i,7] != ""){
    tax.clean$Species[i] <- paste(tax.clean$Genus[i], tax.clean$Species[i], sep = " ")
  } else if (tax.clean[i,2] == ""){
    kingdom <- paste("Unclassified", tax.clean[i,1], sep = " ")
    tax.clean[i, 2:7] <- kingdom
  } else if (tax.clean[i,3] == ""){
    phylum <- paste("Unclassified", tax.clean[i,2], sep = " ")
    tax.clean[i, 3:7] <- phylum
  } else if (tax.clean[i,4] == ""){
    class <- paste("Unclassified", tax.clean[i,3], sep = " ")
    tax.clean[i, 4:7] <- class
  } else if (tax.clean[i,5] == ""){
    order <- paste("Unclassified", tax.clean[i,4], sep = " ")
    tax.clean[i, 5:7] <- order
  } else if (tax.clean[i,6] == ""){
    family <- paste("Unclassified", tax.clean[i,5], sep = " ")
    tax.clean[i, 6:7] <- family
  } else if (tax.clean[i,7] == ""){
    tax.clean$Species[i] <- paste("Unclassified ",tax.clean$Genus[i], sep = " ")
  }
}

metadata <- read.table(file = "manifest16s.tsv", sep = "\t", 
                       header = T, row.names = 1)

b = as.data.frame(asv_16s)
formula = ~sample

a = prepare_data(otu_table = b, rows_are_taxa = TRUE, metadata = metadata,
                 tax_table = tax.clean, cn_normalize = FALSE)
> h = picrust(otu_table = a$otu_table, rows_are_taxa = TRUE, reference = "gg_ko",
+             reference_path = "referencia/ghr/", drop = TRUE)

Error in picrust_otu(file.path(reference_path, ref_fn, fsep = platform_sep()), : Not compatible with STRSXP: [type=NULL].

[the dabase, was downloaded as zip and decompressed manually from: https://gitlab.com/sw1/themetagenomics_data/ and i save them into referencia/ghr directory]