joey711 / phyloseq

phyloseq is a set of classes, wrappers, and tools (in R) to make it easier to import, store, and analyze phylogenetic sequencing data; and to reproducibly share that data and analysis with others. See the phyloseq front page:
http://joey711.github.io/phyloseq/
584 stars 187 forks source link

Exporting DESeq2 results into new OTU table #876

Open marijn1990 opened 6 years ago

marijn1990 commented 6 years ago

Hello everybody,

I have a small issue which is probably just a rookie mistake. I have a dataset of vaginal microbiota; Illumina HiSeq sequencing was performed, I have run the Dada2 pipeline, and made a Philoseq object off the resulting OTU table and taxonomic tree file. Because a certain article taught me not to rarefy, I wanted to use DESeq2 (I used geometric means due to some counts being 0):

VMB <- phyloseq(otu_table(otu, taxa_are_rows=TRUE),tax_table(tree)) #makes phyloseq object of OTU table and tree sample_data(VMB) <- VMB_data VMB_deseq <- phyloseq_to_deseq2(VMB, ~ randomgroup3) #randomgroup3 is my variable of interest gm_mean = function(x, na.rm=TRUE){ exp(sum(log(x[x > 0]), na.rm=na.rm) / length(x)) } geoMeans = apply(counts(VMB_deseq), 1, gm_mean) VMB_deseq = estimateSizeFactors(VMB_deseq, geoMeans = geoMeans) VMB_deseq = DESeq(VMB_deseq,fitType="local")

So far, so good. This all seems to have worked well. So the results are:

VMB_deseq

class: DESeqDataSet dim: 437 639 metadata(1): version assays(5): counts mu cooks replaceCounts replaceCooks rownames(437): Lactobacillus iners Gardnerella vaginalis ... Murdochiella genus Aeromonas caviae/dhakensis/enteropelogenes/hydrophila/jandaei/taiwanensis/veronii rowData names(34): baseMean baseVar ... maxCooks replace colnames(639): L0004 L0006 ... L0990 L0992 colData names(20): subjectid eventcount ... sizeFactor replaceable

This corresponds to the data fed into my "VMB" phyloseq object. However, I now want to make an OTU table based on the transformed count data by DESeq2:

VMB_deseq_otu <- otu_table(VMB_deseq, taxa_are_rows=TRUE) Error in access(object, "otu_table", errorIfNULL) : otu_table slot is empty. I keep getting this result. The same happens if I use VMB0 = VMB # to save previous version otu_table(VMB) <- otu_table(VMB_deseq, taxa_are_rows = TRUE)

Thank you in advance for your help! Again, it's probably just a rookie mistake but I haven't been able to find out how to change this. I am using R version 3.4.3, Phyloseq version 1.20.0 and DESeq2 version 1.16.1, if that's any help.

spholmes commented 6 years ago

This may be due to overzealous checks that occur and phyloseq doesn't like negative values in the otu_table.

Is there a particular reason/function you have for wanting to put this back into the phyloseq object? best Susan

On Thu, Feb 1, 2018 at 5:58 AM, marijn1990 notifications@github.com wrote:

Hello everybody,

I have a small issue which is probably just a rookie mistake. I have a dataset of vaginal microbiota; Illumina HiSeq sequencing was performed, I have run the Dada2 pipeline, and made a Philoseq object off the resulting OTU table and taxonomic tree file. Because a certain article taught me not to rarefy, I wanted to use DESeq2 (I used geometric means due to some counts being 0):

VMB <- phyloseq(otu_table(otu, taxa_are_rows=TRUE),tax_table(tree))

makes phyloseq object of OTU table and tree

