DESeq2::sizeFactors() function does not output the sizeFactor table.
1
0
Entering edit mode
Ben ▴ 50
@ben-17772
Last seen 5 months ago
United States

Hi everybody,

This is a quick question regarding the DESeq2::sizeFactors() function.

To my knowledge, and I hope I am right here, this function prints out the size factor table calculated by the DESeq2::estimateSizeFactors() function, or can be used to assign a size factor table to a DESeqDataSet.

This is not working for me right now and I wonder if this is a bug or if I am doing something wrong. I do have the following output:

> dds = DESeqDataSetFromTximport(txi = txi_rsem,
+                                colData = suppl_DE,
+                                design = dds_design)
using counts and average transcript lengths from tximport
> dds = estimateSizeFactors(object = dds)
using 'avgTxLength' from assays(dds), correcting for library size
> DESeq2::sizeFactors(object = dds)
NULL
> head(dds@assays$`.->data`$normalizationFactors)
                      37        38       39      223      224       225        43       44       45        55       56        57
ENSG00000000003 1.955242 1.1959429 2.155426 4.019545 1.810443 0.6569379 0.4803744 1.332445 1.992221 0.9276040 1.150631 0.2922839
ENSG00000000005 1.998473 1.3346227 1.985947 4.088732 1.610720 0.6053358 0.4442907 1.298375 2.059495 0.8561081 1.066866 0.2692901
ENSG00000000419 2.035106 1.2662805 2.006737 4.132228 1.641392 0.6097413 0.4394249 1.337283 1.995736 0.8525858 1.072112 0.2506485
ENSG00000000457 2.231868 1.3177075 2.175725 4.034305 1.545610 0.5545260 0.4593386 1.279016 2.045876 0.8689270 1.005106 0.2528214
ENSG00000000460 1.699157 0.9614356 1.833769 4.056419 1.461259 0.7162309 0.5289210 1.293589 1.590824 0.7481319 1.019767 0.1630426
ENSG00000000938 2.102553 1.4132327 2.143644 3.989516 1.587771 0.5995394 0.4659913 1.370016 2.091722 0.8614109 1.031070 0.2638402
                      139      140      141      127      128       129      247      248      249       145      146       147
ENSG00000000003 0.6694836 1.422386 2.260352 2.209676 1.260261 1.0846202 1.158377 1.519699 3.010913 0.5003549 1.122298 0.4953297
ENSG00000000005 0.6876588 1.722467 2.246184 2.179192 1.083559 0.9147638 1.189386 1.276715 4.735511 0.8578543 1.234478 0.5822791
ENSG00000000419 0.6806034 1.707245 2.280220 2.217432 1.104848 0.9312860 1.197376 1.295380 3.183622 0.8731478 1.256079 0.5916526
ENSG00000000457 0.6336591 1.635686 2.069190 2.208514 1.249812 0.9094577 1.258961 1.349064 3.228104 0.8970440 1.343730 0.6164877
ENSG00000000460 0.6765751 1.455864 2.121610 2.855973 1.087118 1.0736772 1.370448 1.267261 3.271577 0.8354410 1.628191 0.5976314
ENSG00000000938 0.6461903 1.706534 2.245400 2.204117 1.086940 0.9158851 1.158005 1.264948 3.119524 0.8888839 1.252938 0.5969507
                      151      152      153       229       230       231      169      170       171       175      176       177
ENSG00000000003 0.4899692 1.000269 1.697258 0.5379027 0.3099666 0.5546374 1.321894 2.549355 0.3611776 0.8839132 1.526483 1.2381775
ENSG00000000005 0.4528543 1.037994 1.498454 1.3647716 0.3890118 0.5079416 1.721318 2.388563 0.3334490 0.9312812 1.860784 1.0231431
ENSG00000000419 0.4591837 1.057342 1.528871 1.3833303 0.3953979 0.5156553 1.692714 2.428884 0.3365124 0.9405985 1.856458 1.0381603
ENSG00000000457 0.4424253 1.008558 1.547160 1.4195601 0.4026299 0.4902238 1.561090 2.196709 0.3196145 0.8921872 1.723590 0.9710808
ENSG00000000460 0.5143812 1.204023 1.500126 1.4180668 0.3396498 0.4849575 1.789936 2.050081 0.3500491 0.9970647 1.748196 1.1154241
ENSG00000000938 0.4471966 1.040437 1.507808 1.3591392 0.3975661 0.5111689 1.770232 2.416790 0.3635059 0.9459270 1.953554 1.0759176
                     181      182       183      187      188      189       91       92        93       116      117       157
