EESI / themetagenomics

Other
23 stars 4 forks source link

Extracting topic information #12

Open prialp55 opened 4 years ago

prialp55 commented 4 years ago

Hi. I'm using this package to analyze my microbiome data, and I'm really interested to know if there's a way to obtain a table that shows the composition of each topic? Kind of like the bar plots, but a csv file. Thanks!

sw1 commented 4 years ago

So assuming you have a fitted model like

CLEAN <- prepare_data(otu_table=DAVID$ABUND, rows_are_taxa=FALSE, tax_table=DAVID$TAX, metadata=DAVID$META, formula=~Site + s(Day), refs='UBERON:saliva', cn_normalize=FALSE, drop=TRUE)

TOPICS <- find_topics(CLEAN,K=15)

Then the composition of taxa within topics would be beta:

TOPICS$fit$beta$logbeta[[1]]

which is in logspace so

topic_proportions <- exp(TOPICS$fit$beta$logbeta[[1]])

which is a K x M matrix where K is the number of topics and M is the number of taxa.

ycolin26 commented 3 years ago

Thank you @sw1 for these very useful clarifications. However, I don't understand why the taxa names are replaced by V1, V2, V3... in the output table (e.g. topic_proportions). How do we make the link with the initial OTUs...?

yannick