sample_data(VMB) <- VMB_data VMB_deseq <- phyloseq_to_deseq2(VMB, ~ randomgroup3) #randomgroup3 is my variable of interest gm_mean = function(x, na.rm=TRUE){ exp(sum(log(x[x > 0]), na.rm=na.rm) / length(x)) } geoMeans = apply(counts(VMB_deseq), 1, gm_mean) VMB_deseq = estimateSizeFactors(VMB_deseq, geoMeans = geoMeans) VMB_deseq = DESeq(VMB_deseq,fitType="local")

So far, so good. This all seems to have worked well. So the results are:

VMB_deseq

class: DESeqDataSet dim: 437 639 metadata(1): version assays(5): counts mu cooks replaceCounts replaceCooks rownames(437): Lactobacillus iners Gardnerella vaginalis ... Murdochiella genus Aeromonas caviae/dhakensis/enteropelogenes/hydrophila/jandaei/taiwanensis/veronii rowData names(34): baseMean baseVar ... maxCooks replace colnames(639): L0004 L0006 ... L0990 L0992 colData names(20): subjectid eventcount ... sizeFactor replaceable

This corresponds to the data fed into my "VMB" phyloseq object. However, I now want to make an OTU table based on the transformed count data by DESeq2:

VMB_deseq_otu <- otu_table(VMB_deseq, taxa_are_rows=TRUE) Error in access(object, "otu_table", errorIfNULL) : otu_table slot is empty. I keep getting this result. The same happens if I use VMB0 = VMB # to save previous version otu_table(VMB) <- otu_table(VMB_deseq, taxa_are_rows = TRUE)

Thank you in advance for your help! Again, it's probably just a rookie mistake but I haven't been able to find out how to change this. I am using R version 3.4.3, Phyloseq version 1.20.0 and DESeq2 version 1.16.1, if that's any help.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/joey711/phyloseq/issues/876, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJcvRnM1i38Xys6JCqyY-wRQ72hOgofks5tQcL_gaJpZM4R1pgs .

-- Susan Holmes John Henry Samter Fellow in Undergraduate Education Professor, Statistics 2017-2018 CASBS Fellow, Sequoia Hall, 390 Serra Mall Stanford, CA 94305 http://www-stat.stanford.edu/~susan/

marijn1990 commented 6 years ago

Dear Susan,

I am interested in using the (count transformed-) relative abundance of e.g. all Lactobacillus (genus and species) OTUs as an outcome in a mixed effects model, as well as using gplot for making clustering heatmaps (and using vaginal microbiome cluster membership as another outcome in the mixed effects model). The design of the study is a clinical trial in which vaginal probiotics were used, and I would also be interested in retrieving the relative abundances of the probiotic products.

Kindly, Marijn

GregDeakin commented 6 years ago

You'll need to use the DESeq counts method to get to the data:

VMB_deseq_otu <- otu_table(counts(VMB_deseq,normalize=T), taxa_are_rows=TRUE)

Greg

spholmes commented 6 years ago

Marijn, I don't you need to remake a phyloseq object to do these analyses and taking relative abundances after transformations no longer makes sense.

In the transformed world you would take additive components (ie like they were logs) Susan

On Fri, Feb 2, 2018 at 1:57 AM, marijn1990 notifications@github.com wrote:

Dear Susan,

I am interested in using the (count transformed-) relative abundance of e.g. all Lactobacillus (genus and species) OTUs as an outcome in a mixed effects model, as well as using gplot for making clustering heatmaps (and using vaginal microbiome cluster membership as another outcome in the mixed effects model). The design of the study is a clinical trial in which vaginal probiotics were used, and I would also be interested in retrieving the relative abundances of the probiotic products.

Kindly, Marijn

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/joey711/phyloseq/issues/876#issuecomment-362540437, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJcvTBPoPlUf7j6jL65OTI-ZDPbfGHdks5tQtv5gaJpZM4R1pgs .

-- Susan Holmes John Henry Samter Fellow in Undergraduate Education Professor, Statistics 2017-2018 CASBS Fellow, Sequoia Hall, 390 Serra Mall Stanford, CA 94305 http://www-stat.stanford.edu/~susan/