ENSG00000000003 2.911263 2.102739 0.4422076 2.102199 1.528393 1.709739 1.239798 2.592802 0.2778480 0.7090639 2.951858 0.6666782
ENSG00000000005 3.041694 1.795906 0.4074033 2.242451 1.469207 1.914649 1.169010 2.685305 0.2744419 0.6109591 2.952868 0.6120693
ENSG00000000419 3.022889 1.808744 0.4136650 2.263943 1.493167 1.937378 1.134487 2.727256 0.2511263 0.6150381 3.009015 0.6211097
ENSG00000000457 2.855325 1.773368 0.3454223 2.195840 1.460291 1.813965 1.167886 2.590124 0.2524901 0.7045752 3.037859 0.6710077
ENSG00000000460 2.858273 1.668888 0.6867232 2.432517 1.468383 1.862755 1.247311 2.479675 0.3096363 0.6402914 2.956261 0.4813635
ENSG00000000938 2.981251 1.755022 0.4218868 2.268192 1.465075 1.929867 1.148286 2.740771 0.2830531 0.5904311 2.828218 0.6267804
                      158       159       121      122       123       163       164       165       211       212       213       199
ENSG00000000003 0.6429066 0.4813660 0.8557734 1.467553 0.5798909 0.4962319 0.7722395 0.4378618 0.5181240 0.8707718 0.5847678 0.8751378
ENSG00000000005 0.6717334 0.3340912 0.7858183 1.291406 0.5322940 0.4547822 0.9301494 0.4016647 0.4742017 0.7212282 0.4588380 0.9231025
ENSG00000000419 0.6818405 0.3401001 0.7880545 1.319390 0.5432996 0.4648281 0.9504915 0.4095962 0.4835592 0.7348536 0.4688256 0.9293159
ENSG00000000457 0.7236951 0.3184716 0.7728738 1.358923 0.5785128 0.4865613 1.0557220 0.4395827 0.5518766 0.7940542 0.5000047 0.9758201
ENSG00000000460 0.8056640 0.5472984 0.7711359 1.266655 0.5130723 0.4157363 0.9489811 0.3436353 0.3334114 0.6686022 0.5832169 0.9326715
ENSG00000000938 0.6702543 0.3307351 0.7795972 1.308419 0.5211337 0.4621952 0.9150677 0.4141382 0.4712596 0.7158966 0.4621258 0.9139179
                     200       201
ENSG00000000003 1.190463 0.3612043
ENSG00000000005 1.135199 0.3045086
ENSG00000000419 1.154232 0.3052906
ENSG00000000457 1.161044 0.2799472
ENSG00000000460 1.285133 0.3750760
ENSG00000000938 1.124071 0.3061432
> 

Thanks!

deseq2 • 3.3k views
ADD COMMENT
2
Entering edit mode
@mikelove
Last seen 1 day ago
United States

With tximport, we compute gene x sample normalization factors. You can extract them with normalizationFactors()

ADD COMMENT
0
Entering edit mode

Ha! Interesting. Thanks much!

So even though (I guess) the normalization factors are calculated using the DESeq2::estimateSizeFactors() from a DESeqDataSet object (either created using a tximport or another input), the result of the estimateSizeFactors() function is stored/accessed differently - depending on the input used to create the DESeqDataSet?

ADD REPLY
1
Entering edit mode

I don’t store the size factors as they are not part of the final computation. They are roughly the column means of the normalization factors. Or you can get them directly by providing the average transcript length matrix from tximport to estimateSizeFactorsForMatrix() as the normMatrix.

ADD REPLY
0
Entering edit mode

Recently, I computed my transcript count matrix using Salmon. Using tximport (and biomart) I converted my transcript count matrix to gene count matrix. Can you please look at the following code and let me know, if I am doing the right things?

dds <- DESeqDataSetFromTximport(txi, colData = meta, design = ~ sampletype)

dds <- DESeq(dds)

sizeFactors(dds) <- estimateSizeFactorsForMatrix(txi$counts)

results <- results(dds)

significant_genes <- subset(results, padj < 0.05)

I have explicitly assigned sizefactors, as when I was computing them (after DESeq) it was coming out to be NULL. Please assist.

ADD REPLY
0
Entering edit mode

hi Dinesh,

as when I was computing them (after DESeq) it was coming out to be NULL.

it seems like you didn't read the thread that you posted to. Read above. And you can just follow the code from tximport vignette.

Again, to repeat what this thread said, sizeFactors is supposed to be NULL when using tximport.

ADD REPLY
0
Entering edit mode

oh..yes, I got it....Thank you so much.

ADD REPLY

Login before adding your answer.

Traffic: 740 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6