Closed Ecotone23 closed 11 months ago
Hey, @Ecotone23 I have the same problem.
How you solved this?
Hi @luisymbio, In my case, my sample names consist of numeric values, and when using phyloseq, I noticed that it automatically converts these numeric sample names to non-numeric ones by adding an "X" before the number in the OTU matrix. This can result in sample name mismatches. To address this issue, if you encounter the same problem, follow these steps:
First, check whether your sample names match using the following commands:
Run sample_names(OTU)
Run sample_names(samples)
If you find that the sample names do not match, especially if the sample names in the OTU matrix have been coerced to the format "X+number," you will need to manually update the sample names in your original sample file to match the "X+number" format.
Taking these steps should help resolve the sample name mismatch problem.
Hi @luisymbio, In my case, my sample names consist of numeric values, and when using phyloseq, I noticed that it automatically converts these numeric sample names to non-numeric ones by adding an "X" before the number in the OTU matrix. This can result in sample name mismatches. To address this issue, if you encounter the same problem, follow these steps:
First, check whether your sample names match using the following commands: Run
sample_names(OTU)
Runsample_names(samples)
If you find that the sample names do not match, especially if the sample names in the OTU matrix have been coerced to the format "X+number," you will need to manually update the sample names in your original sample file to match the "X+number" format. Taking these steps should help resolve the sample name mismatch problem.
Wow, there is no way to avoid this leaving the number as flag? As I understood renaming it with a letter at the beginning should solve it.
Hi @joey711 ,
I tried to build a phyloseq object with three txt files as my data source:
an amplicon abundance table, with OTU number as the row name and sample ID as the column name
a taxonomy table, with the same OTU number as the row name and Kingdom to Genus as the column name
and a supplementary information table, with sample ID as the row name and other variable as the column name
I ran the following scripts and got error as described in the title at the last step, and wonder how I can fix the problem. Thank you.
load the data
otu_mat <- read.table("seqtabNoChim.txt", header = TRUE, sep = "\t") # OTU abundance table tax_mat <- read.table("Taxa_table.txt", header = TRUE, sep = "\t") # taxonomy table samples_df <- read.table("culex_map_file.txt", header = TRUE, sep = "\t") # other information table
Define Row Names for each type of data
row.names(otu_mat) <- otu_mat$OTUNumber
Remove the column which is already used as row from the data
otu_mat <- otu_mat %>% select (-OTUNumber) row.names(tax_mat) <- tax_mat$OTUNumber tax_mat <- tax_mat %>% select (-OTUNumber) row.names(samples_df) <- samples_df$Sample samples_df <- samples_df %>% select (-Sample) sampletype <- unique(row.names(samples_df))
Transform into matrix
otu_mat <- as.matrix(otu_mat) tax_mat <- as.matrix(tax_mat)
Transform matrix data as input for Phyloseq
OTU <- otu_table(otu_mat, taxa_are_rows = TRUE) TAX <- tax_table(tax_mat) samples<-sample_data(samples_df)
DF <- phyloseq(OTU, TAX, samples)