do.aggregate: Aggregate data using data.table functions - summarises the...

View source: R/do.aggregate.R

do.aggregateR Documentation

Aggregate data using data.table functions – summarises the mean, median, or sum expression of each marker on each cluster/population

Description

Aggregate data using data.table functions – summarises the mean, median, or sum expression of each marker on each cluster/population

Usage

do.aggregate(dat, use.cols, by, func, dt)

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

Value

Returns a new data.table with values of use.cols aggregated per cluster/population.

Author(s)

Thomas M Ashhurst, thomas.ashhurst@sydney.edu.au

References

https://github.com/ImmuneDynamics/Spectre.

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)])

ImmuneDynamics/Spectre documentation built on Nov. 12, 2023, 8:12 a.m.