SummarizedExperiment object

Researchers who prefer using the SummarizedExperiment class can feed their data and associated metrics into the bigPint methods using one SummarizedExperiment object (instead of both a data and dataMetrics object). We demonstrate here how to create a SummarizedExperiment object. In the remaining articles of the vignette, the example code uses the data and dataMetrics objects as example input. However, at the bottom of each vignette, we also include the corresponding example code that uses instead the SummarizedExperiment object to create the exact same plots.


Example: two groups

As was shown in the article Data object, the data object called soybean_ir_sub contained 5,604 genes and two treatment groups, N and P (Lauter and Graham 2016). We can create a SummarizedExperiment object that combines aspects of the data object and dataMetrics object. We start by reading in the data and dataMetrics objects (created from edgeR in the article Data metrics object.

library(bigPint)
library(DelayedArray)
## Warning: package 'DelayedArray' was built under R version 3.6.3
## Warning: package 'S4Vectors' was built under R version 3.6.3
library(SummarizedExperiment)
## Warning: package 'GenomeInfoDb' was built under R version 3.6.3
data(soybean_ir_sub)
data = soybean_ir_sub
data(soybean_ir_sub_metrics)
dataMetrics = soybean_ir_sub_metrics

We then convert the dataMetrics object from a list of dataframes into one dataframe.

dMUnlist <- dataMetrics
dMUnlist[-1] <- lapply(dMUnlist[-1], transform, ID = NULL)
dMUnlist <- do.call(cbind, dMUnlist)
names(dMUnlist)[1] <- "ID"

Now, we can tranform our data object into a DelayedMatrix class object and then input both our data and dataMetrics objects combined into a SummarizedExperiment class object. We can verify that the assay() and rowData() methods work for accessing our SummarizedExperiment object.

rownames(data) = data[,1]
data = data[,-1]
data <- DelayedArray(data)
se_soybean_ir_sub <- SummarizedExperiment(assays = data, rowData = dMUnlist)
assay(se_soybean_ir_sub)
## <5604 x 6> matrix of class DelayedMatrix and type "integer":
##                             N.1  N.2  N.3  P.1  P.2  P.3
## Glyma.06G158700.Wm82.a2.v1   48   28   15   29   16    8
## Glyma.08G156000.Wm82.a2.v1    0    0    0    0    0    0
## Glyma.12G070600.Wm82.a2.v1    8   11   11    5    8    7
## Glyma.19G045200.Wm82.a2.v1  200  192  187  186  193  183
## Glyma.05G050000.Wm82.a2.v1    0    0    0    0    0    0
##                        ...    .    .    .    .    .    .
## Glyma.08G043300.Wm82.a2.v1   31   32   17   23   24   23
## Glyma.01G089300.Wm82.a2.v1 1859 1904 1607 1869 1735 1479
## Glyma.04G168000.Wm82.a2.v1    1    2    0    1    1    6
##   Glyma.U001000.Wm82.a2.v1    0    0    0    0    0    0
## Glyma.17G217700.Wm82.a2.v1    0    0    0    0    0    0
rowData(se_soybean_ir_sub)
## DataFrame with 5604 rows and 6 columns
##                                                    ID         N_P.logFC
##                                           <character>         <numeric>
## Glyma.06G158700.Wm82.a2.v1 Glyma.19G168700.Wm82.a2.v1  -5.9247761923622
## Glyma.08G156000.Wm82.a2.v1 Glyma.13G293500.Wm82.a2.v1  2.99173960996473
## Glyma.12G070600.Wm82.a2.v1 Glyma.05G188700.Wm82.a2.v1  -3.5079074671209
## Glyma.19G045200.Wm82.a2.v1 Glyma.13G173100.Wm82.a2.v1 -3.90774673911046
## Glyma.05G050000.Wm82.a2.v1 Glyma.11G141800.Wm82.a2.v1 -3.50814181090523
## ...                                               ...               ...
## Glyma.08G043300.Wm82.a2.v1 Glyma.03G066400.Wm82.a2.v1                 0
## Glyma.01G089300.Wm82.a2.v1 Glyma.13G267400.Wm82.a2.v1                 0
## Glyma.04G168000.Wm82.a2.v1 Glyma.06G233000.Wm82.a2.v1                 0
## Glyma.U001000.Wm82.a2.v1     Glyma.U001000.Wm82.a2.v1                 0
## Glyma.17G217700.Wm82.a2.v1 Glyma.17G217700.Wm82.a2.v1                 0
##                                  N_P.logCPM           N_P.LR
##                                   <numeric>        <numeric>
## Glyma.06G158700.Wm82.a2.v1 7.51940083928117  265.83486914301
## Glyma.08G156000.Wm82.a2.v1 8.07646635392326 171.406495183488
## Glyma.12G070600.Wm82.a2.v1 8.83078536437528 167.407678145543
## Glyma.19G045200.Wm82.a2.v1 8.26716122502243 156.671559411266
## Glyma.05G050000.Wm82.a2.v1 10.1912062562805 153.787608225866
## ...                                     ...              ...
## Glyma.08G043300.Wm82.a2.v1  1.5799452462371                0
## Glyma.01G089300.Wm82.a2.v1  1.5799452462371                0
## Glyma.04G168000.Wm82.a2.v1  1.5799452462371                0
## Glyma.U001000.Wm82.a2.v1    1.5799452462371                0
## Glyma.17G217700.Wm82.a2.v1  1.5799452462371                0
##                                      N_P.PValue              N_P.FDR
##                                       <numeric>            <numeric>
## Glyma.06G158700.Wm82.a2.v1 9.17713438359673e-60 5.14286610856761e-56
## Glyma.08G156000.Wm82.a2.v1  3.6473810406337e-39 1.02199616758556e-35
## Glyma.12G070600.Wm82.a2.v1 2.72508695427751e-38 5.09046243059039e-35
## Glyma.19G045200.Wm82.a2.v1 6.03836012864639e-36 8.45974254023359e-33
## Glyma.05G050000.Wm82.a2.v1 2.57718195534749e-35 2.88850553555347e-32
## ...                                         ...                  ...
## Glyma.08G043300.Wm82.a2.v1                    1                    1
## Glyma.01G089300.Wm82.a2.v1                    1                    1
## Glyma.04G168000.Wm82.a2.v1                    1                    1
## Glyma.U001000.Wm82.a2.v1                      1                    1
## Glyma.17G217700.Wm82.a2.v1                    1                    1

Example: three groups

Similarly, as was shown in the data page, the data object called soybean_cn_sub contained 7,332 genes and three treatment groups, S1, S2, and S3 (Brown and Hudson 2015). We can create a SummarizedExperiment object that combines aspects of the data object and dataMetrics object. We start by reading in the data and dataMetrics objects (created from edgeR in the article Data metrics object.

data(soybean_cn_sub)
data = soybean_cn_sub
data(soybean_cn_sub_metrics)
dataMetrics = soybean_cn_sub_metrics

We then convert the dataMetrics object from a list of dataframes into one dataframe.

dMUnlist <- dataMetrics
dMUnlist[-1] <- lapply(dMUnlist[-1], transform, ID = NULL)
dMUnlist <- do.call(cbind, dMUnlist)
names(dMUnlist)[1] <- "ID"

Now, we can tranform our data object into a DelayedMatrix class object and then input both our data and dataMetrics objects combined into a SummarizedExperiment class object. We can verify that the assay() and rowData() methods work for accessing our SummarizedExperiment object.

rownames(data) = data[,1]
data = data[,-1]
data <- DelayedArray(data)
se_soybean_cn_sub <- SummarizedExperiment(assays = data, rowData = dMUnlist)
assay(se_soybean_cn_sub)
## <7332 x 9> matrix of class DelayedMatrix and type "double":
##                       S1.1      S1.2      S1.3 ...      S3.2      S3.3
##  Glyma06g12670.1 0.8024444 2.7088837 1.7634068   . 8.3675932 8.3893470
##  Glyma08g12390.2 4.7687202 5.2357774 5.1666308   . 4.0314271 4.2693124
## Glyma12g02076.11 3.1899340 2.9021310 2.9065021   . 2.7311049 3.2556486
##  Glyma18g53450.1 0.8024444 0.8024444 0.8024444   . 0.8024444 0.8024444
##  Glyma05g03470.4 3.1899340 2.4801080 3.2620818   . 3.4196490 4.1435591
##              ...         .         .         .   .         .         .
##  Glyma02g14300.1 4.6005599 4.9369766 3.8996875   . 5.7465508 5.8893165
##  Glyma06g17451.4 0.8024444 3.0701936 2.2841221   . 2.4400407 0.8024444
##  Glyma06g01600.2 2.5761594 4.0431593 4.6920688   . 3.8463167 3.2556486
##  Glyma15g08800.1 0.8024444 2.7088837 2.2841221   . 4.1727846 3.4845295
##  Glyma02g34995.1 0.8024444 0.8024444 0.8024444   . 0.8024444 0.8024444
rowData(se_soybean_cn_sub)
## DataFrame with 7332 rows and 16 columns
##                               ID           S1_S2.logFC     S1_S2.logCPM
##                      <character>             <numeric>        <numeric>
## Glyma06g12670.1  Glyma18g00690.1       3.1406164674386 8.04140935435585
## Glyma08g12390.2  Glyma08g22380.1      2.62010301368484 8.04876788928141
## Glyma12g02076.11 Glyma20g30460.1      2.50409605459317 8.13952799903194
## Glyma18g53450.1  Glyma07g09700.1      2.37046086750861 8.19271840209557
## Glyma05g03470.4  Glyma10g31780.1      2.74333730828629  7.9319873394926
## ...                          ...                   ...              ...
## Glyma02g14300.1  Glyma10g10560.4 -0.000413427604253003 7.86347185571317
## Glyma06g17451.4  Glyma17g26590.1  0.000192533500625859 8.97421823694854
## Glyma06g01600.2  Glyma17g01820.2  0.000285254463364393 7.82862405077197
## Glyma15g08800.1  Glyma01g44330.1  0.000199404175442821 8.36788817678224
## Glyma02g34995.1  Glyma10g42001.6 -0.000277879736503788 7.38340012952646
##                              S1_S2.LR         S1_S2.PValue            S1_S2.FDR
##                             <numeric>            <numeric>            <numeric>
## Glyma06g12670.1      29.3377659053178 6.07991481053223e-08 0.000445779353908223
## Glyma08g12390.2      24.7572842865198 6.50225983485003e-07  0.00238372845545602
## Glyma12g02076.11     23.9633668945292 9.81862225726021e-07   0.0023996712796744
## Glyma18g53450.1      22.6528940494972 1.94067691466674e-06  0.00355726078458414
## Glyma05g03470.4      21.0107015771135  4.5672514178665e-06  0.00669741747915943
## ...                               ...                  ...                  ...
## Glyma02g14300.1  5.75159128018976e-07    0.999394890420705    0.999674854803839
## Glyma06g17451.4     2.99561162799e-07    0.999563300400471    0.999674854803839
## Glyma06g01600.2  2.52769910419337e-07    0.999598853755752    0.999674854803839
## Glyma15g08800.1  2.05640599770796e-07    0.999638178410205    0.999674854803839
## Glyma02g34995.1  1.66063652162762e-07    0.999674854803839    0.999674854803839
##                            S1_S3.logFC     S1_S3.logCPM             S1_S3.LR
##                              <numeric>        <numeric>            <numeric>
## Glyma06g12670.1       3.18021576438139 8.04876788928141     30.3535157635927
## Glyma08g12390.2       3.31782869501987 8.13525861911815     24.7499133395679
## Glyma12g02076.11      2.44356811670685 8.13952799903194     23.2588075894178
## Glyma18g53450.1       2.46354631724766 8.04140935435585     22.5072123081431
## Glyma05g03470.4       3.02814866964131 7.85103429586298     22.3237406601991
## ...                                ...              ...                  ...
## Glyma02g14300.1   0.000181323009531468 8.10962711657198 1.36860755173274e-07
## Glyma06g17451.4  -0.000198696779056767  7.6469633713906 1.02335294238642e-07
## Glyma06g01600.2  -0.000100971883233311 8.60600253550183 6.35067563606317e-08
## Glyma15g08800.1   6.68582466891479e-05 8.63256350133575 2.72929973760272e-08
## Glyma02g34995.1   1.47433205433351e-05 7.70704380569527 6.03469940685386e-10
##                          S1_S3.PValue            S1_S3.FDR
##                             <numeric>            <numeric>
## Glyma06g12670.1  3.60053785056458e-08 0.000263991435203395
## Glyma08g12390.2  6.52717356513269e-07  0.00239286182897764
## Glyma12g02076.11 1.41600489907636e-06  0.00337772431327586
## Glyma18g53450.1  2.09356073864243e-06  0.00337772431327586
## Glyma05g03470.4  2.30341265226123e-06  0.00337772431327586
## ...                               ...                  ...
## Glyma02g14300.1     0.999704825036919    0.999980399466941
## Glyma06g17451.4     0.999744757625969    0.999980399466941
## Glyma06g01600.2     0.999798928729247    0.999980399466941
## Glyma15g08800.1     0.999868184744363    0.999980399466941
## Glyma02g34995.1     0.999980399466941    0.999980399466941
##                            S2_S3.logFC     S2_S3.logCPM             S2_S3.LR
##                              <numeric>        <numeric>            <numeric>
## Glyma06g12670.1       2.66436020376367 7.85943484994532     16.1010284435055
## Glyma08g12390.2       2.71839513128107 7.82371738576058     16.0104243609561
## Glyma12g02076.11      2.77896477422702 8.13525861911815     14.2809998478888
## Glyma18g53450.1       2.19312440298844 7.63084646168203      11.837447530885
## Glyma05g03470.4       2.28950273402781 7.84030883115338     10.4717693290984
## ...                                ...              ...                  ...
## Glyma02g14300.1  -0.000587797267706622 7.10963315039468 5.02569005522702e-07
## Glyma06g17451.4  -0.000173649112616916 8.56696801319134 1.76322233938486e-07
## Glyma06g01600.2   0.000118818030845814 8.54349783387869 8.37196033054433e-08
## Glyma15g08800.1  -0.000129615564354734 8.16543738316834 7.10091234701338e-08
## Glyma02g34995.1  -0.000100783016769296 8.32825332997323 4.83292751929376e-08
##                          S2_S3.PValue         S2_S3.FDR
##                             <numeric>         <numeric>
## Glyma06g12670.1  6.00514158020776e-05 0.230938474783886
## Glyma08g12390.2  6.29946739726911e-05 0.230938474783886
## Glyma12g02076.11 0.000157446136515663  0.38479835764428
## Glyma18g53450.1  0.000580513451530436 0.999824593695449
## Glyma05g03470.4   0.00121212572789409 0.999824593695449
## ...                               ...               ...
## Glyma02g14300.1     0.999434362914674 0.999824593695449
## Glyma06g17451.4     0.999664962369523 0.999824593695449
## Glyma06g01600.2      0.99976913737134 0.999824593695449
## Glyma15g08800.1     0.999787383417981 0.999824593695449
## Glyma02g34995.1     0.999824593695449 0.999824593695449

References

Brown, Anne V., and Karen A. Hudson. 2015. “Developmental Profiling of Gene Expression in Soybean Trifoliate Leaves and Cotyledons.” BMC Plant Biology 15 (1): 169.

Lauter, AN Moran, and MA Graham. 2016. “NCBI Sra Bioproject Accession: PRJNA318409.”