Returns aggregated (summed) expression values for each identity class

AggregateExpression(
  object,
  assays = NULL,
  features = NULL,
  return.seurat = FALSE,
  group.by = "ident",
  add.ident = NULL,
  slot = "data",
  verbose = TRUE,
  ...
)

Arguments

object

Seurat object

assays

Which assays to use. Default is all assays

features

Features to analyze. Default is all features in the assay

return.seurat

Whether to return the data as a Seurat object. Default is FALSE

group.by

Categories for grouping (e.g, ident, replicate, celltype); 'ident' by default

add.ident

(Deprecated) Place an additional label on each cell prior to pseudobulking (very useful if you want to observe cluster pseudobulk values, separated by replicate, for example)

slot

Slot(s) to use; if multiple slots are given, assumed to follow the order of 'assays' (if specified) or object's assays

verbose

Print messages and show progress bar

...

Arguments to be passed to methods such as CreateSeuratObject#'

Value

Returns a matrix with genes as rows, identity classes as columns. If return.seurat is TRUE, returns an object of class Seurat.

Details

If slot is set to 'data', this function assumes that the data has been log normalized and therefore feature values are exponentiated prior to aggregating so that sum is done in non-log space. Otherwise, if slot is set to either 'counts' or 'scale.data', no exponentiation is performed prior to aggregating If return.seurat = TRUE and slot is not 'scale.data', aggregated values are placed in the 'counts' slot of the returned object and the log of aggregated values are placed in the 'data' slot. For the ScaleData is then run on the default assay before returning the object. If return.seurat = TRUE and slot is 'scale.data', the 'counts' slot is left empty, the 'data' slot is filled with NA, and 'scale.data' is set to the aggregated values.

Examples

