Phyloseq sample_data和sample_names无法将样本合并到phyloseq对象中

问题描述

我的问题与使用phyloseq()建立一个phyloseq对象有关。我遵循了https://joey711.github.io/phyloseq/import-data.htmlhttps://vaulot.github.io/tutorials/Phyloseq_tutorial.html ,并且该代码以前已经起作用。

具体来说,当我的样本在otu_mat和samples_df中都为SAME时,为什么sample_names()返回一个NULL值向量

以下是开始文件

   > head(otu_mat)
                      Species  1  2  3   4  5   6  7  8  9 10 11 12  13 14 15 16 17 18 19 20 21 22 23 24
1           Absiella dolichum 44 14  3 152 50 106  4  4 14 41  2  0   1 21  1  2  4  2  2  4  0  4  7  0
2  Acetivibrio ethanolgignens 50  4 10  65 30  96 71 88 35 65 16 21 108 44 12 40  8 64 42 77 29 24 21 31
3 Acetoanaerobium sticklandii  0  0  0   0  0   0  0  0  0  0  0  0   0  0  0  0  0  0  0  0  0  0  0  0
4        Acetobacterium bakii  0  0  0   0  0   0  0  0  0  0  0  0   0  0  0  0  0  0  0  0  0  0  0  0
5       Acholeplasma axanthum 53 26  2  45  9  19  8  7  4 36  3  4  75 16  2 18  6 22  4  2 25 13  3 13
6      Acholeplasma brassicae  0  0  0   0  1   0  0  0  0  1  0  0   2  0  0  2  1  1  1  1  0  3  0  3
    > head(tax_mat)
 Kingdom  Phylum     Class     Order      Family             Genus                    Species            
  <chr>    <chr>      <chr>     <chr>      <chr>              <chr>                    <chr>              
1 Bacteria Firmicutes Clostrid… Clostridi… Lachnospiraceae    unclassified Lachnospir… Lachnospiraceae ba…
2 Bacteria Bacteroid… Bacteroi… Bacteroid… Tannerellaceae     Parabacteroides          unclassified Parab…
3 Bacteria Firmicutes Clostrid… Clostridi… Lachnospiraceae    Blautia                  Ruminococcus gnavus
4 Bacteria Firmicutes Clostrid… Clostridi… Ruminococcaceae    Ruminococcus             Ruminococcus bromii
5 Bacteria Firmicutes Clostrid… Clostridi… Clostridiales inc… Clostridiales Family XI… Emergencia         
6 Bacteria Firmicutes Clostrid… Clostridi… Ruminococcaceae    Anaerotruncus            unclassified Anaer…
> head(samples_df)
 OG_Sample Sample  Activity    Diet    Sex   Time Weight                Treatment
1       101      1 Sedentary Control Female Week_3     21 Sedentary_Control_Female
2       102      2 Sedentary Control Female Week_3     20 Sedentary_Control_Female
3       103      3 Sedentary Control Female Week_3     21 Sedentary_Control_Female
4       104      4 Sedentary Control Female Week_3     22 Sedentary_Control_Female
5       105      5 Sedentary Control Female Week_3     19 Sedentary_Control_Female
6       106      6 Sedentary Control Female Week_3     19 Sedentary_Control_Female
# Here is the code:
otu_mat <- w3.long %>% rownames_to_column("Species")
# make tax_otu file (OTUs as rows,taxnomoy as columns)
tax_mat1 <- l %>% 
  select(Kingdom,Phylum,Class,Order,Family,Genus,Species) %>% 
  group_by(Species)
# This filters tax_mat1 by Species in otu_mat
tax_mat <- tax_mat1 %>% 
  filter(Species %in% otu_mat$Species) %>%
  distinct(.keep_all = FALSE)
# Subset of Metadata file for conformable arrays
w3.env <- as.data.frame(GS2.env[1:56,])
samples_df <- w3.env %>% select(Sample,Activity,Diet,Sex,Time,Weight,Treatment)
rownames(samples_df) <- samples_df$Sample

# --------------------- Preprocessing for Phyloseq ------------------------------------------
row.names(otu_mat) <- otu_mat$Species
otu_mat <- otu_mat %>% select(-Species)

row.names(tax_mat) <- tax_mat$Species

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 uses the phyloseq() command to rapidly combine the otu_table,# tax_table and samples
carbom <- phyloseq(OTU,TAX,samples)
carbom

这是错误

validobject(.Object)中的错误:无效的类“ phyloseq”对象: 组分样品名称不匹配。 尝试sample_names()

我使用sample_names()重试,它返回一个NULL值的向量

samples = sample_names(samples_df)

在这里验证样品名称是否匹配

> # find the overlapping samples
> common.ids <- intersect(rownames(samples),colnames(otu_mat))
> dim(common.ids)
NULL

非常感谢您的帮助!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...