Aggregate data using data.table functions – summarises the mean, median, or sum expression of each marker on each cluster/population
Source:R/do.aggregate.R
do.aggregate.Rd
Aggregate data using data.table functions – summarises the mean, median, or sum expression of each marker on each cluster/population
Arguments
- dat
NO DEFAULT. A data.table (or data.frame) containing the data to be aggregated.
- use.cols
NO DEFAULT. The columns to be used for aggregation.
- by
NO DEFAULT. The column that contains the cluster/population identities.
- func
DEFAULT = 'median'. Character, method of aggregation. Can be 'median', 'mean', or 'sum'.
- dt
DEFAULT = TRUE. If TRUE returns data.table with observations and the use.cols, if false returns data.frame with use.cols, and rownames as the observations
Author
Thomas M Ashhurst, thomas.ashhurst@sydney.edu.au
Examples
exp <- do.aggregate(dat = Spectre::demo.clustered,
use.cols = names(demo.clustered)[c(11:19)],
by = "Population")
# Typically followed up by making an expression heatmap
Spectre::make.pheatmap(dat = exp,
file.name = "Pheatmap.png",
plot.title = "Pheatmap",
sample.col = "Population",
plot.cols = names(exp)[c(2:10)])
#> Loading required package: pheatmap
#> Loading required package: RColorBrewer
#> Loading required package: scales
#> A pheatmap has been saved to your working directoryPheatmap.png