Skip to contents

Sums the values of all isoforms of a gene. A length assay is combined as the abundance-weighted mean when an abundance assay is supplied in the same list (the tximport convention). This is the function used by gene_assays() and can be called directly on matrices.

Usage

summarize_to_gene(x, tx_to_gene)

Arguments

x

A numeric matrix (transcripts in rows) or a named list of such matrices sharing row names.

tx_to_gene

Data frame with transcript_id and gene_id columns.

Value

A matrix, or a named list of matrices, with genes in rows.

Examples

iso <- example_isoformic()
g <- summarize_to_gene(tx_assay(iso, "abundance"), tx_to_gene(iso))
head(g)
#>                    SRR11498039 SRR11498040 SRR11498041 SRR11498042 SRR11498043
#> ENSG00000070404.12  2569.68384   299.07857  1417.10732   603.17133   471.63517
#> ENSG00000070831.20   122.70026    99.10083    80.20022    86.70524   124.04831
#> ENSG00000092199.21   266.25891   326.93814   276.23063   273.64675   514.47320
#> ENSG00000100567.15    83.58850    89.24681    83.38840    83.66714    89.96554
#> ENSG00000101181.20    19.77858    22.22232    26.51377    22.33130    22.33756
#> ENSG00000102755.15  6674.69963   294.43483  2383.73606   559.48987   632.91902
#>                    SRR11498044 SRR11498045 SRR11498046 SRR11498063 SRR11498064
#> ENSG00000070404.12   310.76213   896.73093  3187.15377    29.18200    31.38722
#> ENSG00000070831.20    78.78730   204.01240   107.61872    52.03164    35.00855
#> ENSG00000092199.21   289.21006   525.55022   327.02047   267.16888   228.18136
#> ENSG00000100567.15    84.23372   116.61350    96.74124   166.90329   113.95220
#> ENSG00000101181.20    21.93102    30.98572    19.77071    29.64593    26.51956
#> ENSG00000102755.15  1899.57688  3828.13284  3580.22704   168.79459   124.46575
#>                    SRR11498065 SRR11498066 SRR11498067 SRR11498068 SRR11498069
#> ENSG00000070404.12    48.99216    14.16329    66.08116    53.78511    13.59521
#> ENSG00000070831.20    38.44176    48.57682    51.06573    43.95347    43.87882
#> ENSG00000092199.21   239.72877   240.21498   277.28130   254.05305   257.29341
#> ENSG00000100567.15   118.80365   121.72739   161.33785   131.05597   111.49771
#> ENSG00000101181.20    21.75279    20.98340    28.30428    28.21587    23.79867
#> ENSG00000102755.15   142.90353   145.31683   220.13165   341.21090   115.23941
#>                    SRR11498070 SRR11498071 SRR11498072 SRR11498073 SRR11498074
#> ENSG00000070404.12    44.79135   136.64611    40.09664    17.48312    20.45126
#> ENSG00000070831.20    46.05098    43.95159    53.90587    55.45721    47.51016
#> ENSG00000092199.21   214.11104   227.47375   246.52902   220.25141   260.88590
#> ENSG00000100567.15   106.60685   124.09180   115.31332   105.69139   105.46941
#> ENSG00000101181.20    17.86774    23.33720    21.65134    21.76331    23.31649
#> ENSG00000102755.15   177.58189   447.94442   270.29311   169.66820   496.04255
#>                    SRR11498075 SRR11498076 SRR11498077 SRR11498078 SRR11498079
#> ENSG00000070404.12    18.72177    49.55750    19.41653   125.57957    17.47104
#> ENSG00000070831.20    36.86573    49.52355    47.49247    42.47217    35.72663
#> ENSG00000092199.21   217.86640   225.80300   225.53977   243.13445   238.39553
#> ENSG00000100567.15   102.48072   114.81176   114.87302   136.99088   106.77130
#> ENSG00000101181.20    23.07231    24.28106    24.41587    25.10409    22.52178
#> ENSG00000102755.15   192.84398   202.08497   209.51895   298.36576   134.90583