Returns averaged expression values for each identity class

AverageExpression(
  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 averaging so that averaging is done in non-log space. Otherwise, if slot is set to either 'counts' or 'scale.data', no exponentiation is performed prior to averaging If return.seurat = TRUE and slot is not 'scale.data', averaged values are placed in the 'counts' slot of the returned object and the log of averaged values are placed in the 'data' slot. 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(AverageExpression(object = pbmc_small))
#> $RNA
#>                         0           1            2
#> MS4A1           0.0000000   2.0834431  171.6152133
#> CD79B          10.8146571  17.5488424  152.1344066
#> CD79A           0.0000000  11.6183331  215.0868777
#> HLA-DRA        37.1058569 405.8505224 1158.0852037
#> TCL1A           0.0000000   3.4632035  142.0747887
#> HLA-DQB1        3.9682540  45.3531831  169.2761547
#> HVCN1           0.0000000   5.5493118   74.7840655
#> HLA-DMB         0.6270379  19.7942417   74.2874820
#> LTB           261.9397358  20.8604601  265.6882303
#> LINC00926       0.0000000   0.0000000   30.9424559
#> FCER2           0.0000000   0.0000000   24.5493077
#> SP100          15.6005001   6.1750842   58.2192340
#> NCF1            0.0000000   6.8263157   42.6771926
#> PPP3CC         10.8216892   0.0000000   29.1362189
#> EAF2            0.0000000   2.5180144   40.3994289
#> PPAPDC1B        0.0000000   0.8658009   32.1424635
#> CD19            0.0000000   0.0000000   33.1904722
#> KIAA0125        0.0000000   0.0000000   26.4562923
#> CYB561A3        0.0000000   0.0000000   27.5709719
#> CD180           0.0000000   0.0000000   23.3758914
#> RP11-693J15.5   0.0000000   0.8658009   30.6821544
#> FAM96A         11.1722196   4.4577227   34.9186269
#> CXCR4          98.3338828  17.8901333  178.7297293
#> STX10          12.5045693   5.8300510   47.2829430
#> SNHG7          12.3074439   3.3061349   42.1701543
#> NT5C            4.1293941   3.6108167   65.3411927
#> BANK1           3.7950664   1.0282776   23.3701089
#> IGLL5           0.0000000   0.0000000  176.3232916
#> CD200           0.0000000   0.0000000   22.7075173
#> FCRLA           0.0000000   1.7316017   24.3058412
#> CD3D          153.5649197   0.8639309  127.0331731
#> NOSIP          73.2797394   9.0948849    7.6324578
#> SAFB2          16.5415100   0.0000000    0.0000000
#> CD2            42.1834786   0.5641749   10.3604644
#> IL7R          141.5908000   8.9462345   27.5432225
#> PIK3IP1        53.6527986   2.0360790   13.1724647
#> MPHOSPH6       25.3937763   2.3014087    3.7864445
#> KHDRBS1        72.0846330   3.8116218    2.6683984
#> MAL            16.0592569   1.0335917    0.0000000
#> CCR7           30.5272533   0.0000000    4.8285852
#> THYN1          34.1835381   1.9420980    4.2736648
#> TAF7           49.8036523   9.7831629   18.7491113
#> LDHB          123.7740433  22.4662941   69.9088096
#> TMEM123        73.5008600  14.7925494   48.3924124
#> CCDC104        12.2007319   0.0000000    4.2736648
#> EPC1           25.7422982   1.9184652   15.1113784
#> EIF4A2        128.1660254  18.6724383   72.4657157
#> CD3E           94.2411782   1.3422819   35.0592588
#> TMUB1          17.9154372   4.3086117    0.0000000
#> BLOC1S4        21.8578141   3.5277239    0.0000000
#> ACSM3          12.1098536   0.0000000    0.0000000
#> TMEM204        10.6040564   0.0000000    0.0000000
#> SRSF7         181.6092692  35.4752721   38.2142627
#> ACAP1          45.9035370   0.0000000    3.3591532
#> TNFAIP8        41.2141455   6.4144652   24.1945212
#> CD7            92.2752707   0.0000000   14.4498615
#> TAGAP          27.1580878   5.5600733   17.9769170
#> DNAJB1         40.4013422   8.6478486    7.5728891
#> ASNSD1         17.2698485   1.7167382    0.0000000
#> S1PR4          72.3405851   5.0372914   18.1405196
#> CTSW           86.7093191   1.0282776   51.7081787
#> GZMK           28.0274014   0.0000000   14.5700621
#> NKG7          512.8914342  22.0674777  258.4848943
#> IL32          177.4325769   3.7481188   58.9841613
#> DNAJC2         13.9224520   3.0907194   12.8961274
#> LYAR           47.0389185   5.5948469  188.9277890
#> CST7          102.6754272   1.9064568   43.8446120
#> LCK            65.8374079   0.7968127   22.0894637
#> CCL5          406.7622694  11.0377053  195.6632380
#> HNRNPH1        14.0128491   0.0000000   10.1346582
#> SSR2           88.3861651  25.8401080   53.0763673
#> DLGAP1-AS1      5.9481187   0.0000000    3.6049027
#> GIMAP1         69.2229891  11.9834749    5.0587798
#> MMADHC         17.0508955   4.9502520   28.4541742
#> ZNF76           6.1724389   0.9852217    3.6049027
#> CD8A           19.0675035   0.0000000   19.4851205
#> PTPN22          9.9284108   1.1080332    6.9192766
#> GYPC           72.6410338   1.1080332   24.8615048
#> HNRNPF         56.2569207   8.3439560   37.7838061
#> RPL7L1         12.5615300   3.3095509   14.7269828
#> KLRG1          34.3723933   0.0000000    3.7864445
#> CRBN           22.1006178   3.8728705   28.2132364
#> SATB1          44.6865377   0.0000000    4.4552066
#> SIT1            9.3470842   0.0000000   22.2153245
#> PMPCB           7.6908759   1.9928243   17.4507663
#> NRBP1          17.1156102   1.1331445    8.0601093
#> TCF7           23.7993821   0.5369128   10.6341475
#> HNRNPA3        33.9362413  11.1442131   36.6321466
#> S100A8          4.9650245 336.9712070    0.6035732
#> S100A9         18.7726466 656.1327572    5.6267095
#> LYZ            44.3166692 987.1410022  262.0950959
#> CD14            0.0000000  26.2034214    1.2071463
#> FCN1           22.2339539 120.6601510   34.1491283
#> TYROBP        109.2251513 358.4089463   31.4775288
#> ASGR1           0.0000000  11.6507481    0.6980316
#> NFKBIA         40.3551279  94.2730751   45.4429752
#> TYMP            8.5907702 120.5213230   19.3778870
#> CTSS           48.7494247 206.0390043   80.1845419
#> TSPO           27.2968127 121.0927239   28.0120931
#> RBP7            0.0000000  17.0683782    6.6622252
#> CTSB            5.0909681  42.2256517    4.4552066
#> LGALS1         89.1253535 323.0851850  109.9532830
#> FPR1            0.6270379  19.6836961    0.0000000
#> VSTM1           0.6270379   8.6799017    0.0000000
#> BLVRA          10.2053899  32.7495715   13.1200667
#> MPEG1           0.5270926  15.4504481    8.2584587
#> BID             8.3159934  61.1706349   10.2005619
#> SMCO4           0.0000000  18.3329748    3.7864445
#> CFD             5.1490875  65.3697594   11.9629067
#> LINC00936       8.1561448  28.4737760    8.4421203
#> LGALS2          6.9122942  65.8571844    9.8454601
#> MS4A6A          0.0000000  35.0271610   10.6865051
#> FCGRT           6.6727895  56.5610638    5.3075273
#> LGALS3          8.4439161  52.7662602    5.4617039
#> NUP214          3.2679739  23.2488624    1.8402650
#> SCO2            1.2540757  16.4105042    4.2841031
#> IL17RA          0.0000000   9.1053226    0.0000000
#> IFI6           19.7283090  57.5773537    3.6214389
#> HLA-DPA1       12.4868707 229.5861593  343.4057148
#> FCER1A          1.7806268  23.3089669   19.2093092
#> CLEC10A         0.0000000  20.2965208    5.5857079
#> HLA-DMA         4.9734748  40.1660976   52.1950830
#> RGS1            4.3402778   7.7613777    5.2426145
#> HLA-DPB1        6.0767799 244.7304494  602.0288064
#> HLA-DQA1        2.1872266  57.9784339  145.0725831
#> RNF130          2.8597276  29.1769083    2.6391289
#> HLA-DRB5        5.5943535  97.9159755  181.6500690
#> HLA-DRB1        6.1981797 199.1281870  452.2970007
#> CST3           45.7354352 599.2053066  247.0582232
#> IL1B            1.6534392  44.4464822    1.2723353
#> POP7            5.0567120  36.0674619    3.9343597
#> HLA-DQA2        0.0000000  15.0500829   40.0012173
#> CD1C            0.0000000   4.9604985    3.8462753
#> GSTP1          23.5577774  95.0193380   59.0152372
#> EIF3G          53.2294156  38.5381043   45.9356457
#> VPS28          25.5271076  47.5342614   19.2167697
#> LY86            1.3102725   9.7029106   55.1058343
#> ZFP36L1        11.7218366  15.1137006   14.5349240
#> ZNF330          1.7806268  34.1243965    5.9141833
#> ANXA2          42.0551269  68.1518395   42.8037437
#> GRN             6.7640746  48.2384947   14.3070408
#> CFP             8.3765829  59.2776697   19.0165168
#> HSP90AA1       83.3471887  20.6927962  112.4274996
#> FUOM            2.7777778   3.8338913    2.4438382
#> LST1           32.3650271 277.5261364   66.8775564
#> AIF1           44.1995361 273.1165147   59.1440920
#> PSAP           51.2467383 133.0397029   56.3360025
#> YWHAB          38.6195281  72.9875143   45.5779460
#> MYO1G          21.9930278  53.4571904   27.1310876
#> SAT1          117.4983001 326.3858717   76.1437446
#> RGS2           15.6995306  46.0614018   73.7461966
#> SERPINA1        5.0191403  58.6957612    8.2860703
#> IFITM3          9.4632268  95.5734723   21.3350591
#> FCGR3A         45.0575037  67.0556748   15.6953427
#> LILRA3          0.6270379   6.3457005   11.3593336
#> S100A11        49.0681367 175.6737977   35.7881594
#> FCER1G         83.4538796 238.3485366   31.5171587
#> TNFRSF1B        4.0885364  15.6620565    7.9380877
#> IFITM2        175.2043525 157.0332861  111.5103658
#> WARS            8.0281659  17.7774080   11.1777917
#> IFI30           3.7622272  39.6212698   12.9290671
#> MS4A7           3.4413023  17.1919037   11.8359012
#> C5AR1           0.0000000  21.4333574    7.5728891
#> HCK             3.1351894  26.9343385    3.3956994
#> COTL1          83.8340060 298.1075275  135.1491884
#> LGALS9          7.3344097  20.3836895    2.5382965
#> CD68            9.8557636  44.7110882    9.6647083
#> RP11-290F20.3   5.7009995  19.9519703    3.8986355
#> RHOC           27.6135109  32.5258906    7.5177676
#> CARD16         14.6727643  45.4663959   16.7879868
#> LRRC25          1.2540757  19.4130703   17.3426901
#> COPS6          20.2274673  36.1064364    4.3900177
#> ADAR           10.5679462  37.3094760   23.5241672
#> PPBP          563.6202644  11.1643601    2.7555800
#> GPX1          219.8601031 137.9965947   53.5929229
#> TPM4           51.7217276  10.3705233   10.4456613
#> PF4           192.0248681   0.0000000    1.8402650
#> SDPR          100.3673346   3.4334764    0.6980316
#> NRGN           33.8803910   8.1703970    0.0000000
#> SPARC          46.5190018   4.5666209    0.0000000
#> GNG11         112.1841619   1.7167382    0.0000000
#> CLU            95.7016028   3.4334764    0.0000000
#> HIST1H2AC      59.0750748   1.7167382    3.8986355
#> NCOA4          71.6604309   7.1561419    5.0587798
#> GP9            45.8668495   0.0000000    0.0000000
#> FERMT3         48.3241454   9.8936936    4.4844761
#> ODC1           34.9215692   4.1286308    9.6562995
#> CD9            81.5036796   5.1948052    0.0000000
#> RUFY1          25.9622868   1.0335917   10.8136685
#> TUBB1          75.7553056   0.0000000    0.0000000
#> TALDO1         87.8624787  49.1675633   15.4575299
#> TREML1         37.3125019   3.4334764    0.0000000
#> NGFRAP1        30.4702497   0.0000000    0.0000000
#> PGRMC1         25.1643084   0.0000000    0.0000000
#> CA2            48.0584353   1.2195122    0.0000000
#> ITGA2B         30.0958312   1.1331445    0.0000000
#> MYL9           28.5163692   1.7167382    0.0000000
#> TMEM40         19.0248410   0.0000000    0.0000000
#> PARVB          21.3308930   3.3156187    3.7864445
#> PTCRA          27.9168501   0.0000000    0.0000000
#> ACRBP          27.2689871   1.7167382    0.0000000
#> TSC22D1        26.3229303   1.7167382    0.0000000
#> VDAC3          89.8938572   4.7474053   80.5805836
#> GZMB          134.7525767   3.2398045    9.1533181
#> GZMA          132.0877530   1.3698630   53.1748514
#> GNLY          303.8483826   0.7968127    2.5382965
#> FGFBP2         99.7206648   5.2636456   33.5469581
#> AKR1C3         29.2797250   0.0000000    0.0000000
#> CCL4           27.5128591   1.3422819   13.7299771
#> PRF1          139.3017391   1.3698630   55.6407029
#> GZMH           71.8802761   0.0000000   13.7299771
#> XBP1           47.7346291   3.2819082   13.3173223
#> GZMM           54.4592898   0.0000000   26.3667455
#> PTGDR          51.7749811   0.0000000    8.1815617
#> IGFBP7         31.8683451  11.8421373    1.8107195
#> TTC38          11.3346912   0.9029345    4.5766590
#> KLRD1          19.8899977   1.1080332    0.0000000
#> ARHGDIA        36.8782529  17.3405284   21.2707611
#> IL2RB          15.0729130   0.0000000    3.8986355
#> CLIC3          20.4099139   1.0335917    5.2110474
#> PPP1R18        35.1094938   6.0370707   36.4916898
#> CD247          39.0664491   1.1331445    8.3631036
#> ALOX5AP        35.9601264   4.2811014   37.4487754
#> XCL2           12.7043849   0.0000000    8.3631036
#> C12orf75       24.1229940   0.5369128    9.0318657
#> RARRES3        75.8379678   4.7837931   43.4589512
#> PCMT1          96.1552660  16.9819608    8.2362929
#> LAMP1          49.3565581   1.5705045    3.7864445
#> SPON2          38.2714225   2.7370379   23.5520573
#> S100B          20.5248993   0.0000000    0.0000000
#>