data("pbmc_small")
head(AggregateExpression(object = pbmc_small))
#> $RNA
#>                         0           1           2
#> MS4A1             0.00000    52.08608  3260.68905
#> CD79B           389.32766   438.72106  2890.55373
#> CD79A             0.00000   290.45833  4086.65068
#> HLA-DRA        1335.81085 10146.26306 22003.61887
#> TCL1A             0.00000    86.58009  2699.42099
#> HLA-DQB1        142.85714  1133.82958  3216.24694
#> HVCN1             0.00000   138.73279  1420.89724
#> HLA-DMB          22.57336   494.85604  1411.46216
#> LTB            9429.83049   521.51150  5048.07638
#> LINC00926         0.00000     0.00000   587.90666
#> FCER2             0.00000     0.00000   466.43685
#> SP100           561.61800   154.37710  1106.16545
#> NCF1              0.00000   170.65789   810.86666
#> PPP3CC          389.58081     0.00000   553.58816
#> EAF2              0.00000    62.95036   767.58915
#> PPAPDC1B          0.00000    21.64502   610.70681
#> CD19              0.00000     0.00000   630.61897
#> KIAA0125          0.00000     0.00000   502.66955
#> CYB561A3          0.00000     0.00000   523.84847
#> CD180             0.00000     0.00000   444.14194
#> RP11-693J15.5     0.00000    21.64502   582.96093
#> FAM96A          402.19990   111.44307   663.45391
#> CXCR4          3540.01978   447.25333  3395.86486
#> STX10           450.16450   145.75128   898.37592
#> SNHG7           443.06798    82.65337   801.23293
#> NT5C            148.65819    90.27042  1241.48266
#> BANK1           136.62239    25.70694   444.03207
#> IGLL5             0.00000     0.00000  3350.14254
#> CD200             0.00000     0.00000   431.44283
#> FCRLA             0.00000    43.29004   461.81098
#> CD3D           5528.33711    21.59827  2413.63029
#> NOSIP          2638.07062   227.37212   145.01670
#> SAFB2           595.49436     0.00000     0.00000
#> CD2            1518.60523    14.10437   196.84882
#> IL7R           5097.26880   223.65586   523.32123
#> PIK3IP1        1931.50075    50.90198   250.27683
#> MPHOSPH6        914.17595    57.53522    71.94245
#> KHDRBS1        2595.04679    95.29054    50.69957
#> MAL             578.13325    25.83979     0.00000
#> CCR7           1098.98112     0.00000    91.74312
#> THYN1          1230.60737    48.55245    81.19963
#> TAF7           1792.93148   244.57907   356.23311
#> LDHB           4455.86556   561.65735  1328.26738
#> TMEM123        2646.03096   369.81373   919.45584
#> CCDC104         439.22635     0.00000    81.19963
#> EPC1            926.72274    47.96163   287.11619
#> EIF4A2         4613.97692   466.81096  1376.84860
#> CD3E           3392.68242    33.55705   666.12592
#> TMUB1           644.95574   107.71529     0.00000
#> BLOC1S4         786.88131    88.19310     0.00000
#> ACSM3           435.95473     0.00000     0.00000
#> TMEM204         381.74603     0.00000     0.00000
#> SRSF7          6537.93369   886.88180   726.07099
#> ACAP1          1652.52733     0.00000    63.82391
#> TNFAIP8        1483.70924   160.36163   459.69590
#> CD7            3321.90975     0.00000   274.54737
#> TAGAP           977.69116   139.00183   341.56142
#> DNAJB1         1454.44832   216.19622   143.88489
#> ASNSD1          621.71454    42.91845     0.00000
#> S1PR4          2604.26106   125.93228   344.66987
#> CTSW           3121.53549    25.70694   982.45540
#> GZMK           1008.98645     0.00000   276.83118
#> NKG7          18464.09163   551.68694  4911.21299
#> IL32           6387.57277    93.70297  1120.69906
#> DNAJC2          501.20827    77.26798   245.02642
#> LYAR           1693.40107   139.87117  3589.62799
#> CST7           3696.31538    47.66142   833.04763
#> LCK            2370.14669    19.92032   419.69981
#> CCL5          14643.44170   275.94263  3717.60152
#> HNRNPH1         504.46257     0.00000   192.55851
#> SSR2           3181.90194   646.00270  1008.45098
#> DLGAP1-AS1      214.13227     0.00000    68.49315
#> GIMAP1         2492.02761   299.58687    96.11682
#> MMADHC          613.83224   123.75630   540.62931
#> ZNF76           222.20780    24.63054    68.49315
#> CD8A            686.43013     0.00000   370.21729
#> PTPN22          357.42279    27.70083   131.46626
#> GYPC           2615.07722    27.70083   472.36859
#> HNRNPF         2025.24914   208.59890   717.89231
#> RPL7L1          452.21508    82.73877   279.81267
#> KLRG1          1237.40616     0.00000    71.94245
#> CRBN            795.62224    96.82176   536.05149
#> SATB1          1608.71536     0.00000    84.64893
#> SIT1            336.49503     0.00000   422.09117
#> PMPCB           276.87153    49.82061   331.56456
#> NRBP1           616.16197    28.32861   153.14208
#> TCF7            856.77775    13.42282   202.04880
#> HNRNPA3        1221.70469   278.60533   696.01078
#> S100A8          178.74088  8424.28018    11.46789
#> S100A9          675.81528 16403.31893   106.90748
#> LYZ            1595.40009 24678.52506  4979.80682
#> CD14              0.00000   655.08553    22.93578
#> FCN1            800.42234  3016.50378   648.83344
#> TYROBP         3932.10545  8960.22366   598.07305
#> ASGR1             0.00000   291.26870    13.26260
#> NFKBIA         1452.78460  2356.82688   863.41653
#> TYMP            309.26773  3013.03308   368.17985
#> CTSS           1754.97929  5150.97511  1523.50630
#> TSPO            982.68526  3027.31810   532.22977
#> RBP7              0.00000   426.70945   126.58228
#> CTSB            183.27485  1055.64129    84.64893
#> LGALS1         3208.51273  8077.12962  2089.11238
#> FPR1             22.57336   492.09240     0.00000
#> VSTM1            22.57336   216.99754     0.00000
#> BLVRA           367.39404   818.73929   249.28127
#> MPEG1            18.97533   386.26120   156.91072
#> BID             299.37576  1529.26587   193.81068
#> SMCO4             0.00000   458.32437    71.94245
#> CFD             185.36715  1634.24399   227.29523
#> LINC00936       293.62121   711.84440   160.40029
#> LGALS2          248.84259  1646.42961   187.06374
#> MS4A6A            0.00000   875.67902   203.04360
#> FCGRT           240.22042  1414.02660   100.84302
#> LGALS3          303.98098  1319.15651   103.77237
#> NUP214          117.64706   581.22156    34.96503
#> SCO2             45.14673   410.26260    81.39796
#> IL17RA            0.00000   227.63307     0.00000
#> IFI6            710.21912  1439.43384    68.80734
#> HLA-DPA1        449.52735  5739.65398  6524.70858
#> FCER1A           64.10256   582.72417   364.97687
#> CLEC10A           0.00000   507.41302   106.12845
#> HLA-DMA         179.04509  1004.15244   991.70658
#> RGS1            156.25000   194.03444    99.60967
#> HLA-DPB1        218.76408  6118.26123 11438.54732
#> HLA-DQA1         78.74016  1449.46085  2756.37908
#> RNF130          102.95020   729.42271    50.14345
#> HLA-DRB5        201.39673  2447.89939  3451.35131
#> HLA-DRB1        223.13447  4978.20467  8593.64301
#> CST3           1646.47567 14980.13267  4694.10624
#> IL1B             59.52381  1111.16205    24.17437
#> POP7            182.04163   901.68655    74.75283
#> HLA-DQA2          0.00000   376.25207   760.02313
#> CD1C              0.00000   124.01246    73.07923
#> GSTP1           848.07999  2375.48345  1121.28951
#> EIF3G          1916.25896   963.45261   872.77727
#> VPS28           918.97587  1188.35653   365.11862
#> LY86             47.16981   242.57276  1047.01085
#> ZFP36L1         421.98612   377.84251   276.16356
#> ZNF330           64.10256   853.10991   112.36948
#> ANXA2          1513.98457  1703.79599   813.27113
#> GRN             243.50668  1205.96237   271.83377
#> CFP             301.55698  1481.94174   361.31382
#> HSP90AA1       3000.49879   517.31991  2136.12249
#> FUOM            100.00000    95.84728    46.43292
#> LST1           1165.14097  6938.15341  1270.67357
#> AIF1           1591.18330  6827.91287  1123.73775
#> PSAP           1844.88258  3325.99257  1070.38405
#> YWHAB          1390.30301  1824.68786   865.98097
#> MYO1G           791.74900  1336.42976   515.49066
#> SAT1           4229.93880  8159.64679  1446.73115
#> RGS2            565.18310  1151.53504  1401.17773
#> SERPINA1        180.68905  1467.39403   157.43534
#> IFITM3          340.67616  2389.33681   405.36612
#> FCGR3A         1622.07013  1676.39187   298.21151
#> LILRA3           22.57336   158.64251   215.82734
#> S100A11        1766.45292  4391.84494   679.97503
#> FCER1G         3004.33967  5958.71342   598.82602
#> TNFRSF1B        147.18731   391.55141   150.82367
#> IFITM2         6307.35669  3925.83215  2118.69695
#> WARS            289.01397   444.43520   212.37804
#> IFI30           135.44018   990.53174   245.65227
#> MS4A7           123.88688   429.79759   224.88212
#> C5AR1             0.00000   535.83394   143.88489
#> HCK             112.86682   673.35846    64.51829
#> COTL1          3018.02421  7452.68819  2567.83458
#> LGALS9          264.03875   509.59224    48.22763
#> CD68            354.80749  1117.77721   183.62946
#> RP11-290F20.3   205.23598   498.79926    74.07407
#> RHOC            994.08639   813.14726   142.83758
#> CARD16          528.21951  1136.65990   318.97175
#> LRRC25           45.14673   485.32676   329.51111
#> COPS6           728.18882   902.66091    83.41034
#> ADAR            380.44606   932.73690   446.95918
#> PPBP          20290.32952   279.10900    52.35602
#> GPX1           7914.96371  3449.91487  1018.26553
#> TPM4           1861.98219   259.26308   198.46757
#> PF4            6912.89525     0.00000    34.96503
#> SDPR           3613.22405    85.83691    13.26260
#> NRGN           1219.69408   204.25993     0.00000
#> SPARC          1674.68407   114.16552     0.00000
#> GNG11          4038.62983    42.91845     0.00000
#> CLU            3445.25770    85.83691     0.00000
#> HIST1H2AC      2126.70269    42.91845    74.07407
#> NCOA4          2579.77551   178.90355    96.11682
#> GP9            1651.20658     0.00000     0.00000
#> FERMT3         1739.66923   247.34234    85.20505
#> ODC1           1257.17649   103.21577   183.46969
#> CD9            2934.13247   129.87013     0.00000
#> RUFY1           934.64232    25.83979   205.45970
#> TUBB1          2727.19100     0.00000     0.00000
#> TALDO1         3163.04923  1229.18908   293.69307
#> TREML1         1343.25007    85.83691     0.00000
#> NGFRAP1        1096.92899     0.00000     0.00000
#> PGRMC1          905.91510     0.00000     0.00000
#> CA2            1730.10367    30.48780     0.00000
#> ITGA2B         1083.44992    28.32861     0.00000
#> MYL9           1026.58929    42.91845     0.00000
#> TMEM40          684.89427     0.00000     0.00000
#> PARVB           767.91215    82.89047    71.94245
#> PTCRA          1005.00660     0.00000     0.00000
#> ACRBP           981.68353    42.91845     0.00000
#> TSC22D1         947.62549    42.91845     0.00000
#> VDAC3          3236.17886   118.68513  1531.03109
#> GZMB           4851.09276    80.99511   173.91304
#> GZMA           4755.15911    34.24658  1010.32218
#> GNLY          10938.54177    19.92032    48.22763
#> FGFBP2         3589.94393   131.59114   637.39220
#> AKR1C3         1054.07010     0.00000     0.00000
#> CCL4            990.46293    33.55705   260.86957
#> PRF1           5014.86261    34.24658  1057.17336
#> GZMH           2587.68994     0.00000   260.86957
#> XBP1           1718.44665    82.04771   253.02912
#> GZMM           1960.53443     0.00000   500.96816
#> PTGDR          1863.89932     0.00000   155.44967
#> IGFBP7         1147.26042   296.05343    34.40367
#> TTC38           408.04888    22.57336    86.95652
#> KLRD1           716.03992    27.70083     0.00000
#> ARHGDIA        1327.61710   433.51321   404.14446
#> IL2RB           542.62487     0.00000    74.07407
#> CLIC3           734.75690    25.83979    99.00990
#> PPP1R18        1263.94178   150.92677   693.34211
#> CD247          1406.39217    28.32861   158.89897
#> ALOX5AP        1294.56455   107.02753   711.52673
#> XCL2            457.35786     0.00000   158.89897
#> C12orf75        868.42778    13.42282   171.60545
#> RARRES3        2730.16684   119.59483   825.72007
#> PCMT1          3461.58957   424.54902   156.48957
#> LAMP1          1776.83609    39.26261    71.94245
#> SPON2          1377.77121    68.42595   447.48909
#> S100B           738.89638     0.00000     0.00000
#>