I'm very thankful if anybody have time to help!
Is the estimation of size factors included in VST normalization? I assumed according DESeq2 manual that VST normalization includes the estimation of size factors but I noticed that the size factor after VST normalization was same for all libraries, though the library size varied. I then tried the VST normalization on three different ways and finally succeeded to change size factors.
I wonder that why VST normalization did not estimate size factors correctly or did I something very wrong? Where should I trust? Here is my script:
First I tried this:
#transform a phyloseq object to a deseq OTU2_deseq<-phyloseq_to_deseq2(OTU2, ~Treatment) #VST transformation vsd <- varianceStabilizingTransformation(OTU2_deseq, blind = TRUE) vsd$sizeFactor C1A C1B C2B C3B C4B D1A D2A D3B D4A 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 D4B M1A M1B M2B M3A M4B V1A V2A V3A 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 V4A V4B 0.9659363 0.9659363 The size factor was same for all libraries although there are differences in the library sizes: C1A C1B C2B C3B C4B D1A D2A D3B D4A D4B M1A M1B M2B M3A 97884 119267 115434 167045 100795 58687 88702 85306 109512 150311 55833 95364 79377 98857 M4B V1A V2A V3A V4A V4B 99659 120503 113216 118007 102453 146158
Since the size factor was not correct, I tried to correct it before the VST transformation:
#transform phyloseq object to deseq OTU2_deseq<-phyloseq_to_deseq2(OTU2, ~Treatment) #estimating size factors from the deseq object OTU2_deseq<-estimateSizeFactors(OTU2_deseq) OTU2_deseq$sizeFactor C1A C1B C2B C3B C4B D1A D2A D3B D4A 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 D4B M1A M1B M2B M3A M4B V1A V2A V3A 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 0.9659363 V4A V4B 0.9659363 0.9659363
So this didn't work either. The factors are still same. Then I tried this:
sizefactors_otu2<-estimateSizeFactorsForMatrix(otu2) sizefactors_otu2 C1A C1B C2B C3B C4B D1A D2A D3B D4A 0.9483795 1.2267456 1.2178742 1.7675233 1.1336218 0.6019426 0.9482678 0.8143618 1.2240495 D4B M1A M1B M2B M3A M4B V1A V2A V3A 1.5083716 0.5034122 0.8343547 0.7268112 0.8225068 0.9190774 1.1940096 1.2189066 1.2699689 V4A V4B 1.0398748 1.5156871
Now it seemed to work. I continued putting this size factors into the deseq object and
after that I made an VST normalization again:
sizeFactors(OTU2_deseq)<-sizefactors_otu2 sizeFactors(OTU2_deseq) C1A C1B C2B C3B C4B D1A D2A D3B D4A 0.9483795 1.2267456 1.2178742 1.7675233 1.1336218 0.6019426 0.9482678 0.8143618 1.2240495 D4B M1A M1B M2B M3A M4B V1A V2A V3A 1.5083716 0.5034122 0.8343547 0.7268112 0.8225068 0.9190774 1.1940096 1.2189066 1.2699689 V4A V4B 1.0398748 1.5156871 vsd <- varianceStabilizingTransformation(OTU2_deseq, blind = TRUE)
# I checked after the normalization that again and the size factors were still correct:
vsd$sizeFactor C1A C1B C2B C3B C4B D1A D2A D3B D4A 0.9483795 1.2267456 1.2178742 1.7675233 1.1336218 0.6019426 0.9482678 0.8143618 1.2240495 D4B M1A M1B M2B M3A M4B V1A V2A V3A 1.5083716 0.5034122 0.8343547 0.7268112 0.8225068 0.9190774 1.1940096 1.2189066 1.2699689 V4A V4B 1.0398748 1.5156871
Regards,
Hanna Sinkko, PhD
University of Helsinki
After this line:
OTU2_deseq<-phyloseq_to_deseq2(OTU2, ~Treatment)
Can you look at colData(OTU2_deseq)? I wonder if there are size factors already there somehow.