microbiomeViz icon indicating copy to clipboard operation
microbiomeViz copied to clipboard

Only works for phyloseq when the phyloseq object (e.g GlobalPattern) has taxa_are_row == TRUE

Open 2533245542 opened this issue 5 years ago • 3 comments

I don't know why but phyloseq allows two kind of otu layout in a phyloseq object; one is taxa_are_row and the other one not. To access this information, one can use taxa_are_row(phyobj) to check.

What I found is microbiomeViz currently only supports the taxa_are_row == TRUE phyobj, but you can make adjustment if you have time. And here is one function I wrote to make that kind of adjustment.

edit_phyobj = function(phyobj){ # phyobj must be taxa_are_rows = TRUE for microbiomeviz to work
			if(!taxa_are_rows(phyobj)){
				otu = otu_table(phyobj)
				otu = t(otu)

				return(
					phyloseq(
						otu_table(otu,taxa_are_rows = TRUE),
						tax_table(phyobj),
						sample_data(phyobj)
						)
					)
			}
		}

2533245542 avatar Sep 04 '18 02:09 2533245542

Thanks for this. I will integrate this to the parser soon.

lch14forever avatar Sep 04 '18 02:09 lch14forever

Actuall that last code does not work, I make some edits now

edit_phyobj = function(phyobj){ # phyobj must be taxa_are_rows = TRUE for microbiomeviz to work
			if(!taxa_are_rows(phyobj)){
				otu = otu_table(phyobj)
				otu = t(otu)
				return(
				  phyloseq(
				    otu_table(otu,taxa_are_rows = TRUE),
				    tax_table(phyobj),
				    sample_data(phyobj)
				  )
				)
			} else {
			  return(phyobj)
			}
		}

2533245542 avatar Sep 04 '18 03:09 2533245542

Do you have some test data that I can try?

lch14forever avatar Sep 04 '18 10:09 lch14forever